Skip to content

Commit 4d85581

Browse files
committed
2949 - fix Each edges
1 parent 1abfc42 commit 4d85581

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

client/src/pages/platform/workflow-editor/utils/createEachEdges.ts

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {EDGE_STYLES} from '@/shared/constants';
1+
import {EDGE_STYLES, TASK_DISPATCHER_NAMES} from '@/shared/constants';
22
import {WorkflowTask} from '@/shared/middleware/platform/configuration';
33
import {NodeDataType} from '@/shared/types';
44
import {Edge, Node} from '@xyflow/react';
@@ -64,24 +64,46 @@ function createEdgesForEmptyEach(eachId: string): Edge[] {
6464
}
6565

6666
function createEdgeSubtaskEdges(eachId: string, eachChildTask: WorkflowTask): Edge[] {
67+
const topGhostId = `${eachId}-each-top-ghost`;
68+
const bottomGhostId = `${eachId}-each-bottom-ghost`;
69+
const childTaskId = eachChildTask.name;
70+
const childTaskComponentName = childTaskId.split('_')[0];
71+
6772
const edgeFromTopGhostToChildTask = {
68-
id: `${eachId}-each-top-ghost=>${eachChildTask.name}`,
69-
source: `${eachId}-each-top-ghost`,
70-
sourceHandle: `${eachId}-each-top-ghost-right`,
73+
id: `${topGhostId}=>${childTaskId}`,
74+
source: topGhostId,
75+
sourceHandle: `${topGhostId}-right`,
7176
style: EDGE_STYLES,
72-
target: eachChildTask.name,
77+
target: childTaskId,
7378
type: 'smoothstep',
7479
};
7580

76-
const edgeFromSubtaskToBottomGhost = {
77-
id: `${eachChildTask.name}=>${eachId}-each-bottom-ghost`,
78-
source: eachChildTask.name,
79-
style: EDGE_STYLES,
80-
target: `${eachId}-each-bottom-ghost`,
81-
type: 'smoothstep',
82-
};
81+
// Check if the child task is itself a task dispatcher
82+
if (TASK_DISPATCHER_NAMES.includes(childTaskComponentName) && childTaskComponentName !== 'loopBreak') {
83+
const nestedBottomGhostId = `${childTaskId}-${childTaskComponentName}-bottom-ghost`;
84+
85+
const edgeFromNestedGhostToBottomGhost = {
86+
id: `${nestedBottomGhostId}=>${bottomGhostId}`,
87+
source: nestedBottomGhostId,
88+
style: EDGE_STYLES,
89+
target: bottomGhostId,
90+
targetHandle: `${bottomGhostId}-right`,
91+
type: 'smoothstep',
92+
};
8393

84-
return [edgeFromTopGhostToChildTask, edgeFromSubtaskToBottomGhost];
94+
return [edgeFromTopGhostToChildTask, edgeFromNestedGhostToBottomGhost];
95+
} else {
96+
const edgeFromSubtaskToBottomGhost = {
97+
id: `${childTaskId}=>${bottomGhostId}`,
98+
source: childTaskId,
99+
style: EDGE_STYLES,
100+
target: bottomGhostId,
101+
targetHandle: `${bottomGhostId}-right`,
102+
type: 'smoothstep',
103+
};
104+
105+
return [edgeFromTopGhostToChildTask, edgeFromSubtaskToBottomGhost];
106+
}
85107
}
86108

87109
/**

client/src/pages/platform/workflow-editor/utils/taskDispatcherConfig.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export const TASK_DISPATCHER_CONFIG = {
301301
return [];
302302
}
303303

304-
return parameters.iteratee;
304+
return [parameters.iteratee];
305305
},
306306
getTask: getTaskDispatcherTask,
307307
initializeParameters: () => ({
@@ -311,7 +311,7 @@ export const TASK_DISPATCHER_CONFIG = {
311311
...task,
312312
parameters: {
313313
...task.parameters,
314-
iteratee: updatedSubtasks,
314+
iteratee: updatedSubtasks[0] || null,
315315
},
316316
}),
317317
},

0 commit comments

Comments
 (0)