The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix workflow if-else node issues (#17244)
Abdul Rahman3c26ebace26b
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/filters/components/WorkflowStepFilterColumn.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/filters/components/WorkflowStepFilterColumn.tsxindex 067b023ba78..f25fe8612c6 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/filters/components/WorkflowStepFilterColumn.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/filters/components/WorkflowStepFilterColumn.tsx@@ -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>diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/if-else-action/components/WorkflowIfElseBranchEditor.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/if-else-action/components/WorkflowIfElseBranchEditor.tsxindex 33c544e2a67..2711bf4d27b 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/if-else-action/components/WorkflowIfElseBranchEditor.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/if-else-action/components/WorkflowIfElseBranchEditor.tsx@@ -8,7 +8,7 @@ import { type FilterSettings } from '@/workflow/workflow-steps/filters/types/Filimport { 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 ? (<WorkflowStepFilterGroupColumnkey={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>);};