|
1 |
| -import {EDGE_STYLES} from '@/shared/constants'; |
| 1 | +import {EDGE_STYLES, TASK_DISPATCHER_NAMES} from '@/shared/constants'; |
2 | 2 | import {WorkflowTask} from '@/shared/middleware/platform/configuration';
|
3 | 3 | import {NodeDataType} from '@/shared/types';
|
4 | 4 | import {Edge, Node} from '@xyflow/react';
|
@@ -64,24 +64,46 @@ function createEdgesForEmptyEach(eachId: string): Edge[] {
|
64 | 64 | }
|
65 | 65 |
|
66 | 66 | 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 | + |
67 | 72 | 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`, |
71 | 76 | style: EDGE_STYLES,
|
72 |
| - target: eachChildTask.name, |
| 77 | + target: childTaskId, |
73 | 78 | type: 'smoothstep',
|
74 | 79 | };
|
75 | 80 |
|
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 | + }; |
83 | 93 |
|
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 | + } |
85 | 107 | }
|
86 | 108 |
|
87 | 109 | /**
|
|
0 commit comments