Fix workflow if-else node issues (#17244)

This commit is contained in:
Abdul Rahman
2026-01-19 21:12:06 +05:30
committed by GitHub
parent 28e98086b0
commit 3c26ebace2
2 changed files with 36 additions and 36 deletions
@@ -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>
@@ -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>
);
};