The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Hide iteration switcher for steps following iterators (#14810)
Baptiste Devessiera68aa303aa1e
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/isParentStep.ts b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/isParentStep.tsdeleted file mode 100644index 6f6b2b54c6e..00000000000--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/isParentStep.ts+++ /dev/null@@ -1,33 +0,0 @@-import { type WorkflowStep } from '@/workflow/types/Workflow';-import { isLastStepOfLoop } from '@/workflow/workflow-diagram/utils/isLastStepOfLoop';--export const isParentStep = ({- currentStep,- potentialParentStep,- steps,-}: {- currentStep: WorkflowStep;- potentialParentStep: WorkflowStep;- steps: WorkflowStep[];-}): boolean => {- if (potentialParentStep.type === 'ITERATOR') {- return !!(- potentialParentStep.settings.input.initialLoopStepIds?.includes(- currentStep.id,- ) || potentialParentStep.nextStepIds?.includes(currentStep.id)- );- }-- if (currentStep.type === 'ITERATOR') {- return !!(- potentialParentStep.nextStepIds?.includes(currentStep.id) &&- !isLastStepOfLoop({- iterator: currentStep,- stepId: potentialParentStep.id,- steps,- })- );- }-- return !!potentialParentStep.nextStepIds?.includes(currentStep.id);-};diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getIsDescendantOfIterator.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getIsDescendantOfIterator.test.tsindex 630cc94dfc8..a8f86db7406 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getIsDescendantOfIterator.test.ts+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getIsDescendantOfIterator.test.ts@@ -68,11 +68,10 @@ describe('getIsDescendantOfIterator', () => {).toBe(true);});- it('returns true for indirect descendant', () => {- // step3 is pointed to by iterator1.nextStepIds+ it('returns false for indirect descendant', () => {expect(getIsDescendantOfIterator({ stepId: codeStep3.id, steps: workflow }),- ).toBe(true);+ ).toBe(false);});it('returns false for iterator itself', () => {@@ -109,5 +108,3 @@ describe('getIsDescendantOfIterator', () => {).toBe(false);});});--// ...existing test code...diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getIsDescendantOfIterator.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getIsDescendantOfIterator.tsindex 580b7efc25c..c668e4760cb 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getIsDescendantOfIterator.ts+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getIsDescendantOfIterator.ts@@ -1,7 +1,38 @@import { type WorkflowStep } from '@/workflow/types/Workflow';-import { isParentStep } from '@/workflow/workflow-diagram/utils/isParentStep';+import { isLastStepOfLoop } from '@/workflow/workflow-diagram/utils/isLastStepOfLoop';import { TRIGGER_STEP_ID } from 'twenty-shared/workflow';+const isParentStep = ({+ currentStep,+ potentialParentStep,+ steps,+}: {+ currentStep: WorkflowStep;+ potentialParentStep: WorkflowStep;+ steps: WorkflowStep[];+}): boolean => {+ if (potentialParentStep.type === 'ITERATOR') {+ return (+ potentialParentStep.settings.input.initialLoopStepIds?.includes(+ currentStep.id,+ ) === true+ );+ }++ if (currentStep.type === 'ITERATOR') {+ return (+ potentialParentStep.nextStepIds?.includes(currentStep.id) === true &&+ !isLastStepOfLoop({+ iterator: currentStep,+ stepId: potentialParentStep.id,+ steps,+ })+ );+ }++ return potentialParentStep.nextStepIds?.includes(currentStep.id) === true;+};+export const getIsDescendantOfIterator = ({stepId,steps,diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getWorkflowPreviousSteps.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getWorkflowPreviousSteps.tsindex 574ec3091da..bd5f88b21a2 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getWorkflowPreviousSteps.ts+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getWorkflowPreviousSteps.ts@@ -1,5 +1,36 @@import { type WorkflowStep } from '@/workflow/types/Workflow';-import { isParentStep } from '@/workflow/workflow-diagram/utils/isParentStep';+import { isLastStepOfLoop } from '@/workflow/workflow-diagram/utils/isLastStepOfLoop';++const isParentStep = ({+ currentStep,+ potentialParentStep,+ steps,+}: {+ currentStep: WorkflowStep;+ potentialParentStep: WorkflowStep;+ steps: WorkflowStep[];+}): boolean => {+ if (potentialParentStep.type === 'ITERATOR') {+ return !!(+ potentialParentStep.settings.input.initialLoopStepIds?.includes(+ currentStep.id,+ ) || potentialParentStep.nextStepIds?.includes(currentStep.id)+ );+ }++ if (currentStep.type === 'ITERATOR') {+ return !!(+ potentialParentStep.nextStepIds?.includes(currentStep.id) &&+ !isLastStepOfLoop({+ iterator: currentStep,+ stepId: potentialParentStep.id,+ steps,+ })+ );+ }++ return !!potentialParentStep.nextStepIds?.includes(currentStep.id);+};export const getPreviousSteps = ({steps,