[Fix] Handle deprecated viewFilterOperand in workflows run & on interface (#14837)
In this PR https://github.com/twentyhq/twenty/pull/14785 we deprecated viewFilterOperand (from camelCase to capital snakeCase values), but we had not migrated the existing workflow steps values. Hence they cannot be executed! Let's fix that by dealing with both operands, new and deprecated, to mitigate the issue. Then we will add a command to migrate the values.
This commit is contained in:
+25
-10
@@ -1,19 +1,30 @@
|
||||
import { useRecoilComponentFamilyState } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyState';
|
||||
import { useSetRecoilComponentState } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentState';
|
||||
import { type FilterSettings } from '@/workflow/workflow-steps/workflow-actions/filter-action/components/WorkflowEditActionFilter';
|
||||
import { currentStepFilterGroupsComponentState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/currentStepFilterGroupsComponentState';
|
||||
import { currentStepFiltersComponentState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/currentStepFiltersComponentState';
|
||||
import { hasInitializedCurrentStepFilterGroupsComponentFamilyState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/hasInitializedCurrentStepFilterGroupsComponentFamilyState';
|
||||
import { hasInitializedCurrentStepFiltersComponentFamilyState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/hasInitializedCurrentStepFiltersComponentFamilyState';
|
||||
import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import {
|
||||
type StepFilterGroup,
|
||||
type StepFilterWithPotentiallyDeprecatedOperand,
|
||||
} from 'twenty-shared/types';
|
||||
import {
|
||||
convertViewFilterOperandToCoreOperand,
|
||||
isDefined,
|
||||
} from 'twenty-shared/utils';
|
||||
|
||||
type FilterSettingsWithPotentiallyDeprecatedOperand = {
|
||||
stepFilterGroups?: StepFilterGroup[];
|
||||
stepFilters?: StepFilterWithPotentiallyDeprecatedOperand[];
|
||||
};
|
||||
|
||||
export const WorkflowEditActionFilterBodyEffect = ({
|
||||
stepId,
|
||||
defaultValue,
|
||||
}: {
|
||||
stepId: string;
|
||||
defaultValue?: FilterSettings;
|
||||
defaultValue?: FilterSettingsWithPotentiallyDeprecatedOperand;
|
||||
}) => {
|
||||
const [
|
||||
hasInitializedCurrentStepFilters,
|
||||
@@ -39,19 +50,23 @@ export const WorkflowEditActionFilterBodyEffect = ({
|
||||
currentStepFilterGroupsComponentState,
|
||||
);
|
||||
|
||||
const stepFiltersConverted = useMemo(() => {
|
||||
return defaultValue?.stepFilters?.map((filter) => ({
|
||||
...filter,
|
||||
operand: convertViewFilterOperandToCoreOperand(filter.operand),
|
||||
}));
|
||||
}, [defaultValue?.stepFilters]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
!hasInitializedCurrentStepFilters &&
|
||||
isDefined(defaultValue?.stepFilters)
|
||||
) {
|
||||
setCurrentStepFilters(defaultValue.stepFilters ?? []);
|
||||
if (!hasInitializedCurrentStepFilters && isDefined(stepFiltersConverted)) {
|
||||
setCurrentStepFilters(stepFiltersConverted ?? []);
|
||||
setHasInitializedCurrentStepFilters(true);
|
||||
}
|
||||
}, [
|
||||
setCurrentStepFilters,
|
||||
hasInitializedCurrentStepFilters,
|
||||
setHasInitializedCurrentStepFilters,
|
||||
defaultValue?.stepFilters,
|
||||
stepFiltersConverted,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user