fix: remove empty else-if branches and add numbering (#17315)
This commit is contained in:
+29
-4
@@ -104,21 +104,46 @@ export const removeStep = ({
|
||||
});
|
||||
}
|
||||
|
||||
const finalNextStepIds = updatedNextStepIds.filter(
|
||||
(id) => !allRemovedStepIds.includes(id),
|
||||
);
|
||||
|
||||
return {
|
||||
...branch,
|
||||
nextStepIds: updatedNextStepIds.filter(
|
||||
(id) => !allRemovedStepIds.includes(id),
|
||||
),
|
||||
nextStepIds: finalNextStepIds,
|
||||
};
|
||||
});
|
||||
|
||||
const filteredBranches = updatedBranches.filter(
|
||||
(branch, branchIndex) => {
|
||||
const isIfBranch = branchIndex === 0;
|
||||
const isElseBranch =
|
||||
branchIndex === updatedBranches.length - 1 &&
|
||||
!isDefined(branch.filterGroupId);
|
||||
const isElseIfBranch =
|
||||
branchIndex > 0 &&
|
||||
branchIndex < updatedBranches.length - 1 &&
|
||||
isDefined(branch.filterGroupId);
|
||||
|
||||
if (isIfBranch || isElseBranch) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isElseIfBranch && branch.nextStepIds.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
...step,
|
||||
settings: {
|
||||
...step.settings,
|
||||
input: {
|
||||
...step.settings.input,
|
||||
branches: updatedBranches,
|
||||
branches: filteredBranches,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user