Fix workflow if-else node issues (#17244)
This commit is contained in:
+3
-1
@@ -14,6 +14,7 @@ type WorkflowStepFilterColumnProps = {
|
||||
stepFilter: StepFilter;
|
||||
stepFilterIndex: number;
|
||||
firstFilterLabel?: string;
|
||||
preventDeletion?: boolean;
|
||||
};
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
@@ -28,10 +29,11 @@ export const WorkflowStepFilterColumn = ({
|
||||
stepFilter,
|
||||
stepFilterIndex,
|
||||
firstFilterLabel,
|
||||
preventDeletion = false,
|
||||
}: WorkflowStepFilterColumnProps) => {
|
||||
const { readonly } = useContext(WorkflowStepFilterContext);
|
||||
|
||||
const shouldShowDropdown = !readonly;
|
||||
const shouldShowDropdown = !readonly && !preventDeletion;
|
||||
|
||||
return (
|
||||
<AdvancedFilterCommandMenuColumn>
|
||||
|
||||
+33
-35
@@ -8,7 +8,7 @@ import { type FilterSettings } from '@/workflow/workflow-steps/filters/types/Fil
|
||||
import { isStepFilterGroupChildAStepFilterGroup } from '@/workflow/workflow-steps/filters/utils/isStepFilterGroupChildAStepFilterGroup';
|
||||
import styled from '@emotion/styled';
|
||||
import { i18n, type MessageDescriptor } from '@lingui/core';
|
||||
import { type StepFilterGroup } from 'twenty-shared/types';
|
||||
import { type StepFilter, type StepFilterGroup } from 'twenty-shared/types';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
import { type StepIfElseBranch } from 'twenty-shared/workflow';
|
||||
|
||||
@@ -58,9 +58,7 @@ export const WorkflowIfElseBranchEditor = ({
|
||||
|
||||
const isIfBranch = branchIndex === 0;
|
||||
|
||||
const isLastFilterInIfBranch = (stepFilter: {
|
||||
stepFilterGroupId: string;
|
||||
}): boolean => {
|
||||
const isLastFilterInIfBranch = (stepFilter: StepFilter): boolean => {
|
||||
const childStepFilters = childStepFiltersAndChildStepFilterGroups.filter(
|
||||
(child) => !isStepFilterGroupChildAStepFilterGroup(child),
|
||||
);
|
||||
@@ -79,26 +77,25 @@ export const WorkflowIfElseBranchEditor = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledBranchContainer>
|
||||
<StyledFiltersContainer>
|
||||
{isDefined(branchFilterGroup) &&
|
||||
childStepFiltersAndChildStepFilterGroups.map(
|
||||
(stepFilterGroupChild, stepFilterGroupChildIndex) => (
|
||||
<WorkflowStepFilterContext.Provider
|
||||
key={stepFilterGroupChild.id}
|
||||
value={{
|
||||
stepId: action.id,
|
||||
readonly: isStepFilterGroupChildAStepFilterGroup(
|
||||
stepFilterGroupChild,
|
||||
)
|
||||
? readonly
|
||||
: readonly || isLastFilterInIfBranch(stepFilterGroupChild),
|
||||
onFilterSettingsUpdate,
|
||||
}}
|
||||
>
|
||||
{isStepFilterGroupChildAStepFilterGroup(
|
||||
stepFilterGroupChild,
|
||||
) ? (
|
||||
<WorkflowStepFilterContext.Provider
|
||||
value={{
|
||||
stepId: action.id,
|
||||
readonly: readonly,
|
||||
onFilterSettingsUpdate,
|
||||
}}
|
||||
>
|
||||
<StyledBranchContainer>
|
||||
<StyledFiltersContainer>
|
||||
{isDefined(branchFilterGroup) &&
|
||||
childStepFiltersAndChildStepFilterGroups.map(
|
||||
(stepFilterGroupChild, stepFilterGroupChildIndex) => {
|
||||
const isFilterGroup =
|
||||
isStepFilterGroupChildAStepFilterGroup(stepFilterGroupChild);
|
||||
const preventDeletion =
|
||||
!isFilterGroup &&
|
||||
isLastFilterInIfBranch(stepFilterGroupChild);
|
||||
|
||||
return isFilterGroup ? (
|
||||
<WorkflowStepFilterGroupColumn
|
||||
key={stepFilterGroupChild.id}
|
||||
parentStepFilterGroup={branchFilterGroup}
|
||||
@@ -114,18 +111,19 @@ export const WorkflowIfElseBranchEditor = ({
|
||||
firstFilterLabel={capitalize(
|
||||
i18n._(branchLabel).toLowerCase(),
|
||||
)}
|
||||
preventDeletion={preventDeletion}
|
||||
/>
|
||||
)}
|
||||
</WorkflowStepFilterContext.Provider>
|
||||
),
|
||||
)}
|
||||
</StyledFiltersContainer>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</StyledFiltersContainer>
|
||||
|
||||
{!readonly && isDefined(branchFilterGroup) && (
|
||||
<WorkflowStepFilterAddFilterRuleSelect
|
||||
stepFilterGroup={branchFilterGroup}
|
||||
/>
|
||||
)}
|
||||
</StyledBranchContainer>
|
||||
{!readonly && isDefined(branchFilterGroup) && (
|
||||
<WorkflowStepFilterAddFilterRuleSelect
|
||||
stepFilterGroup={branchFilterGroup}
|
||||
/>
|
||||
)}
|
||||
</StyledBranchContainer>
|
||||
</WorkflowStepFilterContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user