@kestra-io/ui-libs 0.0.83 → 0.0.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/assets/icons/SplitCellsHorizontal.vue.d.ts +5 -0
  2. package/dist/assets/icons/SplitCellsHorizontal.vue.d.ts.map +1 -0
  3. package/dist/assets/icons/SplitCellsVertical.vue.d.ts +5 -0
  4. package/dist/assets/icons/SplitCellsVertical.vue.d.ts.map +1 -0
  5. package/dist/components/buttons/AddTaskButton.vue.d.ts +6 -0
  6. package/dist/components/buttons/AddTaskButton.vue.d.ts.map +1 -0
  7. package/dist/components/content/Alert.vue.d.ts +21 -0
  8. package/dist/components/content/Alert.vue.d.ts.map +1 -0
  9. package/dist/components/content/Collapse.vue.d.ts +21 -0
  10. package/dist/components/content/Collapse.vue.d.ts.map +1 -0
  11. package/dist/components/content/ConfigPropertyCard.vue.d.ts +11 -0
  12. package/dist/components/content/ConfigPropertyCard.vue.d.ts.map +1 -0
  13. package/dist/components/content/MDCRenderer.vue.d.ts +3 -0
  14. package/dist/components/content/MDCRenderer.vue.d.ts.map +1 -0
  15. package/dist/components/content/Mermaid.vue.d.ts +18 -0
  16. package/dist/components/content/Mermaid.vue.d.ts.map +1 -0
  17. package/dist/components/content/NextLink.vue.d.ts +18 -0
  18. package/dist/components/content/NextLink.vue.d.ts.map +1 -0
  19. package/dist/components/content/ProseBlockquote.vue.d.ts +18 -0
  20. package/dist/components/content/ProseBlockquote.vue.d.ts.map +1 -0
  21. package/dist/components/content/ProseCode.vue.d.ts +18 -0
  22. package/dist/components/content/ProseCode.vue.d.ts.map +1 -0
  23. package/dist/components/content/ProsePre.vue.d.ts +31 -0
  24. package/dist/components/content/ProsePre.vue.d.ts.map +1 -0
  25. package/dist/components/content/ProseTable.vue.d.ts +18 -0
  26. package/dist/components/content/ProseTable.vue.d.ts.map +1 -0
  27. package/dist/components/index.d.ts +9 -0
  28. package/dist/components/index.d.ts.map +1 -0
  29. package/dist/components/misc/Duration.vue.d.ts +6 -0
  30. package/dist/components/misc/Duration.vue.d.ts.map +1 -0
  31. package/dist/components/misc/ExecutionInformations.vue.d.ts +14 -0
  32. package/dist/components/misc/ExecutionInformations.vue.d.ts.map +1 -0
  33. package/dist/components/misc/State.vue.d.ts +8 -0
  34. package/dist/components/misc/State.vue.d.ts.map +1 -0
  35. package/dist/components/misc/TaskIcon.vue.d.ts +13 -0
  36. package/dist/components/misc/TaskIcon.vue.d.ts.map +1 -0
  37. package/dist/components/misc/Tooltip.vue.d.ts +29 -0
  38. package/dist/components/misc/Tooltip.vue.d.ts.map +1 -0
  39. package/dist/components/nodes/BasicNode.vue.d.ts +71 -0
  40. package/dist/components/nodes/BasicNode.vue.d.ts.map +1 -0
  41. package/dist/components/nodes/ClusterNode.vue.d.ts +49 -0
  42. package/dist/components/nodes/ClusterNode.vue.d.ts.map +1 -0
  43. package/dist/components/nodes/CollapsedClusterNode.vue.d.ts +190 -0
  44. package/dist/components/nodes/CollapsedClusterNode.vue.d.ts.map +1 -0
  45. package/dist/components/nodes/DependenciesNode.vue.d.ts +65 -0
  46. package/dist/components/nodes/DependenciesNode.vue.d.ts.map +1 -0
  47. package/dist/components/nodes/DotNode.vue.d.ts +133 -0
  48. package/dist/components/nodes/DotNode.vue.d.ts.map +1 -0
  49. package/dist/components/nodes/EdgeNode.vue.d.ts +103 -0
  50. package/dist/components/nodes/EdgeNode.vue.d.ts.map +1 -0
  51. package/dist/components/nodes/TaskNode.vue.d.ts +202 -0
  52. package/dist/components/nodes/TaskNode.vue.d.ts.map +1 -0
  53. package/dist/components/nodes/TriggerNode.vue.d.ts +170 -0
  54. package/dist/components/nodes/TriggerNode.vue.d.ts.map +1 -0
  55. package/dist/components/plugins/PropertyDetail.vue.d.ts +32 -0
  56. package/dist/components/plugins/PropertyDetail.vue.d.ts.map +1 -0
  57. package/dist/components/plugins/PropertyType.vue.d.ts +31 -0
  58. package/dist/components/plugins/PropertyType.vue.d.ts.map +1 -0
  59. package/dist/components/plugins/SchemaToCode.vue.d.ts +22 -0
  60. package/dist/components/plugins/SchemaToCode.vue.d.ts.map +1 -0
  61. package/dist/components/plugins/SchemaToHtml.vue.d.ts +53 -0
  62. package/dist/components/plugins/SchemaToHtml.vue.d.ts.map +1 -0
  63. package/dist/components/topology/Topology.vue.d.ts +157 -0
  64. package/dist/components/topology/Topology.vue.d.ts.map +1 -0
  65. package/dist/composables/getMDCParser.d.ts +3 -0
  66. package/dist/composables/getMDCParser.d.ts.map +1 -0
  67. package/dist/composables/useMarkdownParser.d.ts +4 -0
  68. package/dist/composables/useMarkdownParser.d.ts.map +1 -0
  69. package/dist/index.d.ts +8 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/kestra-ui.js +15093 -10840
  72. package/dist/kestra-ui.js.map +1 -1
  73. package/dist/kestra-ui.umd.cjs +47 -21
  74. package/dist/kestra-ui.umd.cjs.map +1 -1
  75. package/dist/style.css +1 -1
  76. package/dist/utils/Utils.d.ts +14 -0
  77. package/dist/utils/Utils.d.ts.map +1 -0
  78. package/dist/utils/VueFlowUtils.d.ts +93 -0
  79. package/dist/utils/VueFlowUtils.d.ts.map +1 -0
  80. package/dist/utils/YamlUtils.d.ts +42 -0
  81. package/dist/utils/YamlUtils.d.ts.map +1 -0
  82. package/dist/utils/constants.d.ts +33 -0
  83. package/dist/utils/constants.d.ts.map +1 -0
  84. package/dist/utils/global.d.ts +14 -0
  85. package/dist/utils/global.d.ts.map +1 -0
  86. package/dist/utils/state.d.ts +42 -0
  87. package/dist/utils/state.d.ts.map +1 -0
  88. package/package.json +45 -9
  89. package/src/components/buttons/AddTaskButton.vue +10 -15
  90. package/src/components/content/Alert.vue +8 -10
  91. package/src/components/content/Collapse.vue +10 -23
  92. package/src/components/content/ConfigPropertyCard.vue +8 -19
  93. package/src/components/content/MDCRenderer.vue +3 -2
  94. package/src/components/content/Mermaid.vue +2 -2
  95. package/src/components/content/NextLink.vue +1 -7
  96. package/src/components/content/ProseBlockquote.vue +0 -3
  97. package/src/components/content/ProsePre.vue +56 -73
  98. package/src/components/content/ProseTable.vue +0 -3
  99. package/src/components/index.ts +19 -0
  100. package/src/components/misc/Duration.vue +86 -86
  101. package/src/components/misc/ExecutionInformations.vue +94 -87
  102. package/src/components/misc/State.vue +47 -45
  103. package/src/components/misc/TaskIcon.vue +68 -83
  104. package/src/components/misc/Tooltip.vue +32 -34
  105. package/src/components/nodes/BasicNode.vue +5 -5
  106. package/src/components/nodes/ClusterNode.vue +3 -3
  107. package/src/components/nodes/CollapsedClusterNode.vue +3 -3
  108. package/src/components/nodes/DependenciesNode.vue +42 -45
  109. package/src/components/nodes/EdgeNode.vue +35 -35
  110. package/src/components/nodes/TaskNode.vue +8 -8
  111. package/src/components/nodes/TriggerNode.vue +4 -4
  112. package/src/components/plugins/PropertyDetail.vue +16 -23
  113. package/src/components/plugins/PropertyType.vue +32 -8
  114. package/src/components/plugins/SchemaToCode.vue +56 -77
  115. package/src/components/plugins/SchemaToHtml.vue +38 -14
  116. package/src/components/topology/Topology.vue +140 -126
  117. package/src/composables/getMDCParser.ts +13 -0
  118. package/src/composables/{useMarkdownParser.js → useMarkdownParser.ts} +39 -33
  119. package/src/index.ts +9 -0
  120. package/src/material-icons.d.ts +5 -0
  121. package/src/scss/color-palette.scss +73 -0
  122. package/src/scss/theme-dark.scss +160 -0
  123. package/src/scss/theme-light.scss +160 -0
  124. package/src/utils/Utils.ts +80 -0
  125. package/src/utils/VueFlowUtils.ts +707 -0
  126. package/src/utils/YamlUtils.ts +643 -0
  127. package/src/utils/{constants.js → constants.ts} +16 -18
  128. package/src/utils/global.ts +36 -0
  129. package/src/utils/{state.js → state.ts} +17 -8
  130. package/src/vite.d.ts +1 -0
  131. package/dist/_theme-dark.scss +0 -20
  132. package/dist/_variables.scss +0 -119
  133. package/src/components/index.js +0 -29
  134. package/src/index.js +0 -7
  135. package/src/utils/Utils.js +0 -62
  136. package/src/utils/VueFlowUtils.js +0 -502
  137. package/src/utils/YamlUtils.js +0 -554
  138. package/src/utils/global.js +0 -23
@@ -1,502 +0,0 @@
1
- import {MarkerType, Position, useVueFlow} from "@vue-flow/core"
2
- import dagre from "dagre";
3
- import {YamlUtils} from "../index.js";
4
- import Utils from "./Utils.js";
5
- import {CLUSTER_PREFIX, NODE_SIZES} from "./constants.js";
6
-
7
- const TRIGGERS_NODE_UID = "root.Triggers";
8
- export default class VueFlowUtils {
9
-
10
- static predecessorsEdge(vueFlowId, nodeUid) {
11
- const {getEdges} = useVueFlow(vueFlowId);
12
-
13
- let nodes = [];
14
-
15
- for (const edge of getEdges.value) {
16
- if (edge.target === nodeUid) {
17
- nodes.push(edge)
18
- let recursiveEdge = this.predecessorsEdge(vueFlowId, edge.source);
19
- if (recursiveEdge.length > 0) {
20
- nodes.push(...recursiveEdge);
21
- }
22
- }
23
- }
24
-
25
- return nodes;
26
- }
27
-
28
- static successorsEdge(vueFlowId, nodeUid) {
29
- const {getEdges} = useVueFlow(vueFlowId);
30
-
31
- let nodes = [];
32
-
33
- for (const edge of getEdges.value) {
34
- if (edge.source === nodeUid) {
35
- nodes.push(edge)
36
- let recursiveEdge = this.successorsEdge(vueFlowId, edge.target);
37
- if (recursiveEdge.length > 0) {
38
- nodes.push(...recursiveEdge);
39
- }
40
- }
41
- }
42
-
43
- return nodes;
44
- }
45
-
46
- static predecessorsNode(vueFlowId, nodeUid) {
47
- const {getEdges, findNode} = useVueFlow(vueFlowId);
48
-
49
- let nodes = [findNode(nodeUid)];
50
-
51
- for (const edge of getEdges.value) {
52
- if (edge.target === nodeUid) {
53
- nodes.push(edge.sourceNode)
54
- let recursiveEdge = this.predecessorsNode(vueFlowId, edge.source);
55
- if (recursiveEdge.length > 0) {
56
- nodes.push(...recursiveEdge);
57
- }
58
- }
59
- }
60
-
61
- return nodes;
62
- }
63
-
64
- static successorsNode(vueFlowId, nodeUid) {
65
- const {getEdges, findNode} = useVueFlow(vueFlowId);
66
-
67
- let nodes = [findNode(nodeUid)];
68
-
69
- for (const edge of getEdges.value) {
70
- if (edge.source === nodeUid) {
71
- nodes.push(edge.targetNode)
72
- let recursiveEdge = this.successorsNode(vueFlowId, edge.target);
73
- if (recursiveEdge.length > 0) {
74
- nodes.push(...recursiveEdge);
75
- }
76
- }
77
- }
78
-
79
- return nodes;
80
- }
81
-
82
- static linkedElements(vueFlowId, nodeUid) {
83
- return ([
84
- ...this.predecessorsEdge(vueFlowId, nodeUid),
85
- ...this.predecessorsNode(vueFlowId, nodeUid),
86
- ...this.successorsEdge(vueFlowId, nodeUid),
87
- ...this.successorsNode(vueFlowId, nodeUid),
88
- ])
89
- }
90
-
91
- static generateDagreGraph(flowGraph, hiddenNodes, isHorizontal, clustersWithoutRootNode, edgeReplacer, collapsed, clusterToNode) {
92
- const dagreGraph = new dagre.graphlib.Graph({compound: true})
93
- dagreGraph.setDefaultEdgeLabel(() => ({}))
94
- dagreGraph.setGraph({rankdir: isHorizontal ? "LR" : "TB"})
95
-
96
- for (const node of flowGraph.nodes) {
97
- if (!hiddenNodes.includes(node.uid)) {
98
- dagreGraph.setNode(node.uid, {
99
- width: this.getNodeWidth(node),
100
- height: this.getNodeHeight(node)
101
- })
102
- }
103
- }
104
-
105
- for (let cluster of (flowGraph.clusters || [])) {
106
- const nodeUid = cluster.cluster.uid.replace(CLUSTER_PREFIX, "");
107
- if (clustersWithoutRootNode.includes(cluster.cluster.uid) && collapsed.has(nodeUid)) {
108
- const node = {uid: nodeUid, type: "collapsedcluster"};
109
- dagreGraph.setNode(nodeUid, {
110
- width: this.getNodeWidth(node),
111
- height: this.getNodeHeight(node)
112
- });
113
- clusterToNode.push(node)
114
- continue
115
- }
116
- if (!edgeReplacer[cluster.cluster.uid]) {
117
- dagreGraph.setNode(cluster.cluster.uid, {clusterLabelPos: "top"});
118
-
119
- for (let node of (cluster.nodes || [])) {
120
- if (!hiddenNodes.includes(node)) {
121
- dagreGraph.setParent(node, cluster.cluster.uid)
122
- }
123
- }
124
- }
125
- if (cluster.parents) {
126
- const nodeChild = edgeReplacer[cluster.cluster.uid] ? edgeReplacer[cluster.cluster.uid] : cluster.cluster.uid
127
- if (!hiddenNodes.includes(nodeChild)) {
128
- dagreGraph.setParent(nodeChild, cluster.parents[cluster.parents.length - 1]);
129
- }
130
- }
131
- }
132
-
133
- for (const edge of (flowGraph.edges || [])) {
134
- const newEdge = this.replaceIfCollapsed(edge.source, edge.target, edgeReplacer, hiddenNodes);
135
- if (newEdge) {
136
- dagreGraph.setEdge(newEdge.source, newEdge.target)
137
- }
138
- }
139
-
140
- dagre.layout(dagreGraph)
141
- return dagreGraph;
142
- }
143
-
144
- static getNodePosition(n, parent) {
145
- const position = {x: n.x - n.width / 2, y: n.y - n.height / 2};
146
-
147
- // bug with parent node,
148
- if (parent) {
149
- const parentPosition = this.getNodePosition(parent);
150
- position.x = position.x - parentPosition.x;
151
- position.y = position.y - parentPosition.y;
152
- }
153
- return position;
154
- }
155
-
156
- static getNodeWidth(node) {
157
- return this.isTaskNode(node) || this.isTriggerNode(node) ? NODE_SIZES.TASK_WIDTH : this.isCollapsedCluster(node) ? NODE_SIZES.COLLAPSED_CLUSTER_WIDTH : NODE_SIZES.DOT_WIDTH;
158
- }
159
-
160
- static getNodeHeight(node) {
161
- return this.isTaskNode(node) || this.isTriggerNode(node) ? NODE_SIZES.TASK_HEIGHT : this.isCollapsedCluster(node) ? NODE_SIZES.COLLAPSED_CLUSTER_HEIGHT : NODE_SIZES.DOT_HEIGHT;
162
- }
163
-
164
- static isTaskNode(node) {
165
- return ["GraphTask", "SubflowGraphTask"].some(t => node.type.endsWith(t));
166
- }
167
-
168
- static isTriggerNode(node) {
169
- return node.type.endsWith("GraphTrigger");
170
- }
171
-
172
- static isCollapsedCluster(node) {
173
- return node.type === "collapsedcluster";
174
- }
175
-
176
- static replaceIfCollapsed(source, target, edgeReplacer, hiddenNodes) {
177
- const newSource = edgeReplacer[source] ? edgeReplacer[source] : source
178
- const newTarget = edgeReplacer[target] ? edgeReplacer[target] : target
179
-
180
- if (newSource === newTarget || (hiddenNodes.includes(newSource) || hiddenNodes.includes(newTarget))) {
181
- return null;
182
- }
183
- return {target: newTarget, source: newSource}
184
- }
185
-
186
- static cleanGraph(vueflowId) {
187
- const {
188
- getEdges,
189
- getNodes,
190
- getElements,
191
- removeEdges,
192
- removeNodes,
193
- removeSelectedElements
194
- } = useVueFlow(vueflowId);
195
- removeEdges(getEdges.value)
196
- removeNodes(getNodes.value)
197
- removeSelectedElements(getElements.value)
198
- }
199
-
200
- static flowHaveTasks(source) {
201
- return source ? YamlUtils.flowHaveTasks(source) : false;
202
- }
203
-
204
- static nodeColor(node, collapsed) {
205
- if (node.uid === TRIGGERS_NODE_UID) {
206
- return "success";
207
- }
208
-
209
- if (node.type === "dot") {
210
- return null;
211
- }
212
-
213
- if (this.isTriggerNode(node) || this.isCollapsedCluster(node)) {
214
- return "success";
215
- }
216
-
217
- if (node.type.endsWith("SubflowGraphTask")) {
218
- return "primary";
219
- }
220
- if (node.error) {
221
- return "danger";
222
- }
223
- if (collapsed.has(node.uid)) {
224
- return "blue";
225
- }
226
-
227
- return "default";
228
- }
229
-
230
- static haveAdd(edge, nodeByUid, clustersRootTaskUids, readOnlyUidPrefixes) {
231
- // prevent subflow edit (edge = subflowNode -> subflowNode)
232
- if(readOnlyUidPrefixes.some(prefix => edge.source.startsWith(prefix) && edge.target.startsWith(prefix))) {
233
- return undefined;
234
- }
235
-
236
- // edge = clusterRoot -> clusterRootTask
237
- if (clustersRootTaskUids.includes(edge.target)) {
238
- return undefined;
239
- }
240
-
241
- // edge = Triggers cluster -> something || edge = something -> Triggers cluster
242
- if(edge.source.startsWith(TRIGGERS_NODE_UID) || edge.target.startsWith(TRIGGERS_NODE_UID)) {
243
- return undefined;
244
- }
245
-
246
- const dotSplitTarget = edge.target.split(".");
247
- dotSplitTarget.pop();
248
- const targetNodeClusterUid = dotSplitTarget.join(".");
249
- const clusterRootTaskId = Utils.afterLastDot(targetNodeClusterUid);
250
-
251
- // edge = task of parallel -> end of parallel, we only add + symbol right after the parallel cluster root task node
252
- const targetNode = nodeByUid[edge.target];
253
- if(targetNode.type.endsWith("GraphClusterEnd") && nodeByUid[targetNodeClusterUid]?.task?.type?.endsWith("Parallel")) {
254
- return undefined;
255
- }
256
-
257
- // edge = something -> clusterRoot ==> we insert before the cluster
258
- // clusterUid = clusterTraversalPrefix.{rootTaskUid}
259
- // clusterRoot.uid = clusterUid.someUid = clusterTraversalPrefix.{rootTaskUid}.someUid
260
- if(targetNode.type.endsWith("GraphClusterRoot")) {
261
- return [clusterRootTaskId, "before"];
262
- }
263
-
264
- const sourceIsEndOfCluster = nodeByUid[edge.source].type.endsWith("GraphClusterEnd");
265
- // edge = clusterTask -> clusterEnd ==> we insert after the previous task
266
- if(!sourceIsEndOfCluster && targetNode.type.endsWith("GraphClusterEnd")) {
267
- return [Utils.afterLastDot(edge.source), "after"]
268
- }
269
-
270
- // edge = cluster1End -> something ==> we insert after cluster1
271
- if(sourceIsEndOfCluster) {
272
- const dotSplitSource = edge.source.split(".");
273
- return [dotSplitSource[dotSplitSource.length - 2], "after"];
274
- }
275
-
276
- return [Utils.afterLastDot(edge.target), "before"];
277
- }
278
-
279
- static getEdgeColor(edge, nodeByUid) {
280
- const sourceNode = nodeByUid[edge.source];
281
- const targetNode = nodeByUid[edge.target];
282
- if (sourceNode.error && targetNode.error) {
283
- return "danger"
284
- }
285
-
286
- if (sourceNode.type.endsWith("GraphClusterRoot") && targetNode.error) {
287
- return "danger"
288
- }
289
-
290
- if (sourceNode.error && targetNode.type.endsWith("GraphClusterEnd")) {
291
- return "danger"
292
- }
293
-
294
- return null;
295
- }
296
-
297
- static generateGraph(vueFlowId, flowId, namespace, flowGraph, flowSource, hiddenNodes, isHorizontal, edgeReplacer, collapsed, clusterToNode, isReadOnly, isAllowedEdit, enableSubflowInteraction) {
298
- const elements = [];
299
-
300
- const clustersWithoutRootNode = [CLUSTER_PREFIX + TRIGGERS_NODE_UID];
301
-
302
- if (!flowGraph || (flowSource && !this.flowHaveTasks(flowSource))) {
303
- elements.push({
304
- id: "start",
305
- type: "dot",
306
- position: {x: 0, y: 0},
307
- style: {
308
- width: "5px",
309
- height: "5px"
310
- },
311
- sourcePosition: isHorizontal ? Position.Right : Position.Bottom,
312
- targetPosition: isHorizontal ? Position.Left : Position.Top,
313
- parentNode: undefined,
314
- draggable: false,
315
- })
316
- elements.push({
317
- id: "end",
318
- type: "dot",
319
- position: isHorizontal ? {x: 50, y: 0} : {x: 0, y: 50},
320
- style: {
321
- width: "5px",
322
- height: "5px"
323
- },
324
- sourcePosition: isHorizontal ? Position.Right : Position.Bottom,
325
- targetPosition: isHorizontal ? Position.Left : Position.Top,
326
- parentNode: undefined,
327
- draggable: false,
328
- })
329
- elements.push({
330
- id: "start|end",
331
- source: "start",
332
- target: "end",
333
- type: "edge",
334
- data: {
335
- edge: {
336
- relation: {
337
- relationType: "SEQUENTIAL"
338
- }
339
- },
340
- isFlowable: false,
341
- initTask: true,
342
- color: "primary"
343
- }
344
- })
345
-
346
- return;
347
- }
348
-
349
- const dagreGraph = this.generateDagreGraph(flowGraph, hiddenNodes, isHorizontal, clustersWithoutRootNode, edgeReplacer, collapsed, clusterToNode);
350
-
351
- const clusterByNodeUid = {};
352
- const clusters = flowGraph.clusters || [];
353
- const rawClusters = clusters.map(c => c.cluster);
354
- const readOnlyUidPrefixes = rawClusters.filter(c => c.type.endsWith("SubflowGraphCluster")).map(c => c.taskNode.uid);
355
-
356
- const nodeByUid = Object.fromEntries(flowGraph.nodes.concat(clusterToNode).map(node => [node.uid, node]));
357
- for (let cluster of clusters) {
358
- if (!edgeReplacer[cluster.cluster.uid] && !collapsed.has(cluster.cluster.uid)) {
359
- if (cluster.cluster.taskNode?.task?.type === "io.kestra.core.tasks.flows.Dag") {
360
- readOnlyUidPrefixes.push(cluster.cluster.taskNode.uid);
361
- }
362
-
363
- for (let nodeUid of cluster.nodes) {
364
- clusterByNodeUid[nodeUid] = cluster.cluster;
365
- }
366
-
367
- const clusterUid = cluster.cluster.uid;
368
- const dagreNode = dagreGraph.node(clusterUid)
369
- const parentNode = cluster.parents ? cluster.parents[cluster.parents.length - 1] : undefined;
370
-
371
- const clusterColor = this.computeClusterColor(cluster.cluster);
372
-
373
- elements.push({
374
- id: clusterUid,
375
- type: "cluster",
376
- parentNode: parentNode,
377
- position: this.getNodePosition(dagreNode, parentNode ? dagreGraph.node(parentNode) : undefined),
378
- style: {
379
- width: clusterUid === TRIGGERS_NODE_UID && isHorizontal ? NODE_SIZES.TRIGGER_CLUSTER_WIDTH + "px" : dagreNode.width + "px",
380
- height: clusterUid === TRIGGERS_NODE_UID && !isHorizontal ? NODE_SIZES.TRIGGER_CLUSTER_HEIGHT + "px" : dagreNode.height + "px"
381
- },
382
- data: {
383
- collapsable: true,
384
- color: clusterColor,
385
- taskNode: cluster.cluster.taskNode,
386
- unused: cluster.cluster.taskNode ? nodeByUid[cluster.cluster.taskNode.uid].unused : false
387
- },
388
- class: `bg-light-${clusterColor}-border rounded p-2`,
389
- })
390
- }
391
- }
392
-
393
- for (const node of flowGraph.nodes.concat(clusterToNode)) {
394
- if (!hiddenNodes.includes(node.uid)) {
395
- const dagreNode = dagreGraph.node(node.uid);
396
- let nodeType = "task";
397
- if (this.isClusterRootOrEnd(node)) {
398
- nodeType = "dot";
399
- } else if (node.type.includes("GraphTrigger")) {
400
- nodeType = "trigger";
401
- } else if (node.type === "collapsedcluster") {
402
- nodeType = "collapsedcluster";
403
- }
404
-
405
- const color = this.nodeColor(node, collapsed);
406
- // If task type includes '$', it's an inner class so it's probably an internal class not supposed to be editable
407
- // In such case, only the root task will be editable
408
- const isReadOnlyTask = isReadOnly || node.task?.type?.includes("$") || readOnlyUidPrefixes.some(prefix => node.uid.startsWith(prefix + "."));
409
- elements.push({
410
- id: node.uid,
411
- type: nodeType,
412
- position: this.getNodePosition(dagreNode, clusterByNodeUid[node.uid] ? dagreGraph.node(clusterByNodeUid[node.uid].uid) : undefined),
413
- style: {
414
- width: this.getNodeWidth(node) + "px",
415
- height: this.getNodeHeight(node) + "px"
416
- },
417
- sourcePosition: isHorizontal ? Position.Right : Position.Bottom,
418
- targetPosition: isHorizontal ? Position.Left : Position.Top,
419
- parentNode: clusterByNodeUid[node.uid] ? clusterByNodeUid[node.uid].uid : undefined,
420
- draggable: nodeType === "task" ? !isReadOnlyTask : false,
421
- data: {
422
- node: node,
423
- namespace: clusterByNodeUid[node.uid]?.taskNode?.task?.namespace ?? namespace,
424
- flowId: clusterByNodeUid[node.uid]?.taskNode?.task?.flowId ?? flowId,
425
- isFlowable: clusterByNodeUid[node.uid]?.uid === CLUSTER_PREFIX + node.uid && !node.type.endsWith("SubflowGraphTask"),
426
- color: color,
427
- expandable: this.isExpandableTask(node, clusterByNodeUid, edgeReplacer, enableSubflowInteraction),
428
- isReadOnly: isReadOnlyTask,
429
- iconComponent: this.isCollapsedCluster(node) ? "lightning-bolt" : null,
430
- executionId: node.executionId,
431
- unused: node.unused
432
- },
433
- class: node.type === "collapsedcluster" ? `bg-light-${color}-border rounded` : "",
434
- })
435
- }
436
- }
437
-
438
- const clusterRootTaskNodeUids = rawClusters.filter(c => c.taskNode).map(c => c.taskNode.uid);
439
- const edges = flowGraph.edges ?? [];
440
-
441
- for (const edge of edges) {
442
- const newEdge = this.replaceIfCollapsed(edge.source, edge.target, edgeReplacer, hiddenNodes);
443
- if (newEdge) {
444
- elements.push({
445
- id: newEdge.source + "|" + newEdge.target,
446
- source: newEdge.source,
447
- target: newEdge.target,
448
- type: "edge",
449
- markerEnd: this.isClusterRootOrEnd(nodeByUid[newEdge.target]) ? ""
450
- : {
451
- id: nodeByUid[newEdge.target].error ? "marker-danger" : "marker-custom",
452
- type: MarkerType.ArrowClosed,
453
- },
454
- data: {
455
- haveAdd: !isReadOnly && isAllowedEdit && this.haveAdd(edge, nodeByUid, clusterRootTaskNodeUids, readOnlyUidPrefixes),
456
- haveDashArray: nodeByUid[edge.source].type.endsWith("GraphTrigger")
457
- || nodeByUid[edge.target].type.endsWith("GraphTrigger")
458
- || edge.source.startsWith(TRIGGERS_NODE_UID),
459
- color: this.getEdgeColor(edge, nodeByUid),
460
- unused: edge.unused
461
- },
462
- style: {
463
- zIndex: 10,
464
- }
465
- })
466
- }
467
- }
468
- return elements;
469
- }
470
-
471
- static isClusterRootOrEnd(node) {
472
- return ["GraphClusterRoot", "GraphClusterEnd"].some(s => node.type.endsWith(s));
473
- }
474
-
475
- static computeClusterColor(cluster) {
476
- if (cluster.uid === CLUSTER_PREFIX + TRIGGERS_NODE_UID) {
477
- return "success";
478
- }
479
-
480
- if (cluster.type.endsWith("SubflowGraphCluster")) {
481
- return "primary";
482
- }
483
-
484
- if (cluster.error) {
485
- return "danger";
486
- }
487
-
488
- return "blue";
489
- }
490
-
491
- static isExpandableTask(node, clusterByNodeUid, edgeReplacer, enableSubflowInteraction) {
492
- if (Object.values(edgeReplacer).includes(node.uid)) {
493
- return true;
494
- }
495
-
496
- if (this.isCollapsedCluster(node)) {
497
- return true;
498
- }
499
-
500
- return node.type.endsWith("SubflowGraphTask") && clusterByNodeUid[node.uid]?.uid?.replace(CLUSTER_PREFIX, "") !== node.uid && enableSubflowInteraction;
501
- }
502
- }