Add empty operands to UUID filter type in workflow filter action (#20821)
## Summary - Adds `IS_EMPTY` and `IS_NOT_EMPTY` operands to the UUID entry in `getStepFilterOperands`, aligning the workflow filter action with the find records (search) action which already includes these operands for ID-type fields. ## Test plan - [ ] Open a workflow with a filter action, select an ID-type field, and verify the operand dropdown now includes "Is empty" and "Is not empty" - [ ] Open a workflow with a find records action, select an ID-type field, and verify the operand dropdown is consistent with the filter action --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
+295
@@ -0,0 +1,295 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`getStepFilterOperands ACTOR returns RELATION operands when subFieldName is workspaceMemberId 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands ACTOR returns SELECT operands when subFieldName is source 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands ACTOR returns TEXT operands when subFieldName is undefined 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands ACTOR returns TEXT operands when subFieldName is unknown 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands CURRENCY returns amountMicros operands when subFieldName is amountMicros 1`] = `
|
||||
[
|
||||
"GREATER_THAN_OR_EQUAL",
|
||||
"LESS_THAN_OR_EQUAL",
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands CURRENCY returns amountMicros operands when subFieldName is undefined 1`] = `
|
||||
[
|
||||
"GREATER_THAN_OR_EQUAL",
|
||||
"LESS_THAN_OR_EQUAL",
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands CURRENCY returns currencyCode operands when subFieldName is currencyCode 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=ADDRESS 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=ARRAY 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=BOOLEAN 1`] = `
|
||||
[
|
||||
"IS",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=DATE 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_RELATIVE",
|
||||
"IS_IN_PAST",
|
||||
"IS_IN_FUTURE",
|
||||
"IS_TODAY",
|
||||
"IS_BEFORE",
|
||||
"IS_AFTER",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=DATE_TIME 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_RELATIVE",
|
||||
"IS_IN_PAST",
|
||||
"IS_IN_FUTURE",
|
||||
"IS_TODAY",
|
||||
"IS_BEFORE",
|
||||
"IS_AFTER",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=EMAILS 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=FULL_NAME 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=LINKS 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=MULTI_SELECT 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=NUMBER 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"GREATER_THAN_OR_EQUAL",
|
||||
"LESS_THAN_OR_EQUAL",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=NUMERIC 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"GREATER_THAN_OR_EQUAL",
|
||||
"LESS_THAN_OR_EQUAL",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=PHONES 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=RATING 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"GREATER_THAN_OR_EQUAL",
|
||||
"LESS_THAN_OR_EQUAL",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=RAW_JSON 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=RELATION 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=SELECT 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=TEXT 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=UNKNOWN_TYPE_FALLS_THROUGH 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"GREATER_THAN_OR_EQUAL",
|
||||
"LESS_THAN_OR_EQUAL",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=UUID 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=array 1`] = `
|
||||
[
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=boolean 1`] = `
|
||||
[
|
||||
"IS",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=number 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"GREATER_THAN_OR_EQUAL",
|
||||
"LESS_THAN_OR_EQUAL",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`getStepFilterOperands returns the expected operands for filterType=undefined 1`] = `
|
||||
[
|
||||
"IS",
|
||||
"IS_NOT",
|
||||
"CONTAINS",
|
||||
"DOES_NOT_CONTAIN",
|
||||
"GREATER_THAN_OR_EQUAL",
|
||||
"LESS_THAN_OR_EQUAL",
|
||||
"IS_EMPTY",
|
||||
"IS_NOT_EMPTY",
|
||||
]
|
||||
`;
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
import { getStepFilterOperands } from '@/workflow/workflow-steps/filters/utils/getStepFilterOperands';
|
||||
|
||||
const filterTypesWithoutSubField = [
|
||||
'TEXT',
|
||||
'EMAILS',
|
||||
'FULL_NAME',
|
||||
'ADDRESS',
|
||||
'LINKS',
|
||||
'PHONES',
|
||||
'NUMBER',
|
||||
'number',
|
||||
'RAW_JSON',
|
||||
'DATE_TIME',
|
||||
'DATE',
|
||||
'RATING',
|
||||
'RELATION',
|
||||
'MULTI_SELECT',
|
||||
'SELECT',
|
||||
'ARRAY',
|
||||
'array',
|
||||
'BOOLEAN',
|
||||
'boolean',
|
||||
'UUID',
|
||||
'NUMERIC',
|
||||
'UNKNOWN_TYPE_FALLS_THROUGH',
|
||||
undefined,
|
||||
] as const;
|
||||
|
||||
describe('getStepFilterOperands', () => {
|
||||
it.each(filterTypesWithoutSubField)(
|
||||
'returns the expected operands for filterType=%s',
|
||||
(filterType) => {
|
||||
const operands = getStepFilterOperands({
|
||||
filterType,
|
||||
subFieldName: undefined,
|
||||
});
|
||||
|
||||
expect(operands).toMatchSnapshot();
|
||||
},
|
||||
);
|
||||
|
||||
describe('CURRENCY', () => {
|
||||
it('returns currencyCode operands when subFieldName is currencyCode', () => {
|
||||
const operands = getStepFilterOperands({
|
||||
filterType: 'CURRENCY',
|
||||
subFieldName: 'currencyCode',
|
||||
});
|
||||
|
||||
expect(operands).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('returns amountMicros operands when subFieldName is amountMicros', () => {
|
||||
const operands = getStepFilterOperands({
|
||||
filterType: 'CURRENCY',
|
||||
subFieldName: 'amountMicros',
|
||||
});
|
||||
|
||||
expect(operands).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('returns amountMicros operands when subFieldName is undefined', () => {
|
||||
const operands = getStepFilterOperands({
|
||||
filterType: 'CURRENCY',
|
||||
subFieldName: undefined,
|
||||
});
|
||||
|
||||
expect(operands).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ACTOR', () => {
|
||||
it('returns SELECT operands when subFieldName is source', () => {
|
||||
const operands = getStepFilterOperands({
|
||||
filterType: 'ACTOR',
|
||||
subFieldName: 'source',
|
||||
});
|
||||
|
||||
expect(operands).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('returns RELATION operands when subFieldName is workspaceMemberId', () => {
|
||||
const operands = getStepFilterOperands({
|
||||
filterType: 'ACTOR',
|
||||
subFieldName: 'workspaceMemberId',
|
||||
});
|
||||
|
||||
expect(operands).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('returns TEXT operands when subFieldName is unknown', () => {
|
||||
const operands = getStepFilterOperands({
|
||||
filterType: 'ACTOR',
|
||||
subFieldName: 'someUnknownSubField',
|
||||
});
|
||||
|
||||
expect(operands).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('returns TEXT operands when subFieldName is undefined', () => {
|
||||
const operands = getStepFilterOperands({
|
||||
filterType: 'ACTOR',
|
||||
subFieldName: undefined,
|
||||
});
|
||||
|
||||
expect(operands).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
+7
-81
@@ -1,15 +1,9 @@
|
||||
import {
|
||||
COMPOSITE_FIELD_FILTER_OPERANDS_MAP,
|
||||
FILTER_OPERANDS_MAP,
|
||||
} from '@/object-record/record-filter/utils/getRecordFilterOperands';
|
||||
import { ViewFilterOperand } from 'twenty-shared/types';
|
||||
|
||||
const emptyOperands = [
|
||||
ViewFilterOperand.IS_EMPTY,
|
||||
ViewFilterOperand.IS_NOT_EMPTY,
|
||||
] as const;
|
||||
|
||||
const relationOperands = [
|
||||
ViewFilterOperand.IS,
|
||||
ViewFilterOperand.IS_NOT,
|
||||
] as const;
|
||||
|
||||
const defaultOperands = [
|
||||
ViewFilterOperand.IS,
|
||||
ViewFilterOperand.IS_NOT,
|
||||
@@ -17,78 +11,10 @@ const defaultOperands = [
|
||||
ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
ViewFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
...emptyOperands,
|
||||
ViewFilterOperand.IS_EMPTY,
|
||||
ViewFilterOperand.IS_NOT_EMPTY,
|
||||
] as const;
|
||||
|
||||
export const FILTER_OPERANDS_MAP = {
|
||||
TEXT: [
|
||||
ViewFilterOperand.CONTAINS,
|
||||
ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
NUMBER: [
|
||||
ViewFilterOperand.IS,
|
||||
ViewFilterOperand.IS_NOT,
|
||||
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
ViewFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
...emptyOperands,
|
||||
],
|
||||
RAW_JSON: [
|
||||
ViewFilterOperand.CONTAINS,
|
||||
ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
DATE_TIME: [
|
||||
ViewFilterOperand.IS,
|
||||
ViewFilterOperand.IS_IN_PAST,
|
||||
ViewFilterOperand.IS_IN_FUTURE,
|
||||
ViewFilterOperand.IS_TODAY,
|
||||
ViewFilterOperand.IS_BEFORE,
|
||||
ViewFilterOperand.IS_AFTER,
|
||||
ViewFilterOperand.IS_RELATIVE,
|
||||
...emptyOperands,
|
||||
],
|
||||
RATING: [ViewFilterOperand.IS, ViewFilterOperand.IS_NOT, ...emptyOperands],
|
||||
RELATION: [...relationOperands, ...emptyOperands],
|
||||
MULTI_SELECT: [
|
||||
ViewFilterOperand.CONTAINS,
|
||||
ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
SELECT: [ViewFilterOperand.IS, ViewFilterOperand.IS_NOT, ...emptyOperands],
|
||||
ARRAY: [
|
||||
ViewFilterOperand.CONTAINS,
|
||||
ViewFilterOperand.DOES_NOT_CONTAIN,
|
||||
...emptyOperands,
|
||||
],
|
||||
BOOLEAN: [ViewFilterOperand.IS],
|
||||
UUID: [ViewFilterOperand.IS, ViewFilterOperand.IS_NOT],
|
||||
NUMERIC: [
|
||||
ViewFilterOperand.IS,
|
||||
ViewFilterOperand.IS_NOT,
|
||||
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
ViewFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
...emptyOperands,
|
||||
],
|
||||
};
|
||||
|
||||
export const COMPOSITE_FIELD_FILTER_OPERANDS_MAP = {
|
||||
CURRENCY: {
|
||||
currencyCode: [
|
||||
ViewFilterOperand.IS,
|
||||
ViewFilterOperand.IS_NOT,
|
||||
...emptyOperands,
|
||||
],
|
||||
amountMicros: [
|
||||
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
|
||||
ViewFilterOperand.LESS_THAN_OR_EQUAL,
|
||||
ViewFilterOperand.IS,
|
||||
ViewFilterOperand.IS_NOT,
|
||||
...emptyOperands,
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const getStepFilterOperands = ({
|
||||
filterType,
|
||||
subFieldName,
|
||||
@@ -136,7 +62,7 @@ export const getStepFilterOperands = ({
|
||||
case 'UUID':
|
||||
return FILTER_OPERANDS_MAP.UUID;
|
||||
case 'NUMERIC':
|
||||
return FILTER_OPERANDS_MAP.NUMERIC;
|
||||
return FILTER_OPERANDS_MAP.NUMBER;
|
||||
case 'ACTOR': {
|
||||
if (subFieldName === 'source') {
|
||||
return FILTER_OPERANDS_MAP.SELECT;
|
||||
|
||||
Reference in New Issue
Block a user