@uipath/apollo-react 3.68.3 → 3.69.0-pr458.25d2dee
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.
- package/dist/canvas/components/CanvasPerformance.stories.cjs +349 -0
- package/dist/canvas/components/CanvasPerformance.stories.d.ts +6 -0
- package/dist/canvas/components/CanvasPerformance.stories.d.ts.map +1 -0
- package/dist/canvas/components/CanvasPerformance.stories.js +312 -0
- package/dist/canvas/components/NodePropertiesPanel/hooks/index.cjs +4 -1
- package/dist/canvas/components/NodePropertiesPanel/hooks/index.d.ts +1 -1
- package/dist/canvas/components/NodePropertiesPanel/hooks/index.d.ts.map +1 -1
- package/dist/canvas/components/NodePropertiesPanel/hooks/index.js +2 -2
- package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.cjs +27 -6
- package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.d.ts +3 -0
- package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.d.ts.map +1 -1
- package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.js +23 -5
- package/dist/canvas/components/StageNode/AdhocTask.cjs +4 -5
- package/dist/canvas/components/StageNode/AdhocTask.d.ts +2 -3
- package/dist/canvas/components/StageNode/AdhocTask.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/AdhocTask.js +4 -5
- package/dist/canvas/components/StageNode/DraggableTask.cjs +14 -5
- package/dist/canvas/components/StageNode/DraggableTask.d.ts +1 -1
- package/dist/canvas/components/StageNode/DraggableTask.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/DraggableTask.js +14 -5
- package/dist/canvas/components/StageNode/DraggableTask.types.d.ts +3 -3
- package/dist/canvas/components/StageNode/DraggableTask.types.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageEdge.cjs +34 -11
- package/dist/canvas/components/StageNode/StageEdge.d.ts +2 -1
- package/dist/canvas/components/StageNode/StageEdge.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageEdge.js +35 -12
- package/dist/canvas/components/StageNode/StageNode.cjs +30 -59
- package/dist/canvas/components/StageNode/StageNode.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.js +35 -64
- package/dist/canvas/components/StageNode/StageNode.stories.cjs +127 -179
- package/dist/canvas/components/StageNode/StageNode.stories.d.ts +2 -2
- package/dist/canvas/components/StageNode/StageNode.stories.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.stories.js +123 -175
- package/dist/canvas/components/StageNode/StageNode.stories.utils.cjs +45 -0
- package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts +8 -0
- package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts.map +1 -0
- package/dist/canvas/components/StageNode/StageNode.stories.utils.js +11 -0
- package/dist/canvas/components/StageNode/StageNode.types.d.ts +9 -4
- package/dist/canvas/components/StageNode/StageNode.types.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageTaskDragOverlay.cjs +69 -0
- package/dist/canvas/components/StageNode/StageTaskDragOverlay.d.ts +3 -0
- package/dist/canvas/components/StageNode/StageTaskDragOverlay.d.ts.map +1 -0
- package/dist/canvas/components/StageNode/StageTaskDragOverlay.js +35 -0
- package/dist/canvas/components/StageNode/TaskMenu.cjs +14 -17
- package/dist/canvas/components/StageNode/TaskMenu.d.ts +1 -2
- package/dist/canvas/components/StageNode/TaskMenu.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/TaskMenu.js +15 -18
- package/dist/canvas/components/StageNode/index.d.ts +1 -1
- package/dist/canvas/components/StageNode/index.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.cjs +10 -2
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.js +9 -2
- package/dist/canvas/components/StickyNoteNode/useScrollCapture.cjs +72 -0
- package/dist/canvas/components/StickyNoteNode/useScrollCapture.d.ts +9 -0
- package/dist/canvas/components/StickyNoteNode/useScrollCapture.d.ts.map +1 -0
- package/dist/canvas/components/StickyNoteNode/useScrollCapture.js +38 -0
- package/package.json +5 -4
|
@@ -34,7 +34,6 @@ const index_cjs_namespaceObject = require("../../layouts/index.cjs");
|
|
|
34
34
|
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
35
35
|
const external_material_index_cjs_namespaceObject = require("../../../material/index.cjs");
|
|
36
36
|
const external_react_namespaceObject = require("react");
|
|
37
|
-
const external_react_dom_namespaceObject = require("react-dom");
|
|
38
37
|
const external_icons_index_cjs_namespaceObject = require("../../icons/index.cjs");
|
|
39
38
|
const GroupModificationUtils_cjs_namespaceObject = require("../../utils/GroupModificationUtils.cjs");
|
|
40
39
|
const ConnectedHandlesContext_cjs_namespaceObject = require("../BaseCanvas/ConnectedHandlesContext.cjs");
|
|
@@ -50,6 +49,7 @@ const external_StageNode_styles_cjs_namespaceObject = require("./StageNode.style
|
|
|
50
49
|
const external_StageNode_types_cjs_namespaceObject = require("./StageNode.types.cjs");
|
|
51
50
|
const external_StageNode_utils_cjs_namespaceObject = require("./StageNode.utils.cjs");
|
|
52
51
|
const external_StageNodeTaskUtilities_cjs_namespaceObject = require("./StageNodeTaskUtilities.cjs");
|
|
52
|
+
const external_StageTaskDragOverlay_cjs_namespaceObject = require("./StageTaskDragOverlay.cjs");
|
|
53
53
|
const CHIP_ICONS = {
|
|
54
54
|
[external_StageNode_types_cjs_namespaceObject.StageHeaderChipType.Entry]: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_icons_index_cjs_namespaceObject.EntryConditionIcon, {
|
|
55
55
|
w: apollo_core_namespaceObject.Icon.IconXs,
|
|
@@ -72,7 +72,7 @@ const CHIP_ICONS = {
|
|
|
72
72
|
size: apollo_core_namespaceObject.Icon.IconXs
|
|
73
73
|
})
|
|
74
74
|
};
|
|
75
|
-
const
|
|
75
|
+
const StageNodeInner = (props)=>{
|
|
76
76
|
const { dragging, selected, id, width, execution, stageDetails, addTaskLabel = 'Add task', addTaskLoading = false, replaceTaskLabel = 'Replace task', taskOptions = [], menuItems, pendingReplaceTask, onStageClick, onTaskAdd, onAddTaskFromToolbox, onTaskToolboxSearch, onTaskClick, onTaskGroupModification, onStageTitleChange, onTaskReorder, onReplaceTaskFromToolbox, onTaskPlay, hideParallelOptions } = props;
|
|
77
77
|
const taskWidth = width ? width - external_StageNode_styles_cjs_namespaceObject.STAGE_CONTENT_INSET : void 0;
|
|
78
78
|
const allTasks = (0, external_react_namespaceObject.useMemo)(()=>stageDetails?.tasks || [], [
|
|
@@ -102,9 +102,6 @@ const StageNodeComponent = (props)=>{
|
|
|
102
102
|
const status = execution?.stageStatus?.status;
|
|
103
103
|
const statusLabel = execution?.stageStatus?.label;
|
|
104
104
|
const stageDuration = execution?.stageStatus?.duration;
|
|
105
|
-
const reGroupTaskFunction = (0, external_react_namespaceObject.useMemo)(()=>onTaskGroupModification || (()=>{}), [
|
|
106
|
-
onTaskGroupModification
|
|
107
|
-
]);
|
|
108
105
|
const isStageTitleEditable = !!onStageTitleChange && !isReadOnly;
|
|
109
106
|
const [isHovered, setIsHovered] = (0, external_react_namespaceObject.useState)(false);
|
|
110
107
|
const [label, setLabel] = (0, external_react_namespaceObject.useState)(props.stageDetails.label);
|
|
@@ -121,6 +118,7 @@ const StageNodeComponent = (props)=>{
|
|
|
121
118
|
taskIndex: -1
|
|
122
119
|
});
|
|
123
120
|
const isConnecting = (0, react_cjs_namespaceObject.useStore)((state)=>!!state.connectionClickStartHandle);
|
|
121
|
+
const storeApi = (0, react_cjs_namespaceObject.useStoreApi)();
|
|
124
122
|
const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(id);
|
|
125
123
|
const [isAddingTask, setIsAddingTask] = (0, external_react_namespaceObject.useState)(false);
|
|
126
124
|
const [isReplacingTask, setIsReplacingTask] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -160,7 +158,6 @@ const StageNodeComponent = (props)=>{
|
|
|
160
158
|
tasks,
|
|
161
159
|
activeDragId
|
|
162
160
|
]);
|
|
163
|
-
const { zoom } = (0, react_cjs_namespaceObject.useViewport)();
|
|
164
161
|
const projected = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
165
162
|
if (!activeDragId || !overId) return null;
|
|
166
163
|
return (0, external_StageNode_utils_cjs_namespaceObject.getProjection)(tasks, activeDragId, overId, offsetLeft);
|
|
@@ -243,18 +240,26 @@ const StageNodeComponent = (props)=>{
|
|
|
243
240
|
handleStageTitleClickToSave,
|
|
244
241
|
isStageTitleEditing
|
|
245
242
|
]);
|
|
246
|
-
const
|
|
243
|
+
const hasContextMenu = !!(onReplaceTaskFromToolbox || onTaskGroupModification);
|
|
244
|
+
const buildContextMenuItems = (0, external_react_namespaceObject.useCallback)((groupIndex, taskIndex)=>{
|
|
245
|
+
const taskGroup = tasks[groupIndex] ?? [];
|
|
246
|
+
const isParallel = taskGroup.length > 1;
|
|
247
247
|
const items = [];
|
|
248
248
|
if (onReplaceTaskFromToolbox) {
|
|
249
249
|
items.push((0, external_StageNodeTaskUtilities_cjs_namespaceObject.getMenuItem)('replace-task', 'Replace task', ()=>{
|
|
250
|
-
|
|
250
|
+
taskStateReference.current = {
|
|
251
|
+
isParallel,
|
|
252
|
+
groupIndex,
|
|
253
|
+
taskIndex
|
|
254
|
+
};
|
|
255
|
+
const taskId = taskGroup[taskIndex]?.id;
|
|
251
256
|
if (taskId) onTaskClick?.(taskId);
|
|
252
257
|
setIsReplacingTask(true);
|
|
253
258
|
}));
|
|
254
259
|
items.push((0, external_StageNodeTaskUtilities_cjs_namespaceObject.getDivider)());
|
|
255
260
|
}
|
|
256
261
|
if (onTaskGroupModification) {
|
|
257
|
-
const reGroupOptions = (0, external_StageNodeTaskUtilities_cjs_namespaceObject.getContextMenuItems)(isParallel, groupIndex,
|
|
262
|
+
const reGroupOptions = (0, external_StageNodeTaskUtilities_cjs_namespaceObject.getContextMenuItems)(isParallel, groupIndex, tasks.length, taskIndex, taskGroup.length, (tasks[groupIndex - 1]?.length ?? 0) > 1, (tasks[groupIndex + 1]?.length ?? 0) > 1, onTaskGroupModification, hideParallelOptions);
|
|
258
263
|
return [
|
|
259
264
|
...items,
|
|
260
265
|
...reGroupOptions
|
|
@@ -265,7 +270,6 @@ const StageNodeComponent = (props)=>{
|
|
|
265
270
|
onReplaceTaskFromToolbox,
|
|
266
271
|
onTaskClick,
|
|
267
272
|
onTaskGroupModification,
|
|
268
|
-
reGroupTaskFunction,
|
|
269
273
|
tasks,
|
|
270
274
|
hideParallelOptions
|
|
271
275
|
]);
|
|
@@ -282,16 +286,15 @@ const StageNodeComponent = (props)=>{
|
|
|
282
286
|
}));
|
|
283
287
|
if (onTaskGroupModification) {
|
|
284
288
|
if (items.length > 0) items.push((0, external_StageNodeTaskUtilities_cjs_namespaceObject.getDivider)());
|
|
285
|
-
items.push((0, external_StageNodeTaskUtilities_cjs_namespaceObject.getMenuItem)('remove-task', 'Delete task', ()=>
|
|
289
|
+
items.push((0, external_StageNodeTaskUtilities_cjs_namespaceObject.getMenuItem)('remove-task', 'Delete task', ()=>onTaskGroupModification(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.REMOVE_TASK, groupIndex, taskIndex)));
|
|
286
290
|
}
|
|
287
291
|
return items;
|
|
288
292
|
}, [
|
|
289
293
|
onReplaceTaskFromToolbox,
|
|
290
294
|
onTaskClick,
|
|
291
|
-
onTaskGroupModification
|
|
292
|
-
reGroupTaskFunction
|
|
295
|
+
onTaskGroupModification
|
|
293
296
|
]);
|
|
294
|
-
const { setSelectedNodeId } = (0, hooks_index_cjs_namespaceObject.
|
|
297
|
+
const { setSelectedNodeId } = (0, hooks_index_cjs_namespaceObject.useSetNodeSelection)();
|
|
295
298
|
const handleStageClick = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
296
299
|
onStageClick?.();
|
|
297
300
|
}, [
|
|
@@ -414,9 +417,9 @@ const StageNodeComponent = (props)=>{
|
|
|
414
417
|
setActiveDragId(event.active.id);
|
|
415
418
|
}, []);
|
|
416
419
|
const handleDragMove = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
417
|
-
setOffsetLeft(event.delta.x /
|
|
420
|
+
setOffsetLeft(event.delta.x / storeApi.getState().transform[2]);
|
|
418
421
|
}, [
|
|
419
|
-
|
|
422
|
+
storeApi
|
|
420
423
|
]);
|
|
421
424
|
const handleDragOver = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
422
425
|
setOverId(event.over?.id ?? null);
|
|
@@ -452,12 +455,6 @@ const StageNodeComponent = (props)=>{
|
|
|
452
455
|
} : void 0, [
|
|
453
456
|
taskWidth
|
|
454
457
|
]);
|
|
455
|
-
const dragOverlayStyle = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
456
|
-
transform: `scale(${zoom})`,
|
|
457
|
-
transformOrigin: 'top left'
|
|
458
|
-
}), [
|
|
459
|
-
zoom
|
|
460
|
-
]);
|
|
461
458
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
462
459
|
"data-testid": `stage-${id}`,
|
|
463
460
|
style: {
|
|
@@ -640,19 +637,13 @@ const StageNodeComponent = (props)=>{
|
|
|
640
637
|
taskExecution: taskExecution,
|
|
641
638
|
isSelected: selectedTaskId === task.id,
|
|
642
639
|
isParallel: isParallel,
|
|
643
|
-
|
|
640
|
+
groupIndex: groupIndex,
|
|
641
|
+
taskIndex: taskIndex,
|
|
644
642
|
onTaskClick: handleTaskClick,
|
|
645
643
|
projectedDepth: task.id === activeDragId && projected ? projected.depth : void 0,
|
|
646
644
|
isDragDisabled: !onTaskReorder,
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
onMenuOpen: ()=>{
|
|
650
|
-
taskStateReference.current = {
|
|
651
|
-
isParallel,
|
|
652
|
-
groupIndex,
|
|
653
|
-
taskIndex
|
|
654
|
-
};
|
|
655
|
-
}
|
|
645
|
+
...hasContextMenu && {
|
|
646
|
+
getContextMenuItems: buildContextMenuItems
|
|
656
647
|
}
|
|
657
648
|
}, task.id);
|
|
658
649
|
})
|
|
@@ -663,23 +654,11 @@ const StageNodeComponent = (props)=>{
|
|
|
663
654
|
})
|
|
664
655
|
})
|
|
665
656
|
}),
|
|
666
|
-
/*#__PURE__*/ (0,
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
isParallel: isActiveTaskParallel,
|
|
672
|
-
style: {
|
|
673
|
-
cursor: 'grabbing',
|
|
674
|
-
...taskWidthStyle
|
|
675
|
-
},
|
|
676
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DraggableTask_cjs_namespaceObject.TaskContent, {
|
|
677
|
-
task: activeTask,
|
|
678
|
-
isDragging: true
|
|
679
|
-
})
|
|
680
|
-
})
|
|
681
|
-
}) : null
|
|
682
|
-
}), document.body)
|
|
657
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StageTaskDragOverlay_cjs_namespaceObject.StageTaskDragOverlay, {
|
|
658
|
+
activeTask: activeTask,
|
|
659
|
+
isActiveTaskParallel: isActiveTaskParallel,
|
|
660
|
+
taskWidthStyle: taskWidthStyle
|
|
661
|
+
})
|
|
683
662
|
]
|
|
684
663
|
}),
|
|
685
664
|
adhocTasks.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_StageNode_styles_cjs_namespaceObject.StageAdhocSection, {
|
|
@@ -697,22 +676,14 @@ const StageNodeComponent = (props)=>{
|
|
|
697
676
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StageNode_styles_cjs_namespaceObject.StageTaskList, {
|
|
698
677
|
children: adhocTasks.map(({ task, groupIndex, taskIndex })=>{
|
|
699
678
|
const taskExecution = execution?.taskStatus?.[task.id];
|
|
700
|
-
const menuItems = getAdhocContextMenuItems(groupIndex, taskIndex, task.id);
|
|
701
679
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_AdhocTask_cjs_namespaceObject.AdhocTaskItem, {
|
|
702
680
|
task: task,
|
|
703
681
|
taskExecution: taskExecution,
|
|
704
682
|
isSelected: selectedTaskId === task.id,
|
|
705
|
-
contextMenuItems: menuItems,
|
|
706
683
|
onTaskClick: handleTaskClick,
|
|
707
684
|
onTaskPlay: onTaskPlay,
|
|
708
685
|
...(onTaskGroupModification || onReplaceTaskFromToolbox) && {
|
|
709
|
-
|
|
710
|
-
taskStateReference.current = {
|
|
711
|
-
isParallel: false,
|
|
712
|
-
groupIndex,
|
|
713
|
-
taskIndex
|
|
714
|
-
};
|
|
715
|
-
}
|
|
686
|
+
getContextMenuItems: ()=>getAdhocContextMenuItems(groupIndex, taskIndex, task.id)
|
|
716
687
|
}
|
|
717
688
|
}, task.id);
|
|
718
689
|
})
|
|
@@ -757,7 +728,7 @@ const StageNodeComponent = (props)=>{
|
|
|
757
728
|
]
|
|
758
729
|
});
|
|
759
730
|
};
|
|
760
|
-
const StageNode = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(
|
|
731
|
+
const StageNode = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(StageNodeInner);
|
|
761
732
|
exports.StageNode = __webpack_exports__.StageNode;
|
|
762
733
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
763
734
|
"StageNode"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StageNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StageNode/StageNode.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StageNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StageNode/StageNode.tsx"],"names":[],"mappings":"AAyDA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAsvBxD,eAAO,MAAM,SAAS,8CAluBS,cAAc,6CAkuBA,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DndContext,
|
|
2
|
+
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
|
|
3
3
|
import { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
4
4
|
import { FontVariantToken, Icon, Padding, Spacing } from "@uipath/apollo-core";
|
|
5
5
|
import { Column, Row } from "../../layouts/index.js";
|
|
6
|
-
import { Position, useStore,
|
|
6
|
+
import { Position, useStore, useStoreApi } from "../../xyflow/react.js";
|
|
7
7
|
import { ApIcon, ApIconButton, ApLink, ApTooltip, ApTypography } from "../../../material/index.js";
|
|
8
8
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
9
|
-
import { createPortal } from "react-dom";
|
|
10
9
|
import { EntryConditionIcon, ExitConditionIcon, ReturnToOriginIcon } from "../../icons/index.js";
|
|
11
10
|
import { GroupModificationType } from "../../utils/GroupModificationUtils.js";
|
|
12
11
|
import { useConnectedHandles } from "../BaseCanvas/ConnectedHandlesContext.js";
|
|
@@ -14,14 +13,15 @@ import { useButtonHandles } from "../ButtonHandle/useButtonHandles.js";
|
|
|
14
13
|
import { ExecutionStatusIcon } from "../ExecutionStatusIcon/index.js";
|
|
15
14
|
import { FloatingCanvasPanel } from "../FloatingCanvasPanel/index.js";
|
|
16
15
|
import { NodeContextMenu } from "../NodeContextMenu/index.js";
|
|
17
|
-
import {
|
|
16
|
+
import { useSetNodeSelection } from "../NodePropertiesPanel/hooks/index.js";
|
|
18
17
|
import { Toolbox } from "../Toolbox/index.js";
|
|
19
18
|
import { AdhocTaskItem } from "./AdhocTask.js";
|
|
20
|
-
import { DraggableTask
|
|
21
|
-
import { INDENTATION_WIDTH, STAGE_CONTENT_INSET, StageAdhocHeaderSection, StageAdhocSection, StageChip, StageContainer, StageContent, StageHeader, StageHeaderChipsRow, StageParallelBracket, StageParallelLabel,
|
|
19
|
+
import { DraggableTask } from "./DraggableTask.js";
|
|
20
|
+
import { INDENTATION_WIDTH, STAGE_CONTENT_INSET, StageAdhocHeaderSection, StageAdhocSection, StageChip, StageContainer, StageContent, StageHeader, StageHeaderChipsRow, StageParallelBracket, StageParallelLabel, StageTaskGroup, StageTaskList, StageTitleContainer, StageTitleInput } from "./StageNode.styles.js";
|
|
22
21
|
import { StageHeaderChipType } from "./StageNode.types.js";
|
|
23
22
|
import { flattenTasks, getProjection, reorderTasks } from "./StageNode.utils.js";
|
|
24
23
|
import { getContextMenuItems, getDivider, getMenuItem } from "./StageNodeTaskUtilities.js";
|
|
24
|
+
import { StageTaskDragOverlay } from "./StageTaskDragOverlay.js";
|
|
25
25
|
const CHIP_ICONS = {
|
|
26
26
|
[StageHeaderChipType.Entry]: /*#__PURE__*/ jsx(EntryConditionIcon, {
|
|
27
27
|
w: Icon.IconXs,
|
|
@@ -44,7 +44,7 @@ const CHIP_ICONS = {
|
|
|
44
44
|
size: Icon.IconXs
|
|
45
45
|
})
|
|
46
46
|
};
|
|
47
|
-
const
|
|
47
|
+
const StageNodeInner = (props)=>{
|
|
48
48
|
const { dragging, selected, id, width, execution, stageDetails, addTaskLabel = 'Add task', addTaskLoading = false, replaceTaskLabel = 'Replace task', taskOptions = [], menuItems, pendingReplaceTask, onStageClick, onTaskAdd, onAddTaskFromToolbox, onTaskToolboxSearch, onTaskClick, onTaskGroupModification, onStageTitleChange, onTaskReorder, onReplaceTaskFromToolbox, onTaskPlay, hideParallelOptions } = props;
|
|
49
49
|
const taskWidth = width ? width - STAGE_CONTENT_INSET : void 0;
|
|
50
50
|
const allTasks = useMemo(()=>stageDetails?.tasks || [], [
|
|
@@ -74,9 +74,6 @@ const StageNodeComponent = (props)=>{
|
|
|
74
74
|
const status = execution?.stageStatus?.status;
|
|
75
75
|
const statusLabel = execution?.stageStatus?.label;
|
|
76
76
|
const stageDuration = execution?.stageStatus?.duration;
|
|
77
|
-
const reGroupTaskFunction = useMemo(()=>onTaskGroupModification || (()=>{}), [
|
|
78
|
-
onTaskGroupModification
|
|
79
|
-
]);
|
|
80
77
|
const isStageTitleEditable = !!onStageTitleChange && !isReadOnly;
|
|
81
78
|
const [isHovered, setIsHovered] = useState(false);
|
|
82
79
|
const [label, setLabel] = useState(props.stageDetails.label);
|
|
@@ -93,6 +90,7 @@ const StageNodeComponent = (props)=>{
|
|
|
93
90
|
taskIndex: -1
|
|
94
91
|
});
|
|
95
92
|
const isConnecting = useStore((state)=>!!state.connectionClickStartHandle);
|
|
93
|
+
const storeApi = useStoreApi();
|
|
96
94
|
const connectedHandleIds = useConnectedHandles(id);
|
|
97
95
|
const [isAddingTask, setIsAddingTask] = useState(false);
|
|
98
96
|
const [isReplacingTask, setIsReplacingTask] = useState(false);
|
|
@@ -132,7 +130,6 @@ const StageNodeComponent = (props)=>{
|
|
|
132
130
|
tasks,
|
|
133
131
|
activeDragId
|
|
134
132
|
]);
|
|
135
|
-
const { zoom } = useViewport();
|
|
136
133
|
const projected = useMemo(()=>{
|
|
137
134
|
if (!activeDragId || !overId) return null;
|
|
138
135
|
return getProjection(tasks, activeDragId, overId, offsetLeft);
|
|
@@ -215,18 +212,26 @@ const StageNodeComponent = (props)=>{
|
|
|
215
212
|
handleStageTitleClickToSave,
|
|
216
213
|
isStageTitleEditing
|
|
217
214
|
]);
|
|
218
|
-
const
|
|
215
|
+
const hasContextMenu = !!(onReplaceTaskFromToolbox || onTaskGroupModification);
|
|
216
|
+
const buildContextMenuItems = useCallback((groupIndex, taskIndex)=>{
|
|
217
|
+
const taskGroup = tasks[groupIndex] ?? [];
|
|
218
|
+
const isParallel = taskGroup.length > 1;
|
|
219
219
|
const items = [];
|
|
220
220
|
if (onReplaceTaskFromToolbox) {
|
|
221
221
|
items.push(getMenuItem('replace-task', 'Replace task', ()=>{
|
|
222
|
-
|
|
222
|
+
taskStateReference.current = {
|
|
223
|
+
isParallel,
|
|
224
|
+
groupIndex,
|
|
225
|
+
taskIndex
|
|
226
|
+
};
|
|
227
|
+
const taskId = taskGroup[taskIndex]?.id;
|
|
223
228
|
if (taskId) onTaskClick?.(taskId);
|
|
224
229
|
setIsReplacingTask(true);
|
|
225
230
|
}));
|
|
226
231
|
items.push(getDivider());
|
|
227
232
|
}
|
|
228
233
|
if (onTaskGroupModification) {
|
|
229
|
-
const reGroupOptions = getContextMenuItems(isParallel, groupIndex,
|
|
234
|
+
const reGroupOptions = getContextMenuItems(isParallel, groupIndex, tasks.length, taskIndex, taskGroup.length, (tasks[groupIndex - 1]?.length ?? 0) > 1, (tasks[groupIndex + 1]?.length ?? 0) > 1, onTaskGroupModification, hideParallelOptions);
|
|
230
235
|
return [
|
|
231
236
|
...items,
|
|
232
237
|
...reGroupOptions
|
|
@@ -237,7 +242,6 @@ const StageNodeComponent = (props)=>{
|
|
|
237
242
|
onReplaceTaskFromToolbox,
|
|
238
243
|
onTaskClick,
|
|
239
244
|
onTaskGroupModification,
|
|
240
|
-
reGroupTaskFunction,
|
|
241
245
|
tasks,
|
|
242
246
|
hideParallelOptions
|
|
243
247
|
]);
|
|
@@ -254,16 +258,15 @@ const StageNodeComponent = (props)=>{
|
|
|
254
258
|
}));
|
|
255
259
|
if (onTaskGroupModification) {
|
|
256
260
|
if (items.length > 0) items.push(getDivider());
|
|
257
|
-
items.push(getMenuItem('remove-task', 'Delete task', ()=>
|
|
261
|
+
items.push(getMenuItem('remove-task', 'Delete task', ()=>onTaskGroupModification(GroupModificationType.REMOVE_TASK, groupIndex, taskIndex)));
|
|
258
262
|
}
|
|
259
263
|
return items;
|
|
260
264
|
}, [
|
|
261
265
|
onReplaceTaskFromToolbox,
|
|
262
266
|
onTaskClick,
|
|
263
|
-
onTaskGroupModification
|
|
264
|
-
reGroupTaskFunction
|
|
267
|
+
onTaskGroupModification
|
|
265
268
|
]);
|
|
266
|
-
const { setSelectedNodeId } =
|
|
269
|
+
const { setSelectedNodeId } = useSetNodeSelection();
|
|
267
270
|
const handleStageClick = useCallback(()=>{
|
|
268
271
|
onStageClick?.();
|
|
269
272
|
}, [
|
|
@@ -386,9 +389,9 @@ const StageNodeComponent = (props)=>{
|
|
|
386
389
|
setActiveDragId(event.active.id);
|
|
387
390
|
}, []);
|
|
388
391
|
const handleDragMove = useCallback((event)=>{
|
|
389
|
-
setOffsetLeft(event.delta.x /
|
|
392
|
+
setOffsetLeft(event.delta.x / storeApi.getState().transform[2]);
|
|
390
393
|
}, [
|
|
391
|
-
|
|
394
|
+
storeApi
|
|
392
395
|
]);
|
|
393
396
|
const handleDragOver = useCallback((event)=>{
|
|
394
397
|
setOverId(event.over?.id ?? null);
|
|
@@ -424,12 +427,6 @@ const StageNodeComponent = (props)=>{
|
|
|
424
427
|
} : void 0, [
|
|
425
428
|
taskWidth
|
|
426
429
|
]);
|
|
427
|
-
const dragOverlayStyle = useMemo(()=>({
|
|
428
|
-
transform: `scale(${zoom})`,
|
|
429
|
-
transformOrigin: 'top left'
|
|
430
|
-
}), [
|
|
431
|
-
zoom
|
|
432
|
-
]);
|
|
433
430
|
return /*#__PURE__*/ jsxs("div", {
|
|
434
431
|
"data-testid": `stage-${id}`,
|
|
435
432
|
style: {
|
|
@@ -612,19 +609,13 @@ const StageNodeComponent = (props)=>{
|
|
|
612
609
|
taskExecution: taskExecution,
|
|
613
610
|
isSelected: selectedTaskId === task.id,
|
|
614
611
|
isParallel: isParallel,
|
|
615
|
-
|
|
612
|
+
groupIndex: groupIndex,
|
|
613
|
+
taskIndex: taskIndex,
|
|
616
614
|
onTaskClick: handleTaskClick,
|
|
617
615
|
projectedDepth: task.id === activeDragId && projected ? projected.depth : void 0,
|
|
618
616
|
isDragDisabled: !onTaskReorder,
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
onMenuOpen: ()=>{
|
|
622
|
-
taskStateReference.current = {
|
|
623
|
-
isParallel,
|
|
624
|
-
groupIndex,
|
|
625
|
-
taskIndex
|
|
626
|
-
};
|
|
627
|
-
}
|
|
617
|
+
...hasContextMenu && {
|
|
618
|
+
getContextMenuItems: buildContextMenuItems
|
|
628
619
|
}
|
|
629
620
|
}, task.id);
|
|
630
621
|
})
|
|
@@ -635,23 +626,11 @@ const StageNodeComponent = (props)=>{
|
|
|
635
626
|
})
|
|
636
627
|
})
|
|
637
628
|
}),
|
|
638
|
-
/*#__PURE__*/
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
isParallel: isActiveTaskParallel,
|
|
644
|
-
style: {
|
|
645
|
-
cursor: 'grabbing',
|
|
646
|
-
...taskWidthStyle
|
|
647
|
-
},
|
|
648
|
-
children: /*#__PURE__*/ jsx(TaskContent, {
|
|
649
|
-
task: activeTask,
|
|
650
|
-
isDragging: true
|
|
651
|
-
})
|
|
652
|
-
})
|
|
653
|
-
}) : null
|
|
654
|
-
}), document.body)
|
|
629
|
+
/*#__PURE__*/ jsx(StageTaskDragOverlay, {
|
|
630
|
+
activeTask: activeTask,
|
|
631
|
+
isActiveTaskParallel: isActiveTaskParallel,
|
|
632
|
+
taskWidthStyle: taskWidthStyle
|
|
633
|
+
})
|
|
655
634
|
]
|
|
656
635
|
}),
|
|
657
636
|
adhocTasks.length > 0 && /*#__PURE__*/ jsxs(StageAdhocSection, {
|
|
@@ -669,22 +648,14 @@ const StageNodeComponent = (props)=>{
|
|
|
669
648
|
/*#__PURE__*/ jsx(StageTaskList, {
|
|
670
649
|
children: adhocTasks.map(({ task, groupIndex, taskIndex })=>{
|
|
671
650
|
const taskExecution = execution?.taskStatus?.[task.id];
|
|
672
|
-
const menuItems = getAdhocContextMenuItems(groupIndex, taskIndex, task.id);
|
|
673
651
|
return /*#__PURE__*/ jsx(AdhocTaskItem, {
|
|
674
652
|
task: task,
|
|
675
653
|
taskExecution: taskExecution,
|
|
676
654
|
isSelected: selectedTaskId === task.id,
|
|
677
|
-
contextMenuItems: menuItems,
|
|
678
655
|
onTaskClick: handleTaskClick,
|
|
679
656
|
onTaskPlay: onTaskPlay,
|
|
680
657
|
...(onTaskGroupModification || onReplaceTaskFromToolbox) && {
|
|
681
|
-
|
|
682
|
-
taskStateReference.current = {
|
|
683
|
-
isParallel: false,
|
|
684
|
-
groupIndex,
|
|
685
|
-
taskIndex
|
|
686
|
-
};
|
|
687
|
-
}
|
|
658
|
+
getContextMenuItems: ()=>getAdhocContextMenuItems(groupIndex, taskIndex, task.id)
|
|
688
659
|
}
|
|
689
660
|
}, task.id);
|
|
690
661
|
})
|
|
@@ -729,5 +700,5 @@ const StageNodeComponent = (props)=>{
|
|
|
729
700
|
]
|
|
730
701
|
});
|
|
731
702
|
};
|
|
732
|
-
const StageNode = /*#__PURE__*/ memo(
|
|
703
|
+
const StageNode = /*#__PURE__*/ memo(StageNodeInner);
|
|
733
704
|
export { StageNode };
|