@uipath/apollo-react 3.64.0-pr431.cb6b0b8 → 3.65.0
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/NodePropertiesPanel/hooks/index.cjs +1 -4
- 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 +6 -27
- package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.d.ts +0 -3
- package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.d.ts.map +1 -1
- package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.js +5 -23
- package/dist/canvas/components/StageNode/DraggableTask.cjs +5 -14
- 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 +5 -14
- 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 +11 -34
- package/dist/canvas/components/StageNode/StageEdge.d.ts +1 -2
- package/dist/canvas/components/StageNode/StageEdge.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageEdge.js +12 -35
- package/dist/canvas/components/StageNode/StageNode.cjs +51 -54
- package/dist/canvas/components/StageNode/StageNode.d.ts +1 -1
- package/dist/canvas/components/StageNode/StageNode.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.js +56 -59
- package/dist/canvas/components/StageNode/StageNode.stories.cjs +157 -116
- package/dist/canvas/components/StageNode/StageNode.stories.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.stories.js +153 -112
- package/dist/canvas/components/StageNode/StageNode.types.d.ts +2 -9
- package/dist/canvas/components/StageNode/StageNode.types.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeTaskUtilities.cjs +3 -2
- package/dist/canvas/components/StageNode/StageNodeTaskUtilities.d.ts +1 -1
- package/dist/canvas/components/StageNode/StageNodeTaskUtilities.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeTaskUtilities.js +3 -2
- package/dist/canvas/components/StageNode/TaskMenu.cjs +17 -13
- package/dist/canvas/components/StageNode/TaskMenu.d.ts +2 -1
- package/dist/canvas/components/StageNode/TaskMenu.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/TaskMenu.js +18 -14
- package/package.json +1 -1
- package/dist/canvas/components/CanvasPerformance.stories.cjs +0 -361
- package/dist/canvas/components/CanvasPerformance.stories.d.ts +0 -6
- package/dist/canvas/components/CanvasPerformance.stories.d.ts.map +0 -1
- package/dist/canvas/components/CanvasPerformance.stories.js +0 -324
- package/dist/canvas/components/StageNode/StageNode.stories.utils.cjs +0 -42
- package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts +0 -3
- package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts.map +0 -1
- package/dist/canvas/components/StageNode/StageNode.stories.utils.js +0 -8
- package/dist/canvas/components/StageNode/StageTaskDragOverlay.cjs +0 -68
- package/dist/canvas/components/StageNode/StageTaskDragOverlay.d.ts +0 -3
- package/dist/canvas/components/StageNode/StageTaskDragOverlay.d.ts.map +0 -1
- package/dist/canvas/components/StageNode/StageTaskDragOverlay.js +0 -34
|
@@ -34,7 +34,7 @@ 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
|
|
37
|
+
const external_react_dom_namespaceObject = require("react-dom");
|
|
38
38
|
const ConnectedHandlesContext_cjs_namespaceObject = require("../BaseCanvas/ConnectedHandlesContext.cjs");
|
|
39
39
|
const useButtonHandles_cjs_namespaceObject = require("../ButtonHandle/useButtonHandles.cjs");
|
|
40
40
|
const external_ExecutionStatusIcon_index_cjs_namespaceObject = require("../ExecutionStatusIcon/index.cjs");
|
|
@@ -42,12 +42,12 @@ const external_FloatingCanvasPanel_index_cjs_namespaceObject = require("../Float
|
|
|
42
42
|
const external_NodeContextMenu_index_cjs_namespaceObject = require("../NodeContextMenu/index.cjs");
|
|
43
43
|
const hooks_index_cjs_namespaceObject = require("../NodePropertiesPanel/hooks/index.cjs");
|
|
44
44
|
const external_Toolbox_index_cjs_namespaceObject = require("../Toolbox/index.cjs");
|
|
45
|
+
const external_icons_index_cjs_namespaceObject = require("../../icons/index.cjs");
|
|
45
46
|
const external_DraggableTask_cjs_namespaceObject = require("./DraggableTask.cjs");
|
|
46
47
|
const external_StageNode_styles_cjs_namespaceObject = require("./StageNode.styles.cjs");
|
|
47
48
|
const external_StageNode_types_cjs_namespaceObject = require("./StageNode.types.cjs");
|
|
48
49
|
const external_StageNode_utils_cjs_namespaceObject = require("./StageNode.utils.cjs");
|
|
49
50
|
const external_StageNodeTaskUtilities_cjs_namespaceObject = require("./StageNodeTaskUtilities.cjs");
|
|
50
|
-
const external_StageTaskDragOverlay_cjs_namespaceObject = require("./StageTaskDragOverlay.cjs");
|
|
51
51
|
const CHIP_ICONS = {
|
|
52
52
|
[external_StageNode_types_cjs_namespaceObject.StageHeaderChipType.Entry]: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_icons_index_cjs_namespaceObject.EntryConditionIcon, {
|
|
53
53
|
w: apollo_core_namespaceObject.Icon.IconXs,
|
|
@@ -70,8 +70,8 @@ const CHIP_ICONS = {
|
|
|
70
70
|
size: apollo_core_namespaceObject.Icon.IconXs
|
|
71
71
|
})
|
|
72
72
|
};
|
|
73
|
-
const
|
|
74
|
-
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 } = props;
|
|
73
|
+
const StageNodeComponent = (props)=>{
|
|
74
|
+
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;
|
|
75
75
|
const taskWidth = width ? width - external_StageNode_styles_cjs_namespaceObject.STAGE_CONTENT_INSET : void 0;
|
|
76
76
|
const tasks = (0, external_react_namespaceObject.useMemo)(()=>stageDetails?.tasks || [], [
|
|
77
77
|
stageDetails?.tasks
|
|
@@ -90,6 +90,9 @@ const StageNodeInner = (props)=>{
|
|
|
90
90
|
const status = execution?.stageStatus?.status;
|
|
91
91
|
const statusLabel = execution?.stageStatus?.label;
|
|
92
92
|
const stageDuration = execution?.stageStatus?.duration;
|
|
93
|
+
const reGroupTaskFunction = (0, external_react_namespaceObject.useMemo)(()=>onTaskGroupModification || (()=>{}), [
|
|
94
|
+
onTaskGroupModification
|
|
95
|
+
]);
|
|
93
96
|
const isStageTitleEditable = !!onStageTitleChange && !isReadOnly;
|
|
94
97
|
const [isHovered, setIsHovered] = (0, external_react_namespaceObject.useState)(false);
|
|
95
98
|
const [label, setLabel] = (0, external_react_namespaceObject.useState)(props.stageDetails.label);
|
|
@@ -106,7 +109,6 @@ const StageNodeInner = (props)=>{
|
|
|
106
109
|
taskIndex: -1
|
|
107
110
|
});
|
|
108
111
|
const isConnecting = (0, react_cjs_namespaceObject.useStore)((state)=>!!state.connectionClickStartHandle);
|
|
109
|
-
const storeApi = (0, react_cjs_namespaceObject.useStoreApi)();
|
|
110
112
|
const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(id);
|
|
111
113
|
const [isAddingTask, setIsAddingTask] = (0, external_react_namespaceObject.useState)(false);
|
|
112
114
|
const [isReplacingTask, setIsReplacingTask] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -146,6 +148,7 @@ const StageNodeInner = (props)=>{
|
|
|
146
148
|
tasks,
|
|
147
149
|
activeDragId
|
|
148
150
|
]);
|
|
151
|
+
const { zoom } = (0, react_cjs_namespaceObject.useViewport)();
|
|
149
152
|
const projected = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
150
153
|
if (!activeDragId || !overId) return null;
|
|
151
154
|
return (0, external_StageNode_utils_cjs_namespaceObject.getProjection)(tasks, activeDragId, overId, offsetLeft);
|
|
@@ -228,26 +231,18 @@ const StageNodeInner = (props)=>{
|
|
|
228
231
|
handleStageTitleClickToSave,
|
|
229
232
|
isStageTitleEditing
|
|
230
233
|
]);
|
|
231
|
-
const
|
|
232
|
-
const buildContextMenuItems = (0, external_react_namespaceObject.useCallback)((groupIndex, taskIndex)=>{
|
|
233
|
-
const taskGroup = tasks[groupIndex] ?? [];
|
|
234
|
-
const isParallel = taskGroup.length > 1;
|
|
234
|
+
const contextMenuItems = (0, external_react_namespaceObject.useCallback)((isParallel, groupIndex, taskIndex, tasksLength, taskGroupLength, isAboveParallel, isBelowParallel)=>{
|
|
235
235
|
const items = [];
|
|
236
236
|
if (onReplaceTaskFromToolbox) {
|
|
237
237
|
items.push((0, external_StageNodeTaskUtilities_cjs_namespaceObject.getMenuItem)('replace-task', 'Replace task', ()=>{
|
|
238
|
-
|
|
239
|
-
isParallel,
|
|
240
|
-
groupIndex,
|
|
241
|
-
taskIndex
|
|
242
|
-
};
|
|
243
|
-
const taskId = taskGroup[taskIndex]?.id;
|
|
238
|
+
const taskId = tasks[groupIndex]?.[taskIndex]?.id;
|
|
244
239
|
if (taskId) onTaskClick?.(taskId);
|
|
245
240
|
setIsReplacingTask(true);
|
|
246
241
|
}));
|
|
247
242
|
items.push((0, external_StageNodeTaskUtilities_cjs_namespaceObject.getDivider)());
|
|
248
243
|
}
|
|
249
244
|
if (onTaskGroupModification) {
|
|
250
|
-
const reGroupOptions = (0, external_StageNodeTaskUtilities_cjs_namespaceObject.getContextMenuItems)(isParallel, groupIndex,
|
|
245
|
+
const reGroupOptions = (0, external_StageNodeTaskUtilities_cjs_namespaceObject.getContextMenuItems)(isParallel, groupIndex, tasksLength, taskIndex, taskGroupLength, isAboveParallel, isBelowParallel, reGroupTaskFunction, hideParallelOptions);
|
|
251
246
|
return [
|
|
252
247
|
...items,
|
|
253
248
|
...reGroupOptions
|
|
@@ -258,9 +253,11 @@ const StageNodeInner = (props)=>{
|
|
|
258
253
|
onReplaceTaskFromToolbox,
|
|
259
254
|
onTaskClick,
|
|
260
255
|
onTaskGroupModification,
|
|
261
|
-
|
|
256
|
+
reGroupTaskFunction,
|
|
257
|
+
tasks,
|
|
258
|
+
hideParallelOptions
|
|
262
259
|
]);
|
|
263
|
-
const { setSelectedNodeId } = (0, hooks_index_cjs_namespaceObject.
|
|
260
|
+
const { setSelectedNodeId } = (0, hooks_index_cjs_namespaceObject.useNodeSelection)();
|
|
264
261
|
const handleStageClick = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
265
262
|
onStageClick?.();
|
|
266
263
|
}, [
|
|
@@ -383,9 +380,9 @@ const StageNodeInner = (props)=>{
|
|
|
383
380
|
setActiveDragId(event.active.id);
|
|
384
381
|
}, []);
|
|
385
382
|
const handleDragMove = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
386
|
-
setOffsetLeft(event.delta.x /
|
|
383
|
+
setOffsetLeft(event.delta.x / zoom);
|
|
387
384
|
}, [
|
|
388
|
-
|
|
385
|
+
zoom
|
|
389
386
|
]);
|
|
390
387
|
const handleDragOver = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
391
388
|
setOverId(event.over?.id ?? null);
|
|
@@ -421,6 +418,12 @@ const StageNodeInner = (props)=>{
|
|
|
421
418
|
} : void 0, [
|
|
422
419
|
taskWidth
|
|
423
420
|
]);
|
|
421
|
+
const dragOverlayStyle = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
422
|
+
transform: `scale(${zoom})`,
|
|
423
|
+
transformOrigin: 'top left'
|
|
424
|
+
}), [
|
|
425
|
+
zoom
|
|
426
|
+
]);
|
|
424
427
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
425
428
|
"data-testid": `stage-${id}`,
|
|
426
429
|
style: {
|
|
@@ -585,14 +588,20 @@ const StageNodeInner = (props)=>{
|
|
|
585
588
|
taskExecution: taskExecution,
|
|
586
589
|
isSelected: selectedTaskId === task.id,
|
|
587
590
|
isParallel: isParallel,
|
|
588
|
-
|
|
589
|
-
taskIndex: taskIndex,
|
|
591
|
+
contextMenuItems: contextMenuItems(isParallel, groupIndex, taskIndex, tasks.length, taskGroup.length, (tasks[groupIndex - 1]?.length ?? 0) > 1, (tasks[groupIndex + 1]?.length ?? 0) > 1),
|
|
590
592
|
onTaskClick: handleTaskClick,
|
|
591
593
|
projectedDepth: task.id === activeDragId && projected ? projected.depth : void 0,
|
|
592
594
|
onTaskPlay: onTaskPlay,
|
|
593
595
|
isDragDisabled: !onTaskReorder,
|
|
594
|
-
|
|
595
|
-
|
|
596
|
+
zoom: zoom,
|
|
597
|
+
...(onTaskGroupModification || onReplaceTaskFromToolbox) && {
|
|
598
|
+
onMenuOpen: ()=>{
|
|
599
|
+
taskStateReference.current = {
|
|
600
|
+
isParallel,
|
|
601
|
+
groupIndex,
|
|
602
|
+
taskIndex
|
|
603
|
+
};
|
|
604
|
+
}
|
|
596
605
|
}
|
|
597
606
|
}, task.id);
|
|
598
607
|
})
|
|
@@ -603,11 +612,23 @@ const StageNodeInner = (props)=>{
|
|
|
603
612
|
})
|
|
604
613
|
})
|
|
605
614
|
}),
|
|
606
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
615
|
+
/*#__PURE__*/ (0, external_react_dom_namespaceObject.createPortal)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(core_namespaceObject.DragOverlay, {
|
|
616
|
+
children: activeTask ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
617
|
+
style: dragOverlayStyle,
|
|
618
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StageNode_styles_cjs_namespaceObject.StageTask, {
|
|
619
|
+
selected: true,
|
|
620
|
+
isParallel: isActiveTaskParallel,
|
|
621
|
+
style: {
|
|
622
|
+
cursor: 'grabbing',
|
|
623
|
+
...taskWidthStyle
|
|
624
|
+
},
|
|
625
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DraggableTask_cjs_namespaceObject.TaskContent, {
|
|
626
|
+
task: activeTask,
|
|
627
|
+
isDragging: true
|
|
628
|
+
})
|
|
629
|
+
})
|
|
630
|
+
}) : null
|
|
631
|
+
}), document.body)
|
|
611
632
|
]
|
|
612
633
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.Column, {
|
|
613
634
|
py: 2,
|
|
@@ -661,31 +682,7 @@ const StageNodeInner = (props)=>{
|
|
|
661
682
|
]
|
|
662
683
|
});
|
|
663
684
|
};
|
|
664
|
-
const
|
|
665
|
-
const StageNode = ({ dragging, selected, id, width, execution, stageDetails, addTaskLabel, addTaskLoading, replaceTaskLabel, taskOptions, menuItems, pendingReplaceTask, onStageClick, onTaskAdd, onAddTaskFromToolbox, onTaskToolboxSearch, onTaskClick, onTaskGroupModification, onStageTitleChange, onTaskReorder, onReplaceTaskFromToolbox, onTaskPlay })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(StageNodeInnerMemo, {
|
|
666
|
-
dragging: dragging,
|
|
667
|
-
selected: selected,
|
|
668
|
-
id: id,
|
|
669
|
-
width: width,
|
|
670
|
-
execution: execution,
|
|
671
|
-
stageDetails: stageDetails,
|
|
672
|
-
addTaskLabel: addTaskLabel,
|
|
673
|
-
addTaskLoading: addTaskLoading,
|
|
674
|
-
replaceTaskLabel: replaceTaskLabel,
|
|
675
|
-
taskOptions: taskOptions,
|
|
676
|
-
menuItems: menuItems,
|
|
677
|
-
pendingReplaceTask: pendingReplaceTask,
|
|
678
|
-
onStageClick: onStageClick,
|
|
679
|
-
onTaskAdd: onTaskAdd,
|
|
680
|
-
onAddTaskFromToolbox: onAddTaskFromToolbox,
|
|
681
|
-
onTaskToolboxSearch: onTaskToolboxSearch,
|
|
682
|
-
onTaskClick: onTaskClick,
|
|
683
|
-
onTaskGroupModification: onTaskGroupModification,
|
|
684
|
-
onStageTitleChange: onStageTitleChange,
|
|
685
|
-
onTaskReorder: onTaskReorder,
|
|
686
|
-
onReplaceTaskFromToolbox: onReplaceTaskFromToolbox,
|
|
687
|
-
onTaskPlay: onTaskPlay
|
|
688
|
-
});
|
|
685
|
+
const StageNode = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(StageNodeComponent);
|
|
689
686
|
exports.StageNode = __webpack_exports__.StageNode;
|
|
690
687
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
691
688
|
"StageNode"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { StageNodeProps } from './StageNode.types';
|
|
2
|
-
export declare const StageNode: (
|
|
2
|
+
export declare const StageNode: import("react").MemoExoticComponent<(props: StageNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
3
3
|
//# sourceMappingURL=StageNode.d.ts.map
|
|
@@ -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;AA4sBxD,eAAO,MAAM,SAAS,8CA1rBa,cAAc,6CA0rBA,CAAC"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
|
|
2
|
+
import { DndContext, DragOverlay, 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, useViewport } 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 {
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
10
|
import { useConnectedHandles } from "../BaseCanvas/ConnectedHandlesContext.js";
|
|
11
11
|
import { useButtonHandles } from "../ButtonHandle/useButtonHandles.js";
|
|
12
12
|
import { ExecutionStatusIcon } from "../ExecutionStatusIcon/index.js";
|
|
13
13
|
import { FloatingCanvasPanel } from "../FloatingCanvasPanel/index.js";
|
|
14
14
|
import { NodeContextMenu } from "../NodeContextMenu/index.js";
|
|
15
|
-
import {
|
|
15
|
+
import { useNodeSelection } from "../NodePropertiesPanel/hooks/index.js";
|
|
16
16
|
import { Toolbox } from "../Toolbox/index.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { EntryConditionIcon, ExitConditionIcon, ReturnToOriginIcon } from "../../icons/index.js";
|
|
18
|
+
import { DraggableTask, TaskContent } from "./DraggableTask.js";
|
|
19
|
+
import { INDENTATION_WIDTH, STAGE_CONTENT_INSET, StageChip, StageContainer, StageContent, StageHeader, StageHeaderChipsRow, StageParallelBracket, StageParallelLabel, StageTask, StageTaskGroup, StageTaskList, StageTitleContainer, StageTitleInput } from "./StageNode.styles.js";
|
|
19
20
|
import { StageHeaderChipType } from "./StageNode.types.js";
|
|
20
21
|
import { flattenTasks, getProjection, reorderTasks } from "./StageNode.utils.js";
|
|
21
22
|
import { getContextMenuItems, getDivider, getMenuItem } from "./StageNodeTaskUtilities.js";
|
|
22
|
-
import { StageTaskDragOverlay } from "./StageTaskDragOverlay.js";
|
|
23
23
|
const CHIP_ICONS = {
|
|
24
24
|
[StageHeaderChipType.Entry]: /*#__PURE__*/ jsx(EntryConditionIcon, {
|
|
25
25
|
w: Icon.IconXs,
|
|
@@ -42,8 +42,8 @@ const CHIP_ICONS = {
|
|
|
42
42
|
size: Icon.IconXs
|
|
43
43
|
})
|
|
44
44
|
};
|
|
45
|
-
const
|
|
46
|
-
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 } = props;
|
|
45
|
+
const StageNodeComponent = (props)=>{
|
|
46
|
+
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;
|
|
47
47
|
const taskWidth = width ? width - STAGE_CONTENT_INSET : void 0;
|
|
48
48
|
const tasks = useMemo(()=>stageDetails?.tasks || [], [
|
|
49
49
|
stageDetails?.tasks
|
|
@@ -62,6 +62,9 @@ const StageNodeInner = (props)=>{
|
|
|
62
62
|
const status = execution?.stageStatus?.status;
|
|
63
63
|
const statusLabel = execution?.stageStatus?.label;
|
|
64
64
|
const stageDuration = execution?.stageStatus?.duration;
|
|
65
|
+
const reGroupTaskFunction = useMemo(()=>onTaskGroupModification || (()=>{}), [
|
|
66
|
+
onTaskGroupModification
|
|
67
|
+
]);
|
|
65
68
|
const isStageTitleEditable = !!onStageTitleChange && !isReadOnly;
|
|
66
69
|
const [isHovered, setIsHovered] = useState(false);
|
|
67
70
|
const [label, setLabel] = useState(props.stageDetails.label);
|
|
@@ -78,7 +81,6 @@ const StageNodeInner = (props)=>{
|
|
|
78
81
|
taskIndex: -1
|
|
79
82
|
});
|
|
80
83
|
const isConnecting = useStore((state)=>!!state.connectionClickStartHandle);
|
|
81
|
-
const storeApi = useStoreApi();
|
|
82
84
|
const connectedHandleIds = useConnectedHandles(id);
|
|
83
85
|
const [isAddingTask, setIsAddingTask] = useState(false);
|
|
84
86
|
const [isReplacingTask, setIsReplacingTask] = useState(false);
|
|
@@ -118,6 +120,7 @@ const StageNodeInner = (props)=>{
|
|
|
118
120
|
tasks,
|
|
119
121
|
activeDragId
|
|
120
122
|
]);
|
|
123
|
+
const { zoom } = useViewport();
|
|
121
124
|
const projected = useMemo(()=>{
|
|
122
125
|
if (!activeDragId || !overId) return null;
|
|
123
126
|
return getProjection(tasks, activeDragId, overId, offsetLeft);
|
|
@@ -200,26 +203,18 @@ const StageNodeInner = (props)=>{
|
|
|
200
203
|
handleStageTitleClickToSave,
|
|
201
204
|
isStageTitleEditing
|
|
202
205
|
]);
|
|
203
|
-
const
|
|
204
|
-
const buildContextMenuItems = useCallback((groupIndex, taskIndex)=>{
|
|
205
|
-
const taskGroup = tasks[groupIndex] ?? [];
|
|
206
|
-
const isParallel = taskGroup.length > 1;
|
|
206
|
+
const contextMenuItems = useCallback((isParallel, groupIndex, taskIndex, tasksLength, taskGroupLength, isAboveParallel, isBelowParallel)=>{
|
|
207
207
|
const items = [];
|
|
208
208
|
if (onReplaceTaskFromToolbox) {
|
|
209
209
|
items.push(getMenuItem('replace-task', 'Replace task', ()=>{
|
|
210
|
-
|
|
211
|
-
isParallel,
|
|
212
|
-
groupIndex,
|
|
213
|
-
taskIndex
|
|
214
|
-
};
|
|
215
|
-
const taskId = taskGroup[taskIndex]?.id;
|
|
210
|
+
const taskId = tasks[groupIndex]?.[taskIndex]?.id;
|
|
216
211
|
if (taskId) onTaskClick?.(taskId);
|
|
217
212
|
setIsReplacingTask(true);
|
|
218
213
|
}));
|
|
219
214
|
items.push(getDivider());
|
|
220
215
|
}
|
|
221
216
|
if (onTaskGroupModification) {
|
|
222
|
-
const reGroupOptions = getContextMenuItems(isParallel, groupIndex,
|
|
217
|
+
const reGroupOptions = getContextMenuItems(isParallel, groupIndex, tasksLength, taskIndex, taskGroupLength, isAboveParallel, isBelowParallel, reGroupTaskFunction, hideParallelOptions);
|
|
223
218
|
return [
|
|
224
219
|
...items,
|
|
225
220
|
...reGroupOptions
|
|
@@ -230,9 +225,11 @@ const StageNodeInner = (props)=>{
|
|
|
230
225
|
onReplaceTaskFromToolbox,
|
|
231
226
|
onTaskClick,
|
|
232
227
|
onTaskGroupModification,
|
|
233
|
-
|
|
228
|
+
reGroupTaskFunction,
|
|
229
|
+
tasks,
|
|
230
|
+
hideParallelOptions
|
|
234
231
|
]);
|
|
235
|
-
const { setSelectedNodeId } =
|
|
232
|
+
const { setSelectedNodeId } = useNodeSelection();
|
|
236
233
|
const handleStageClick = useCallback(()=>{
|
|
237
234
|
onStageClick?.();
|
|
238
235
|
}, [
|
|
@@ -355,9 +352,9 @@ const StageNodeInner = (props)=>{
|
|
|
355
352
|
setActiveDragId(event.active.id);
|
|
356
353
|
}, []);
|
|
357
354
|
const handleDragMove = useCallback((event)=>{
|
|
358
|
-
setOffsetLeft(event.delta.x /
|
|
355
|
+
setOffsetLeft(event.delta.x / zoom);
|
|
359
356
|
}, [
|
|
360
|
-
|
|
357
|
+
zoom
|
|
361
358
|
]);
|
|
362
359
|
const handleDragOver = useCallback((event)=>{
|
|
363
360
|
setOverId(event.over?.id ?? null);
|
|
@@ -393,6 +390,12 @@ const StageNodeInner = (props)=>{
|
|
|
393
390
|
} : void 0, [
|
|
394
391
|
taskWidth
|
|
395
392
|
]);
|
|
393
|
+
const dragOverlayStyle = useMemo(()=>({
|
|
394
|
+
transform: `scale(${zoom})`,
|
|
395
|
+
transformOrigin: 'top left'
|
|
396
|
+
}), [
|
|
397
|
+
zoom
|
|
398
|
+
]);
|
|
396
399
|
return /*#__PURE__*/ jsxs("div", {
|
|
397
400
|
"data-testid": `stage-${id}`,
|
|
398
401
|
style: {
|
|
@@ -557,14 +560,20 @@ const StageNodeInner = (props)=>{
|
|
|
557
560
|
taskExecution: taskExecution,
|
|
558
561
|
isSelected: selectedTaskId === task.id,
|
|
559
562
|
isParallel: isParallel,
|
|
560
|
-
|
|
561
|
-
taskIndex: taskIndex,
|
|
563
|
+
contextMenuItems: contextMenuItems(isParallel, groupIndex, taskIndex, tasks.length, taskGroup.length, (tasks[groupIndex - 1]?.length ?? 0) > 1, (tasks[groupIndex + 1]?.length ?? 0) > 1),
|
|
562
564
|
onTaskClick: handleTaskClick,
|
|
563
565
|
projectedDepth: task.id === activeDragId && projected ? projected.depth : void 0,
|
|
564
566
|
onTaskPlay: onTaskPlay,
|
|
565
567
|
isDragDisabled: !onTaskReorder,
|
|
566
|
-
|
|
567
|
-
|
|
568
|
+
zoom: zoom,
|
|
569
|
+
...(onTaskGroupModification || onReplaceTaskFromToolbox) && {
|
|
570
|
+
onMenuOpen: ()=>{
|
|
571
|
+
taskStateReference.current = {
|
|
572
|
+
isParallel,
|
|
573
|
+
groupIndex,
|
|
574
|
+
taskIndex
|
|
575
|
+
};
|
|
576
|
+
}
|
|
568
577
|
}
|
|
569
578
|
}, task.id);
|
|
570
579
|
})
|
|
@@ -575,11 +584,23 @@ const StageNodeInner = (props)=>{
|
|
|
575
584
|
})
|
|
576
585
|
})
|
|
577
586
|
}),
|
|
578
|
-
/*#__PURE__*/ jsx(
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
587
|
+
/*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(DragOverlay, {
|
|
588
|
+
children: activeTask ? /*#__PURE__*/ jsx("div", {
|
|
589
|
+
style: dragOverlayStyle,
|
|
590
|
+
children: /*#__PURE__*/ jsx(StageTask, {
|
|
591
|
+
selected: true,
|
|
592
|
+
isParallel: isActiveTaskParallel,
|
|
593
|
+
style: {
|
|
594
|
+
cursor: 'grabbing',
|
|
595
|
+
...taskWidthStyle
|
|
596
|
+
},
|
|
597
|
+
children: /*#__PURE__*/ jsx(TaskContent, {
|
|
598
|
+
task: activeTask,
|
|
599
|
+
isDragging: true
|
|
600
|
+
})
|
|
601
|
+
})
|
|
602
|
+
}) : null
|
|
603
|
+
}), document.body)
|
|
583
604
|
]
|
|
584
605
|
}) : /*#__PURE__*/ jsx(Column, {
|
|
585
606
|
py: 2,
|
|
@@ -633,29 +654,5 @@ const StageNodeInner = (props)=>{
|
|
|
633
654
|
]
|
|
634
655
|
});
|
|
635
656
|
};
|
|
636
|
-
const
|
|
637
|
-
const StageNode = ({ dragging, selected, id, width, execution, stageDetails, addTaskLabel, addTaskLoading, replaceTaskLabel, taskOptions, menuItems, pendingReplaceTask, onStageClick, onTaskAdd, onAddTaskFromToolbox, onTaskToolboxSearch, onTaskClick, onTaskGroupModification, onStageTitleChange, onTaskReorder, onReplaceTaskFromToolbox, onTaskPlay })=>/*#__PURE__*/ jsx(StageNodeInnerMemo, {
|
|
638
|
-
dragging: dragging,
|
|
639
|
-
selected: selected,
|
|
640
|
-
id: id,
|
|
641
|
-
width: width,
|
|
642
|
-
execution: execution,
|
|
643
|
-
stageDetails: stageDetails,
|
|
644
|
-
addTaskLabel: addTaskLabel,
|
|
645
|
-
addTaskLoading: addTaskLoading,
|
|
646
|
-
replaceTaskLabel: replaceTaskLabel,
|
|
647
|
-
taskOptions: taskOptions,
|
|
648
|
-
menuItems: menuItems,
|
|
649
|
-
pendingReplaceTask: pendingReplaceTask,
|
|
650
|
-
onStageClick: onStageClick,
|
|
651
|
-
onTaskAdd: onTaskAdd,
|
|
652
|
-
onAddTaskFromToolbox: onAddTaskFromToolbox,
|
|
653
|
-
onTaskToolboxSearch: onTaskToolboxSearch,
|
|
654
|
-
onTaskClick: onTaskClick,
|
|
655
|
-
onTaskGroupModification: onTaskGroupModification,
|
|
656
|
-
onStageTitleChange: onStageTitleChange,
|
|
657
|
-
onTaskReorder: onTaskReorder,
|
|
658
|
-
onReplaceTaskFromToolbox: onReplaceTaskFromToolbox,
|
|
659
|
-
onTaskPlay: onTaskPlay
|
|
660
|
-
});
|
|
657
|
+
const StageNode = /*#__PURE__*/ memo(StageNodeComponent);
|
|
661
658
|
export { StageNode };
|