[View migration] Clean ViewFilterOperand (#14785)

In the BE we have stored filter operand as IS_EMPTY, IS_NOT_EMPTY, etc. 
For some reason in the FE we were manipulating IsEmpty, IsNotEmpty, etc.
(maybe because they were used before in Views before they were moved to
core)

So we were converting the operands in the FE from IS to Is
(convertViewFilterOperandFromCore) to read and manipulate viewFilters,
and then back to BE version to send mutations etc., from Is to IS
(convertViewFilterOperandToCore).
The migration is now over, so we can remove and simplify that code. 
(In the 1-5:migrate-views-to-core command we still do the migration from
Is format to IS format.)
This commit is contained in:
Marie
2025-09-30 17:12:03 +02:00
committed by GitHub
parent 15975a2cfc
commit 3927b36406
88 changed files with 730 additions and 853 deletions
@@ -25,7 +25,7 @@ const BASE_NEW_STEP_FILTER = {
type: 'unknown',
label: '',
value: '',
operand: ViewFilterOperand.Is,
operand: ViewFilterOperand.IS,
displayValue: '',
stepFilterGroupId: '',
stepOutputKey: '',
@@ -163,7 +163,7 @@ export const WorkflowStepFilterValueInput = ({
);
}
if (isDateField && stepFilter.operand === ViewFilterOperand.IsRelative) {
if (isDateField && stepFilter.operand === ViewFilterOperand.IS_RELATIVE) {
return (
<FormRelativeDatePicker
defaultValue={stepFilter.value}
@@ -51,7 +51,7 @@ const CONFIGURED_ACTION: WorkflowFilterAction = {
id: 'filter-1',
stepFilterGroupId: 'filter-group-1',
stepOutputKey: 'company.name',
operand: ViewFilterOperand.Contains,
operand: ViewFilterOperand.CONTAINS,
value: 'Acme',
type: 'string',
},
@@ -26,7 +26,7 @@ const TEXT_STEP_FILTER: StepFilter = {
stepOutputKey: 'company.name',
type: 'text',
value: 'Acme',
operand: ViewFilterOperand.Contains,
operand: ViewFilterOperand.CONTAINS,
};
const meta: Meta<typeof WorkflowStepFilterColumn> = {
@@ -14,7 +14,7 @@ const DEFAULT_STEP_FILTER: StepFilter = {
stepFilterGroupId: 'filter-group-1',
stepOutputKey: '',
type: 'text',
operand: ViewFilterOperand.Is,
operand: ViewFilterOperand.IS,
value: '',
positionInStepFilterGroup: 0,
};
@@ -15,7 +15,7 @@ const DEFAULT_STEP_FILTER: StepFilter = {
stepFilterGroupId: 'filter-group-1',
stepOutputKey: 'company.name',
type: 'text',
operand: ViewFilterOperand.Contains,
operand: ViewFilterOperand.CONTAINS,
value: '',
positionInStepFilterGroup: 0,
};
@@ -25,7 +25,7 @@ const GREATER_THAN_FILTER: StepFilter = {
stepFilterGroupId: 'filter-group-1',
stepOutputKey: 'company.employees',
type: 'number',
operand: ViewFilterOperand.GreaterThanOrEqual,
operand: ViewFilterOperand.GREATER_THAN_OR_EQUAL,
value: '100',
positionInStepFilterGroup: 0,
};
@@ -15,7 +15,7 @@ const TEXT_FILTER: StepFilter = {
stepFilterGroupId: 'filter-group-1',
stepOutputKey: 'company.name',
type: 'text',
operand: ViewFilterOperand.Contains,
operand: ViewFilterOperand.CONTAINS,
value: 'Acme',
positionInStepFilterGroup: 0,
};
@@ -25,7 +25,7 @@ const NUMBER_FILTER: StepFilter = {
stepFilterGroupId: 'filter-group-1',
stepOutputKey: 'company.employees',
type: 'number',
operand: ViewFilterOperand.GreaterThanOrEqual,
operand: ViewFilterOperand.GREATER_THAN_OR_EQUAL,
value: '100',
positionInStepFilterGroup: 0,
};
@@ -50,7 +50,7 @@ export const useAddRootStepFilter = () => {
id: v4(),
type: 'unknown',
value: '',
operand: ViewFilterOperand.Is,
operand: ViewFilterOperand.IS,
stepFilterGroupId: newStepFilterGroup.id,
stepOutputKey: '',
positionInStepFilterGroup: 0,
@@ -1,69 +1,69 @@
import { ViewFilterOperand } from 'twenty-shared/types';
const emptyOperands = [
ViewFilterOperand.IsEmpty,
ViewFilterOperand.IsNotEmpty,
ViewFilterOperand.IS_EMPTY,
ViewFilterOperand.IS_NOT_EMPTY,
] as const;
const relationOperands = [
ViewFilterOperand.Is,
ViewFilterOperand.IsNot,
ViewFilterOperand.IS,
ViewFilterOperand.IS_NOT,
] as const;
const defaultOperands = [
ViewFilterOperand.Is,
ViewFilterOperand.IsNot,
ViewFilterOperand.Contains,
ViewFilterOperand.DoesNotContain,
ViewFilterOperand.GreaterThanOrEqual,
ViewFilterOperand.LessThanOrEqual,
ViewFilterOperand.IS,
ViewFilterOperand.IS_NOT,
ViewFilterOperand.CONTAINS,
ViewFilterOperand.DOES_NOT_CONTAIN,
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
ViewFilterOperand.LESS_THAN_OR_EQUAL,
...emptyOperands,
] as const;
export const FILTER_OPERANDS_MAP = {
TEXT: [
ViewFilterOperand.Contains,
ViewFilterOperand.DoesNotContain,
ViewFilterOperand.CONTAINS,
ViewFilterOperand.DOES_NOT_CONTAIN,
...emptyOperands,
],
NUMBER: [
ViewFilterOperand.GreaterThanOrEqual,
ViewFilterOperand.LessThanOrEqual,
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
ViewFilterOperand.LESS_THAN_OR_EQUAL,
...emptyOperands,
],
RAW_JSON: [
ViewFilterOperand.Contains,
ViewFilterOperand.DoesNotContain,
ViewFilterOperand.CONTAINS,
ViewFilterOperand.DOES_NOT_CONTAIN,
...emptyOperands,
],
DATE_TIME: [
ViewFilterOperand.Is,
ViewFilterOperand.IsInPast,
ViewFilterOperand.IsInFuture,
ViewFilterOperand.IsToday,
ViewFilterOperand.IsBefore,
ViewFilterOperand.IsAfter,
ViewFilterOperand.IsRelative,
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.IsNot, ...emptyOperands],
RATING: [ViewFilterOperand.IS, ViewFilterOperand.IS_NOT, ...emptyOperands],
RELATION: [...relationOperands, ...emptyOperands],
MULTI_SELECT: [
ViewFilterOperand.Contains,
ViewFilterOperand.DoesNotContain,
ViewFilterOperand.CONTAINS,
ViewFilterOperand.DOES_NOT_CONTAIN,
...emptyOperands,
],
SELECT: [ViewFilterOperand.Is, ViewFilterOperand.IsNot, ...emptyOperands],
SELECT: [ViewFilterOperand.IS, ViewFilterOperand.IS_NOT, ...emptyOperands],
ARRAY: [
ViewFilterOperand.Contains,
ViewFilterOperand.DoesNotContain,
ViewFilterOperand.CONTAINS,
ViewFilterOperand.DOES_NOT_CONTAIN,
...emptyOperands,
],
BOOLEAN: [ViewFilterOperand.Is],
UUID: [ViewFilterOperand.Is],
BOOLEAN: [ViewFilterOperand.IS],
UUID: [ViewFilterOperand.IS],
NUMERIC: [
ViewFilterOperand.GreaterThanOrEqual,
ViewFilterOperand.LessThanOrEqual,
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
ViewFilterOperand.LESS_THAN_OR_EQUAL,
...emptyOperands,
],
};
@@ -71,15 +71,15 @@ export const FILTER_OPERANDS_MAP = {
export const COMPOSITE_FIELD_FILTER_OPERANDS_MAP = {
CURRENCY: {
currencyCode: [
ViewFilterOperand.Is,
ViewFilterOperand.IsNot,
ViewFilterOperand.IS,
ViewFilterOperand.IS_NOT,
...emptyOperands,
],
amountMicros: [
ViewFilterOperand.GreaterThanOrEqual,
ViewFilterOperand.LessThanOrEqual,
ViewFilterOperand.Is,
ViewFilterOperand.IsNot,
ViewFilterOperand.GREATER_THAN_OR_EQUAL,
ViewFilterOperand.LESS_THAN_OR_EQUAL,
ViewFilterOperand.IS,
ViewFilterOperand.IS_NOT,
...emptyOperands,
],
},
@@ -33,7 +33,7 @@ export const WorkflowAdvancedFilterRecordFilterOperandSelect = ({
? getRecordFilterOperands({
filterType,
subFieldName: filter?.subFieldName,
}).filter((operand) => operand !== RecordFilterOperand.IsRelative)
}).filter((operand) => operand !== RecordFilterOperand.IS_RELATIVE)
: [];
if (isDisabled === true) {