@uipath/apollo-react 3.62.0 → 3.63.0-pr431.329c320
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 +360 -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 +323 -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/DraggableTask.cjs +6 -4
- 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 +6 -4
- package/dist/canvas/components/StageNode/DraggableTask.types.d.ts +1 -2
- 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 +71 -38
- 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 +73 -40
- package/dist/canvas/components/StageNode/StageNode.stories.cjs +118 -135
- package/dist/canvas/components/StageNode/StageNode.stories.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.stories.js +115 -132
- package/dist/canvas/components/StageNode/StageNode.stories.utils.cjs +42 -0
- package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts +3 -0
- package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts.map +1 -0
- package/dist/canvas/components/StageNode/StageNode.stories.utils.js +8 -0
- package/dist/canvas/components/StageNode/StageNode.types.d.ts +9 -1
- package/dist/canvas/components/StageNode/StageNode.types.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/TaskMenu.cjs +13 -15
- package/dist/canvas/components/StageNode/TaskMenu.d.ts +1 -1
- package/dist/canvas/components/StageNode/TaskMenu.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/TaskMenu.js +14 -16
- package/dist/canvas/components/TaskIcon/TaskIcon.styles.cjs +1 -1
- package/dist/canvas/components/TaskIcon/TaskIcon.styles.js +1 -1
- package/dist/canvas/icons/CaseManagementProject.cjs +9 -18
- package/dist/canvas/icons/CaseManagementProject.d.ts.map +1 -1
- package/dist/canvas/icons/CaseManagementProject.js +9 -18
- package/package.json +3 -3
|
@@ -46,7 +46,33 @@ const external_DraggableTask_cjs_namespaceObject = require("./DraggableTask.cjs"
|
|
|
46
46
|
const external_StageNode_styles_cjs_namespaceObject = require("./StageNode.styles.cjs");
|
|
47
47
|
const external_StageNode_utils_cjs_namespaceObject = require("./StageNode.utils.cjs");
|
|
48
48
|
const external_StageNodeTaskUtilities_cjs_namespaceObject = require("./StageNodeTaskUtilities.cjs");
|
|
49
|
-
const
|
|
49
|
+
const StageNode_StageTaskDragOverlay = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ activeTask, isActiveTaskParallel, taskWidthStyle }) {
|
|
50
|
+
const { zoom } = (0, react_cjs_namespaceObject.useViewport)();
|
|
51
|
+
const dragOverlayStyle = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
52
|
+
transform: `scale(${zoom})`,
|
|
53
|
+
transformOrigin: 'top left'
|
|
54
|
+
}), [
|
|
55
|
+
zoom
|
|
56
|
+
]);
|
|
57
|
+
return /*#__PURE__*/ (0, external_react_dom_namespaceObject.createPortal)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(core_namespaceObject.DragOverlay, {
|
|
58
|
+
children: activeTask ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
59
|
+
style: dragOverlayStyle,
|
|
60
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StageNode_styles_cjs_namespaceObject.StageTask, {
|
|
61
|
+
selected: true,
|
|
62
|
+
isParallel: isActiveTaskParallel,
|
|
63
|
+
style: {
|
|
64
|
+
cursor: 'grabbing',
|
|
65
|
+
...taskWidthStyle
|
|
66
|
+
},
|
|
67
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DraggableTask_cjs_namespaceObject.TaskContent, {
|
|
68
|
+
task: activeTask,
|
|
69
|
+
isDragging: true
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
}) : null
|
|
73
|
+
}), document.body);
|
|
74
|
+
});
|
|
75
|
+
const StageNodeInner = (props)=>{
|
|
50
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 } = props;
|
|
51
77
|
const taskWidth = width ? width - external_StageNode_styles_cjs_namespaceObject.STAGE_CONTENT_INSET : void 0;
|
|
52
78
|
const tasks = (0, external_react_namespaceObject.useMemo)(()=>stageDetails?.tasks || [], [
|
|
@@ -66,9 +92,6 @@ const StageNodeComponent = (props)=>{
|
|
|
66
92
|
const status = execution?.stageStatus?.status;
|
|
67
93
|
const statusLabel = execution?.stageStatus?.label;
|
|
68
94
|
const stageDuration = execution?.stageStatus?.duration;
|
|
69
|
-
const reGroupTaskFunction = (0, external_react_namespaceObject.useMemo)(()=>onTaskGroupModification || (()=>{}), [
|
|
70
|
-
onTaskGroupModification
|
|
71
|
-
]);
|
|
72
95
|
const isStageTitleEditable = !!onStageTitleChange && !isReadOnly;
|
|
73
96
|
const [isHovered, setIsHovered] = (0, external_react_namespaceObject.useState)(false);
|
|
74
97
|
const [label, setLabel] = (0, external_react_namespaceObject.useState)(props.stageDetails.label);
|
|
@@ -85,6 +108,7 @@ const StageNodeComponent = (props)=>{
|
|
|
85
108
|
taskIndex: -1
|
|
86
109
|
});
|
|
87
110
|
const isConnecting = (0, react_cjs_namespaceObject.useStore)((state)=>!!state.connectionClickStartHandle);
|
|
111
|
+
const storeApi = (0, react_cjs_namespaceObject.useStoreApi)();
|
|
88
112
|
const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(id);
|
|
89
113
|
const [isAddingTask, setIsAddingTask] = (0, external_react_namespaceObject.useState)(false);
|
|
90
114
|
const [isReplacingTask, setIsReplacingTask] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -124,7 +148,6 @@ const StageNodeComponent = (props)=>{
|
|
|
124
148
|
tasks,
|
|
125
149
|
activeDragId
|
|
126
150
|
]);
|
|
127
|
-
const { zoom } = (0, react_cjs_namespaceObject.useViewport)();
|
|
128
151
|
const projected = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
129
152
|
if (!activeDragId || !overId) return null;
|
|
130
153
|
return (0, external_StageNode_utils_cjs_namespaceObject.getProjection)(tasks, activeDragId, overId, offsetLeft);
|
|
@@ -207,18 +230,21 @@ const StageNodeComponent = (props)=>{
|
|
|
207
230
|
handleStageTitleClickToSave,
|
|
208
231
|
isStageTitleEditing
|
|
209
232
|
]);
|
|
210
|
-
const
|
|
233
|
+
const hasContextMenu = !!(onReplaceTaskFromToolbox || onTaskGroupModification);
|
|
234
|
+
const buildContextMenuItems = (0, external_react_namespaceObject.useCallback)((groupIndex, taskIndex)=>{
|
|
235
|
+
const taskGroup = tasks[groupIndex] ?? [];
|
|
236
|
+
const isParallel = taskGroup.length > 1;
|
|
211
237
|
const items = [];
|
|
212
238
|
if (onReplaceTaskFromToolbox) {
|
|
213
239
|
items.push((0, external_StageNodeTaskUtilities_cjs_namespaceObject.getMenuItem)('replace-task', 'Replace task', ()=>{
|
|
214
|
-
const taskId =
|
|
240
|
+
const taskId = taskGroup[taskIndex]?.id;
|
|
215
241
|
if (taskId) onTaskClick?.(taskId);
|
|
216
242
|
setIsReplacingTask(true);
|
|
217
243
|
}));
|
|
218
244
|
items.push((0, external_StageNodeTaskUtilities_cjs_namespaceObject.getDivider)());
|
|
219
245
|
}
|
|
220
246
|
if (onTaskGroupModification) {
|
|
221
|
-
const reGroupOptions = (0, external_StageNodeTaskUtilities_cjs_namespaceObject.getContextMenuItems)(isParallel, groupIndex,
|
|
247
|
+
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);
|
|
222
248
|
return [
|
|
223
249
|
...items,
|
|
224
250
|
...reGroupOptions
|
|
@@ -229,10 +255,9 @@ const StageNodeComponent = (props)=>{
|
|
|
229
255
|
onReplaceTaskFromToolbox,
|
|
230
256
|
onTaskClick,
|
|
231
257
|
onTaskGroupModification,
|
|
232
|
-
reGroupTaskFunction,
|
|
233
258
|
tasks
|
|
234
259
|
]);
|
|
235
|
-
const { setSelectedNodeId } = (0, hooks_index_cjs_namespaceObject.
|
|
260
|
+
const { setSelectedNodeId } = (0, hooks_index_cjs_namespaceObject.useSetNodeSelection)();
|
|
236
261
|
const handleStageClick = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
237
262
|
onStageClick?.();
|
|
238
263
|
}, [
|
|
@@ -355,9 +380,9 @@ const StageNodeComponent = (props)=>{
|
|
|
355
380
|
setActiveDragId(event.active.id);
|
|
356
381
|
}, []);
|
|
357
382
|
const handleDragMove = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
358
|
-
setOffsetLeft(event.delta.x /
|
|
383
|
+
setOffsetLeft(event.delta.x / storeApi.getState().transform[2]);
|
|
359
384
|
}, [
|
|
360
|
-
|
|
385
|
+
storeApi
|
|
361
386
|
]);
|
|
362
387
|
const handleDragOver = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
363
388
|
setOverId(event.over?.id ?? null);
|
|
@@ -393,12 +418,6 @@ const StageNodeComponent = (props)=>{
|
|
|
393
418
|
} : void 0, [
|
|
394
419
|
taskWidth
|
|
395
420
|
]);
|
|
396
|
-
const dragOverlayStyle = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
397
|
-
transform: `scale(${zoom})`,
|
|
398
|
-
transformOrigin: 'top left'
|
|
399
|
-
}), [
|
|
400
|
-
zoom
|
|
401
|
-
]);
|
|
402
421
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
403
422
|
"data-testid": `stage-${id}`,
|
|
404
423
|
style: {
|
|
@@ -483,11 +502,13 @@ const StageNodeComponent = (props)=>{
|
|
|
483
502
|
(onTaskAdd || onAddTaskFromToolbox) && !isReadOnly && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_material_index_cjs_namespaceObject.ApTooltip, {
|
|
484
503
|
content: addTaskLabel,
|
|
485
504
|
placement: "top",
|
|
505
|
+
hide: addTaskLoading,
|
|
486
506
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
487
507
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_material_index_cjs_namespaceObject.ApIconButton, {
|
|
488
508
|
onClick: handleTaskAddClick,
|
|
489
509
|
size: "small",
|
|
490
510
|
label: addTaskLabel,
|
|
511
|
+
disabled: addTaskLoading,
|
|
491
512
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_material_index_cjs_namespaceObject.ApIcon, {
|
|
492
513
|
name: "add",
|
|
493
514
|
size: "20px"
|
|
@@ -536,13 +557,12 @@ const StageNodeComponent = (props)=>{
|
|
|
536
557
|
taskExecution: taskExecution,
|
|
537
558
|
isSelected: selectedTaskId === task.id,
|
|
538
559
|
isParallel: isParallel,
|
|
539
|
-
contextMenuItems: contextMenuItems(isParallel, groupIndex, taskIndex, tasks.length, taskGroup.length, (tasks[groupIndex - 1]?.length ?? 0) > 1, (tasks[groupIndex + 1]?.length ?? 0) > 1),
|
|
540
560
|
onTaskClick: handleTaskClick,
|
|
541
561
|
projectedDepth: task.id === activeDragId && projected ? projected.depth : void 0,
|
|
542
562
|
onTaskPlay: onTaskPlay,
|
|
543
563
|
isDragDisabled: !onTaskReorder,
|
|
544
|
-
|
|
545
|
-
|
|
564
|
+
...hasContextMenu && {
|
|
565
|
+
getContextMenuItems: ()=>buildContextMenuItems(groupIndex, taskIndex),
|
|
546
566
|
onMenuOpen: ()=>{
|
|
547
567
|
taskStateReference.current = {
|
|
548
568
|
isParallel,
|
|
@@ -560,23 +580,11 @@ const StageNodeComponent = (props)=>{
|
|
|
560
580
|
})
|
|
561
581
|
})
|
|
562
582
|
}),
|
|
563
|
-
/*#__PURE__*/ (0,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
isParallel: isActiveTaskParallel,
|
|
569
|
-
style: {
|
|
570
|
-
cursor: 'grabbing',
|
|
571
|
-
...taskWidthStyle
|
|
572
|
-
},
|
|
573
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DraggableTask_cjs_namespaceObject.TaskContent, {
|
|
574
|
-
task: activeTask,
|
|
575
|
-
isDragging: true
|
|
576
|
-
})
|
|
577
|
-
})
|
|
578
|
-
}) : null
|
|
579
|
-
}), document.body)
|
|
583
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(StageNode_StageTaskDragOverlay, {
|
|
584
|
+
activeTask: activeTask,
|
|
585
|
+
isActiveTaskParallel: isActiveTaskParallel,
|
|
586
|
+
taskWidthStyle: taskWidthStyle
|
|
587
|
+
})
|
|
580
588
|
]
|
|
581
589
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.Column, {
|
|
582
590
|
py: 2,
|
|
@@ -630,6 +638,31 @@ const StageNodeComponent = (props)=>{
|
|
|
630
638
|
]
|
|
631
639
|
});
|
|
632
640
|
};
|
|
641
|
+
const StageNodeInnerMemo = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(StageNodeInner);
|
|
642
|
+
const StageNodeComponent = ({ 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, {
|
|
643
|
+
dragging: dragging,
|
|
644
|
+
selected: selected,
|
|
645
|
+
id: id,
|
|
646
|
+
width: width,
|
|
647
|
+
execution: execution,
|
|
648
|
+
stageDetails: stageDetails,
|
|
649
|
+
addTaskLabel: addTaskLabel,
|
|
650
|
+
addTaskLoading: addTaskLoading,
|
|
651
|
+
replaceTaskLabel: replaceTaskLabel,
|
|
652
|
+
taskOptions: taskOptions,
|
|
653
|
+
menuItems: menuItems,
|
|
654
|
+
pendingReplaceTask: pendingReplaceTask,
|
|
655
|
+
onStageClick: onStageClick,
|
|
656
|
+
onTaskAdd: onTaskAdd,
|
|
657
|
+
onAddTaskFromToolbox: onAddTaskFromToolbox,
|
|
658
|
+
onTaskToolboxSearch: onTaskToolboxSearch,
|
|
659
|
+
onTaskClick: onTaskClick,
|
|
660
|
+
onTaskGroupModification: onTaskGroupModification,
|
|
661
|
+
onStageTitleChange: onStageTitleChange,
|
|
662
|
+
onTaskReorder: onTaskReorder,
|
|
663
|
+
onReplaceTaskFromToolbox: onReplaceTaskFromToolbox,
|
|
664
|
+
onTaskPlay: onTaskPlay
|
|
665
|
+
});
|
|
633
666
|
const StageNode = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(StageNodeComponent);
|
|
634
667
|
exports.StageNode = __webpack_exports__.StageNode;
|
|
635
668
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { StageNodeProps } from './StageNode.types';
|
|
2
|
-
export declare const StageNode: import("react").MemoExoticComponent<(
|
|
2
|
+
export declare const StageNode: import("react").MemoExoticComponent<({ dragging, selected, id, width, execution, stageDetails, addTaskLabel, addTaskLoading, replaceTaskLabel, taskOptions, menuItems, pendingReplaceTask, onStageClick, onTaskAdd, onAddTaskFromToolbox, onTaskToolboxSearch, onTaskClick, onTaskGroupModification, onStageTitleChange, onTaskReorder, onReplaceTaskFromToolbox, onTaskPlay, }: 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":"AA0DA,OAAO,KAAK,EAEV,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAotB3B,eAAO,MAAM,SAAS,mXA7BnB,cAAc,6CA6BgC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { DndContext, DragOverlay, KeyboardSensor, PointerSensor, closestCenter,
|
|
|
3
3
|
import { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
4
4
|
import { FontVariantToken, Padding, Spacing } from "@uipath/apollo-core";
|
|
5
5
|
import { Column, Row } from "../../layouts/index.js";
|
|
6
|
-
import { Position, useStore, useViewport } from "../../xyflow/react.js";
|
|
6
|
+
import { Position, useStore, useStoreApi, 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
9
|
import { createPortal } from "react-dom";
|
|
@@ -12,13 +12,39 @@ 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 { useSetNodeSelection } from "../NodePropertiesPanel/hooks/index.js";
|
|
16
16
|
import { Toolbox } from "../Toolbox/index.js";
|
|
17
17
|
import { DraggableTask, TaskContent } from "./DraggableTask.js";
|
|
18
18
|
import { INDENTATION_WIDTH, STAGE_CONTENT_INSET, StageContainer, StageContent, StageHeader, StageParallelBracket, StageParallelLabel, StageTask, StageTaskGroup, StageTaskList, StageTitleContainer, StageTitleInput } from "./StageNode.styles.js";
|
|
19
19
|
import { flattenTasks, getProjection, reorderTasks } from "./StageNode.utils.js";
|
|
20
20
|
import { getContextMenuItems, getDivider, getMenuItem } from "./StageNodeTaskUtilities.js";
|
|
21
|
-
const
|
|
21
|
+
const StageNode_StageTaskDragOverlay = /*#__PURE__*/ memo(function({ activeTask, isActiveTaskParallel, taskWidthStyle }) {
|
|
22
|
+
const { zoom } = useViewport();
|
|
23
|
+
const dragOverlayStyle = useMemo(()=>({
|
|
24
|
+
transform: `scale(${zoom})`,
|
|
25
|
+
transformOrigin: 'top left'
|
|
26
|
+
}), [
|
|
27
|
+
zoom
|
|
28
|
+
]);
|
|
29
|
+
return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(DragOverlay, {
|
|
30
|
+
children: activeTask ? /*#__PURE__*/ jsx("div", {
|
|
31
|
+
style: dragOverlayStyle,
|
|
32
|
+
children: /*#__PURE__*/ jsx(StageTask, {
|
|
33
|
+
selected: true,
|
|
34
|
+
isParallel: isActiveTaskParallel,
|
|
35
|
+
style: {
|
|
36
|
+
cursor: 'grabbing',
|
|
37
|
+
...taskWidthStyle
|
|
38
|
+
},
|
|
39
|
+
children: /*#__PURE__*/ jsx(TaskContent, {
|
|
40
|
+
task: activeTask,
|
|
41
|
+
isDragging: true
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
}) : null
|
|
45
|
+
}), document.body);
|
|
46
|
+
});
|
|
47
|
+
const StageNodeInner = (props)=>{
|
|
22
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 } = props;
|
|
23
49
|
const taskWidth = width ? width - STAGE_CONTENT_INSET : void 0;
|
|
24
50
|
const tasks = useMemo(()=>stageDetails?.tasks || [], [
|
|
@@ -38,9 +64,6 @@ const StageNodeComponent = (props)=>{
|
|
|
38
64
|
const status = execution?.stageStatus?.status;
|
|
39
65
|
const statusLabel = execution?.stageStatus?.label;
|
|
40
66
|
const stageDuration = execution?.stageStatus?.duration;
|
|
41
|
-
const reGroupTaskFunction = useMemo(()=>onTaskGroupModification || (()=>{}), [
|
|
42
|
-
onTaskGroupModification
|
|
43
|
-
]);
|
|
44
67
|
const isStageTitleEditable = !!onStageTitleChange && !isReadOnly;
|
|
45
68
|
const [isHovered, setIsHovered] = useState(false);
|
|
46
69
|
const [label, setLabel] = useState(props.stageDetails.label);
|
|
@@ -57,6 +80,7 @@ const StageNodeComponent = (props)=>{
|
|
|
57
80
|
taskIndex: -1
|
|
58
81
|
});
|
|
59
82
|
const isConnecting = useStore((state)=>!!state.connectionClickStartHandle);
|
|
83
|
+
const storeApi = useStoreApi();
|
|
60
84
|
const connectedHandleIds = useConnectedHandles(id);
|
|
61
85
|
const [isAddingTask, setIsAddingTask] = useState(false);
|
|
62
86
|
const [isReplacingTask, setIsReplacingTask] = useState(false);
|
|
@@ -96,7 +120,6 @@ const StageNodeComponent = (props)=>{
|
|
|
96
120
|
tasks,
|
|
97
121
|
activeDragId
|
|
98
122
|
]);
|
|
99
|
-
const { zoom } = useViewport();
|
|
100
123
|
const projected = useMemo(()=>{
|
|
101
124
|
if (!activeDragId || !overId) return null;
|
|
102
125
|
return getProjection(tasks, activeDragId, overId, offsetLeft);
|
|
@@ -179,18 +202,21 @@ const StageNodeComponent = (props)=>{
|
|
|
179
202
|
handleStageTitleClickToSave,
|
|
180
203
|
isStageTitleEditing
|
|
181
204
|
]);
|
|
182
|
-
const
|
|
205
|
+
const hasContextMenu = !!(onReplaceTaskFromToolbox || onTaskGroupModification);
|
|
206
|
+
const buildContextMenuItems = useCallback((groupIndex, taskIndex)=>{
|
|
207
|
+
const taskGroup = tasks[groupIndex] ?? [];
|
|
208
|
+
const isParallel = taskGroup.length > 1;
|
|
183
209
|
const items = [];
|
|
184
210
|
if (onReplaceTaskFromToolbox) {
|
|
185
211
|
items.push(getMenuItem('replace-task', 'Replace task', ()=>{
|
|
186
|
-
const taskId =
|
|
212
|
+
const taskId = taskGroup[taskIndex]?.id;
|
|
187
213
|
if (taskId) onTaskClick?.(taskId);
|
|
188
214
|
setIsReplacingTask(true);
|
|
189
215
|
}));
|
|
190
216
|
items.push(getDivider());
|
|
191
217
|
}
|
|
192
218
|
if (onTaskGroupModification) {
|
|
193
|
-
const reGroupOptions = getContextMenuItems(isParallel, groupIndex,
|
|
219
|
+
const reGroupOptions = getContextMenuItems(isParallel, groupIndex, tasks.length, taskIndex, taskGroup.length, (tasks[groupIndex - 1]?.length ?? 0) > 1, (tasks[groupIndex + 1]?.length ?? 0) > 1, onTaskGroupModification);
|
|
194
220
|
return [
|
|
195
221
|
...items,
|
|
196
222
|
...reGroupOptions
|
|
@@ -201,10 +227,9 @@ const StageNodeComponent = (props)=>{
|
|
|
201
227
|
onReplaceTaskFromToolbox,
|
|
202
228
|
onTaskClick,
|
|
203
229
|
onTaskGroupModification,
|
|
204
|
-
reGroupTaskFunction,
|
|
205
230
|
tasks
|
|
206
231
|
]);
|
|
207
|
-
const { setSelectedNodeId } =
|
|
232
|
+
const { setSelectedNodeId } = useSetNodeSelection();
|
|
208
233
|
const handleStageClick = useCallback(()=>{
|
|
209
234
|
onStageClick?.();
|
|
210
235
|
}, [
|
|
@@ -327,9 +352,9 @@ const StageNodeComponent = (props)=>{
|
|
|
327
352
|
setActiveDragId(event.active.id);
|
|
328
353
|
}, []);
|
|
329
354
|
const handleDragMove = useCallback((event)=>{
|
|
330
|
-
setOffsetLeft(event.delta.x /
|
|
355
|
+
setOffsetLeft(event.delta.x / storeApi.getState().transform[2]);
|
|
331
356
|
}, [
|
|
332
|
-
|
|
357
|
+
storeApi
|
|
333
358
|
]);
|
|
334
359
|
const handleDragOver = useCallback((event)=>{
|
|
335
360
|
setOverId(event.over?.id ?? null);
|
|
@@ -365,12 +390,6 @@ const StageNodeComponent = (props)=>{
|
|
|
365
390
|
} : void 0, [
|
|
366
391
|
taskWidth
|
|
367
392
|
]);
|
|
368
|
-
const dragOverlayStyle = useMemo(()=>({
|
|
369
|
-
transform: `scale(${zoom})`,
|
|
370
|
-
transformOrigin: 'top left'
|
|
371
|
-
}), [
|
|
372
|
-
zoom
|
|
373
|
-
]);
|
|
374
393
|
return /*#__PURE__*/ jsxs("div", {
|
|
375
394
|
"data-testid": `stage-${id}`,
|
|
376
395
|
style: {
|
|
@@ -455,11 +474,13 @@ const StageNodeComponent = (props)=>{
|
|
|
455
474
|
(onTaskAdd || onAddTaskFromToolbox) && !isReadOnly && /*#__PURE__*/ jsx(ApTooltip, {
|
|
456
475
|
content: addTaskLabel,
|
|
457
476
|
placement: "top",
|
|
477
|
+
hide: addTaskLoading,
|
|
458
478
|
children: /*#__PURE__*/ jsx("span", {
|
|
459
479
|
children: /*#__PURE__*/ jsx(ApIconButton, {
|
|
460
480
|
onClick: handleTaskAddClick,
|
|
461
481
|
size: "small",
|
|
462
482
|
label: addTaskLabel,
|
|
483
|
+
disabled: addTaskLoading,
|
|
463
484
|
children: /*#__PURE__*/ jsx(ApIcon, {
|
|
464
485
|
name: "add",
|
|
465
486
|
size: "20px"
|
|
@@ -508,13 +529,12 @@ const StageNodeComponent = (props)=>{
|
|
|
508
529
|
taskExecution: taskExecution,
|
|
509
530
|
isSelected: selectedTaskId === task.id,
|
|
510
531
|
isParallel: isParallel,
|
|
511
|
-
contextMenuItems: contextMenuItems(isParallel, groupIndex, taskIndex, tasks.length, taskGroup.length, (tasks[groupIndex - 1]?.length ?? 0) > 1, (tasks[groupIndex + 1]?.length ?? 0) > 1),
|
|
512
532
|
onTaskClick: handleTaskClick,
|
|
513
533
|
projectedDepth: task.id === activeDragId && projected ? projected.depth : void 0,
|
|
514
534
|
onTaskPlay: onTaskPlay,
|
|
515
535
|
isDragDisabled: !onTaskReorder,
|
|
516
|
-
|
|
517
|
-
|
|
536
|
+
...hasContextMenu && {
|
|
537
|
+
getContextMenuItems: ()=>buildContextMenuItems(groupIndex, taskIndex),
|
|
518
538
|
onMenuOpen: ()=>{
|
|
519
539
|
taskStateReference.current = {
|
|
520
540
|
isParallel,
|
|
@@ -532,23 +552,11 @@ const StageNodeComponent = (props)=>{
|
|
|
532
552
|
})
|
|
533
553
|
})
|
|
534
554
|
}),
|
|
535
|
-
/*#__PURE__*/
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
isParallel: isActiveTaskParallel,
|
|
541
|
-
style: {
|
|
542
|
-
cursor: 'grabbing',
|
|
543
|
-
...taskWidthStyle
|
|
544
|
-
},
|
|
545
|
-
children: /*#__PURE__*/ jsx(TaskContent, {
|
|
546
|
-
task: activeTask,
|
|
547
|
-
isDragging: true
|
|
548
|
-
})
|
|
549
|
-
})
|
|
550
|
-
}) : null
|
|
551
|
-
}), document.body)
|
|
555
|
+
/*#__PURE__*/ jsx(StageNode_StageTaskDragOverlay, {
|
|
556
|
+
activeTask: activeTask,
|
|
557
|
+
isActiveTaskParallel: isActiveTaskParallel,
|
|
558
|
+
taskWidthStyle: taskWidthStyle
|
|
559
|
+
})
|
|
552
560
|
]
|
|
553
561
|
}) : /*#__PURE__*/ jsx(Column, {
|
|
554
562
|
py: 2,
|
|
@@ -602,5 +610,30 @@ const StageNodeComponent = (props)=>{
|
|
|
602
610
|
]
|
|
603
611
|
});
|
|
604
612
|
};
|
|
613
|
+
const StageNodeInnerMemo = /*#__PURE__*/ memo(StageNodeInner);
|
|
614
|
+
const StageNodeComponent = ({ 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, {
|
|
615
|
+
dragging: dragging,
|
|
616
|
+
selected: selected,
|
|
617
|
+
id: id,
|
|
618
|
+
width: width,
|
|
619
|
+
execution: execution,
|
|
620
|
+
stageDetails: stageDetails,
|
|
621
|
+
addTaskLabel: addTaskLabel,
|
|
622
|
+
addTaskLoading: addTaskLoading,
|
|
623
|
+
replaceTaskLabel: replaceTaskLabel,
|
|
624
|
+
taskOptions: taskOptions,
|
|
625
|
+
menuItems: menuItems,
|
|
626
|
+
pendingReplaceTask: pendingReplaceTask,
|
|
627
|
+
onStageClick: onStageClick,
|
|
628
|
+
onTaskAdd: onTaskAdd,
|
|
629
|
+
onAddTaskFromToolbox: onAddTaskFromToolbox,
|
|
630
|
+
onTaskToolboxSearch: onTaskToolboxSearch,
|
|
631
|
+
onTaskClick: onTaskClick,
|
|
632
|
+
onTaskGroupModification: onTaskGroupModification,
|
|
633
|
+
onStageTitleChange: onStageTitleChange,
|
|
634
|
+
onTaskReorder: onTaskReorder,
|
|
635
|
+
onReplaceTaskFromToolbox: onReplaceTaskFromToolbox,
|
|
636
|
+
onTaskPlay: onTaskPlay
|
|
637
|
+
});
|
|
605
638
|
const StageNode = /*#__PURE__*/ memo(StageNodeComponent);
|
|
606
639
|
export { StageNode };
|