965 flow control arrow menu 1/3 add insert step button (#12519)
Add insert step button to workflow edges https://github.com/user-attachments/assets/7144f722-f1c7-450f-a8eb-c902071986a1 Also fixes `iconButtonGroup` UI component ## Before https://github.com/user-attachments/assets/7b5f0245-d0e8-48af-9aa5-a29388a1caea ## After https://github.com/user-attachments/assets/1820874f-aa99-41ae-8254-c76c275ee3ae
This commit is contained in:
@ -38,7 +38,8 @@ describe('insertStep', () => {
|
||||
insertedStep: newStep,
|
||||
});
|
||||
|
||||
expect(result).toEqual([step1, step2, newStep]);
|
||||
expect(result.updatedSteps).toEqual([step1, step2, newStep]);
|
||||
expect(result.updatedInsertedStep).toEqual(newStep);
|
||||
});
|
||||
|
||||
it('should update parent step nextStepIds when inserting a step between two steps', () => {
|
||||
@ -53,7 +54,7 @@ describe('insertStep', () => {
|
||||
nextStepId: '2',
|
||||
});
|
||||
|
||||
expect(result).toEqual([
|
||||
expect(result.updatedSteps).toEqual([
|
||||
{ ...step1, nextStepIds: ['new'] },
|
||||
step2,
|
||||
{ ...newStep, nextStepIds: ['2'] },
|
||||
@ -71,7 +72,10 @@ describe('insertStep', () => {
|
||||
nextStepId: '1',
|
||||
});
|
||||
|
||||
expect(result).toEqual([step1, { ...newStep, nextStepIds: ['1'] }]);
|
||||
expect(result.updatedSteps).toEqual([
|
||||
step1,
|
||||
{ ...newStep, nextStepIds: ['1'] },
|
||||
]);
|
||||
});
|
||||
|
||||
it('should handle inserting a step at the end of the workflow', () => {
|
||||
@ -85,7 +89,10 @@ describe('insertStep', () => {
|
||||
nextStepId: undefined,
|
||||
});
|
||||
|
||||
expect(result).toEqual([{ ...step1, nextStepIds: ['new'] }, newStep]);
|
||||
expect(result.updatedSteps).toEqual([
|
||||
{ ...step1, nextStepIds: ['new'] },
|
||||
newStep,
|
||||
]);
|
||||
});
|
||||
|
||||
it('should handle inserting a step between two steps with multiple nextStepIds', () => {
|
||||
@ -101,7 +108,7 @@ describe('insertStep', () => {
|
||||
nextStepId: '2',
|
||||
});
|
||||
|
||||
expect(result).toEqual([
|
||||
expect(result.updatedSteps).toEqual([
|
||||
{ ...step1, nextStepIds: ['3', 'new'] },
|
||||
step2,
|
||||
step3,
|
||||
|
||||
@ -10,7 +10,7 @@ export const insertStep = ({
|
||||
insertedStep: WorkflowAction;
|
||||
parentStepId?: string;
|
||||
nextStepId?: string;
|
||||
}): WorkflowAction[] => {
|
||||
}): { updatedSteps: WorkflowAction[]; updatedInsertedStep: WorkflowAction } => {
|
||||
const updatedExistingSteps = existingSteps.map((existingStep) => {
|
||||
if (existingStep.id === parentStepId) {
|
||||
return {
|
||||
@ -28,11 +28,13 @@ export const insertStep = ({
|
||||
return existingStep;
|
||||
});
|
||||
|
||||
return [
|
||||
...updatedExistingSteps,
|
||||
{
|
||||
...insertedStep,
|
||||
nextStepIds: nextStepId ? [nextStepId] : undefined,
|
||||
},
|
||||
];
|
||||
const updatedInsertedStep = {
|
||||
...insertedStep,
|
||||
nextStepIds: nextStepId ? [nextStepId] : undefined,
|
||||
};
|
||||
|
||||
return {
|
||||
updatedSteps: [...updatedExistingSteps, updatedInsertedStep],
|
||||
updatedInsertedStep,
|
||||
};
|
||||
};
|
||||
|
||||
@ -96,7 +96,8 @@ export class WorkflowVersionStepWorkspaceService {
|
||||
assertWorkflowVersionIsDraft(workflowVersion);
|
||||
|
||||
const existingSteps = workflowVersion.steps || [];
|
||||
const updatedSteps = insertStep({
|
||||
|
||||
const { updatedSteps, updatedInsertedStep } = insertStep({
|
||||
existingSteps,
|
||||
insertedStep: enrichedNewStep,
|
||||
parentStepId,
|
||||
@ -107,7 +108,7 @@ export class WorkflowVersionStepWorkspaceService {
|
||||
steps: updatedSteps,
|
||||
});
|
||||
|
||||
return enrichedNewStep;
|
||||
return updatedInsertedStep;
|
||||
}
|
||||
|
||||
async updateWorkflowVersionStep({
|
||||
|
||||
Reference in New Issue
Block a user