Hide iteration switcher for steps following iterators (#14810)
## Before https://github.com/user-attachments/assets/a8eca1aa-b2b6-4fdb-8848-65c8235a330c ## After https://github.com/user-attachments/assets/84b7e969-423b-4f0e-8f53-524bfb11e2ca
This commit is contained in:
committed by
GitHub
parent
f302b7c74e
commit
a68aa303aa
@@ -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);
|
||||
};
|
||||
+2
-5
@@ -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...
|
||||
|
||||
+32
-1
@@ -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,
|
||||
|
||||
+32
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user