@uipath/apollo-react 6.26.0 → 6.28.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/AgentCanvas/AgentFlow.cjs +4 -3
- package/dist/canvas/components/AgentCanvas/AgentFlow.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/AgentFlow.js +4 -3
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.cjs +13 -9
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.js +13 -9
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.styles.cjs +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.styles.d.ts +2 -0
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.styles.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.styles.js +1 -1
- package/dist/canvas/components/BaseCanvas/BaseCanvas.cjs +27 -3
- package/dist/canvas/components/BaseCanvas/BaseCanvas.d.ts.map +1 -1
- package/dist/canvas/components/BaseCanvas/BaseCanvas.hooks.cjs +21 -3
- package/dist/canvas/components/BaseCanvas/BaseCanvas.hooks.d.ts +1 -0
- package/dist/canvas/components/BaseCanvas/BaseCanvas.hooks.d.ts.map +1 -1
- package/dist/canvas/components/BaseCanvas/BaseCanvas.hooks.js +18 -3
- package/dist/canvas/components/BaseCanvas/BaseCanvas.js +28 -4
- package/dist/canvas/components/BaseCanvas/BaseCanvas.stories.fixtures.cjs +87 -0
- package/dist/canvas/components/BaseCanvas/BaseCanvas.stories.fixtures.d.ts +4 -0
- package/dist/canvas/components/BaseCanvas/BaseCanvas.stories.fixtures.d.ts.map +1 -0
- package/dist/canvas/components/BaseCanvas/BaseCanvas.stories.fixtures.js +53 -0
- package/dist/canvas/components/BaseCanvas/BaseCanvas.types.d.ts.map +1 -1
- package/dist/canvas/components/BaseCanvas/ReadOnlyNodesContext.cjs +30 -3
- package/dist/canvas/components/BaseCanvas/ReadOnlyNodesContext.d.ts +3 -0
- package/dist/canvas/components/BaseCanvas/ReadOnlyNodesContext.d.ts.map +1 -1
- package/dist/canvas/components/BaseCanvas/ReadOnlyNodesContext.js +21 -3
- package/dist/canvas/components/BaseCanvas/index.cjs +43 -32
- package/dist/canvas/components/BaseCanvas/index.d.ts +1 -1
- package/dist/canvas/components/BaseCanvas/index.d.ts.map +1 -1
- package/dist/canvas/components/BaseCanvas/index.js +2 -2
- package/dist/canvas/components/BaseCanvas/useReadOnlyConnectionCallbacks.cjs +87 -0
- package/dist/canvas/components/BaseCanvas/useReadOnlyConnectionCallbacks.d.ts +13 -0
- package/dist/canvas/components/BaseCanvas/useReadOnlyConnectionCallbacks.d.ts.map +1 -0
- package/dist/canvas/components/BaseCanvas/useReadOnlyConnectionCallbacks.js +53 -0
- package/dist/canvas/components/BaseNode/BaseNode.cjs +2 -14
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +2 -14
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +2 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts +1 -0
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +2 -1
- package/dist/canvas/components/LoopNode/LoopNode.cjs +13 -5
- package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNode.js +13 -5
- package/dist/canvas/components/StageNode/StageNode.cjs +15 -11
- package/dist/canvas/components/StageNode/StageNode.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.js +15 -11
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.cjs +29 -6
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts.map +1 -1
- package/dist/canvas/components/StickyNoteNode/StickyNoteNode.js +29 -6
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +21 -3
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +21 -3
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.utils.cjs +18 -2
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.utils.d.ts +2 -0
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.utils.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.utils.js +14 -1
- package/dist/canvas/storybook-utils/components/StoryPage.d.ts +15 -1
- package/dist/canvas/storybook-utils/components/StoryPage.d.ts.map +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/types.d.ts +1 -0
- package/dist/canvas/types.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewGraph.cjs +13 -8
- package/dist/canvas/utils/createPreviewGraph.d.ts +5 -2
- package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewGraph.js +13 -8
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useLatestRef } from "../../hooks/useLatestRef.js";
|
|
3
|
+
import { isConnectionReadOnly } from "./ReadOnlyNodesContext.js";
|
|
4
|
+
const includesReadOnlyConnection = (readOnlyNodeIds, ...connections)=>connections.some(({ source, target })=>isConnectionReadOnly(readOnlyNodeIds, source, target));
|
|
5
|
+
function useReadOnlyConnectionCallbacks({ readOnlyNodeIds, isValidConnection, onConnect, onReconnect, onReconnectEnd }) {
|
|
6
|
+
const readOnlyNodeIdsRef = useLatestRef(readOnlyNodeIds);
|
|
7
|
+
const isValidConnectionRef = useLatestRef(isValidConnection);
|
|
8
|
+
const onConnectRef = useLatestRef(onConnect);
|
|
9
|
+
const onReconnectRef = useLatestRef(onReconnect);
|
|
10
|
+
const onReconnectEndRef = useLatestRef(onReconnectEnd);
|
|
11
|
+
const guardedIsValidConnection = useCallback((connection)=>{
|
|
12
|
+
const currentReadOnlyNodeIds = readOnlyNodeIdsRef.current;
|
|
13
|
+
if (includesReadOnlyConnection(currentReadOnlyNodeIds, connection)) return false;
|
|
14
|
+
return isValidConnectionRef.current?.(connection) ?? true;
|
|
15
|
+
}, [
|
|
16
|
+
isValidConnectionRef,
|
|
17
|
+
readOnlyNodeIdsRef
|
|
18
|
+
]);
|
|
19
|
+
const guardedOnConnect = useCallback((connection)=>{
|
|
20
|
+
const currentOnConnect = onConnectRef.current;
|
|
21
|
+
const currentReadOnlyNodeIds = readOnlyNodeIdsRef.current;
|
|
22
|
+
if (!currentOnConnect || includesReadOnlyConnection(currentReadOnlyNodeIds, connection)) return;
|
|
23
|
+
currentOnConnect(connection);
|
|
24
|
+
}, [
|
|
25
|
+
onConnectRef,
|
|
26
|
+
readOnlyNodeIdsRef
|
|
27
|
+
]);
|
|
28
|
+
const guardedOnReconnect = useCallback((edgeBeingReconnected, proposedConnection)=>{
|
|
29
|
+
const currentOnReconnect = onReconnectRef.current;
|
|
30
|
+
const currentReadOnlyNodeIds = readOnlyNodeIdsRef.current;
|
|
31
|
+
if (!currentOnReconnect || includesReadOnlyConnection(currentReadOnlyNodeIds, edgeBeingReconnected, proposedConnection)) return;
|
|
32
|
+
currentOnReconnect(edgeBeingReconnected, proposedConnection);
|
|
33
|
+
}, [
|
|
34
|
+
onReconnectRef,
|
|
35
|
+
readOnlyNodeIdsRef
|
|
36
|
+
]);
|
|
37
|
+
const guardedOnReconnectEnd = useCallback((event, edgeBeingReconnected, handleType, connectionState)=>{
|
|
38
|
+
const currentOnReconnectEnd = onReconnectEndRef.current;
|
|
39
|
+
const currentReadOnlyNodeIds = readOnlyNodeIdsRef.current;
|
|
40
|
+
if (!currentOnReconnectEnd || includesReadOnlyConnection(currentReadOnlyNodeIds, edgeBeingReconnected)) return;
|
|
41
|
+
currentOnReconnectEnd(event, edgeBeingReconnected, handleType, connectionState);
|
|
42
|
+
}, [
|
|
43
|
+
onReconnectEndRef,
|
|
44
|
+
readOnlyNodeIdsRef
|
|
45
|
+
]);
|
|
46
|
+
return {
|
|
47
|
+
guardedIsValidConnection,
|
|
48
|
+
guardedOnConnect: onConnect ? guardedOnConnect : void 0,
|
|
49
|
+
guardedOnReconnect: onReconnect ? guardedOnReconnect : void 0,
|
|
50
|
+
guardedOnReconnectEnd: onReconnectEnd ? guardedOnReconnectEnd : void 0
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export { useReadOnlyConnectionCallbacks };
|
|
@@ -47,6 +47,7 @@ const SmartHandle_cjs_namespaceObject = require("../ButtonHandle/SmartHandle.cjs
|
|
|
47
47
|
const useButtonHandles_cjs_namespaceObject = require("../ButtonHandle/useButtonHandles.cjs");
|
|
48
48
|
const InitialsBadge_cjs_namespaceObject = require("../shared/InitialsBadge.cjs");
|
|
49
49
|
const external_Toolbar_index_cjs_namespaceObject = require("../Toolbar/index.cjs");
|
|
50
|
+
const NodeToolbar_utils_cjs_namespaceObject = require("../Toolbar/NodeToolbar/NodeToolbar.utils.cjs");
|
|
50
51
|
const external_BaseNodeBadgeSlot_cjs_namespaceObject = require("./BaseNodeBadgeSlot.cjs");
|
|
51
52
|
const external_BaseNodeConfigContext_cjs_namespaceObject = require("./BaseNodeConfigContext.cjs");
|
|
52
53
|
const external_BaseNodeContainer_cjs_namespaceObject = require("./BaseNodeContainer.cjs");
|
|
@@ -54,10 +55,6 @@ const external_BaseNodeInnerShape_cjs_namespaceObject = require("./BaseNodeInner
|
|
|
54
55
|
const external_BaseNodeMissingManifest_cjs_namespaceObject = require("./BaseNodeMissingManifest.cjs");
|
|
55
56
|
const external_NodeLabel_cjs_namespaceObject = require("./NodeLabel.cjs");
|
|
56
57
|
const NEVER_SHOW_ADD_BUTTON = ()=>false;
|
|
57
|
-
const disableToolbarActions = (actions)=>actions.map((action)=>'separator' === action.id ? action : {
|
|
58
|
-
...action,
|
|
59
|
-
disabled: true
|
|
60
|
-
});
|
|
61
58
|
const getContainerWidth = (shape, width)=>{
|
|
62
59
|
const defaultWidth = 'rectangle' === shape ? external_constants_cjs_namespaceObject.DEFAULT_RECTANGLE_NODE_WIDTH : external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE;
|
|
63
60
|
if (width && width !== external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE && width !== external_constants_cjs_namespaceObject.DEFAULT_RECTANGLE_NODE_WIDTH) return width;
|
|
@@ -179,16 +176,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
179
176
|
manifest,
|
|
180
177
|
statusContext
|
|
181
178
|
]);
|
|
182
|
-
const effectiveToolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>
|
|
183
|
-
if (!toolbarConfig || !isNodeReadOnly) return toolbarConfig;
|
|
184
|
-
return {
|
|
185
|
-
...toolbarConfig,
|
|
186
|
-
actions: disableToolbarActions(toolbarConfig.actions),
|
|
187
|
-
...toolbarConfig.overflowActions && {
|
|
188
|
-
overflowActions: disableToolbarActions(toolbarConfig.overflowActions)
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
}, [
|
|
179
|
+
const effectiveToolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>toolbarConfig && isNodeReadOnly ? (0, NodeToolbar_utils_cjs_namespaceObject.lockToolbarConfig)(toolbarConfig) : toolbarConfig, [
|
|
192
180
|
toolbarConfig,
|
|
193
181
|
isNodeReadOnly
|
|
194
182
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/BaseNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/BaseNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AA+ChF,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,kBAAkB,CAAC;AAosB1B,eAAO,MAAM,QAAQ,8CA/pBa,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,6CA+pBmB,CAAC"}
|
|
@@ -19,6 +19,7 @@ import { SmartHandle, SmartHandleProvider } from "../ButtonHandle/SmartHandle.js
|
|
|
19
19
|
import { useButtonHandles } from "../ButtonHandle/useButtonHandles.js";
|
|
20
20
|
import { InitialsBadge } from "../shared/InitialsBadge.js";
|
|
21
21
|
import { NodeToolbar } from "../Toolbar/index.js";
|
|
22
|
+
import { lockToolbarConfig } from "../Toolbar/NodeToolbar/NodeToolbar.utils.js";
|
|
22
23
|
import { BaseBadgeSlot } from "./BaseNodeBadgeSlot.js";
|
|
23
24
|
import { useBaseNodeOverrideConfig } from "./BaseNodeConfigContext.js";
|
|
24
25
|
import { BaseContainer } from "./BaseNodeContainer.js";
|
|
@@ -26,10 +27,6 @@ import { BaseInnerShape } from "./BaseNodeInnerShape.js";
|
|
|
26
27
|
import { MissingManifestNode } from "./BaseNodeMissingManifest.js";
|
|
27
28
|
import { NodeLabel } from "./NodeLabel.js";
|
|
28
29
|
const NEVER_SHOW_ADD_BUTTON = ()=>false;
|
|
29
|
-
const disableToolbarActions = (actions)=>actions.map((action)=>'separator' === action.id ? action : {
|
|
30
|
-
...action,
|
|
31
|
-
disabled: true
|
|
32
|
-
});
|
|
33
30
|
const getContainerWidth = (shape, width)=>{
|
|
34
31
|
const defaultWidth = 'rectangle' === shape ? DEFAULT_RECTANGLE_NODE_WIDTH : DEFAULT_NODE_SIZE;
|
|
35
32
|
if (width && width !== DEFAULT_NODE_SIZE && width !== DEFAULT_RECTANGLE_NODE_WIDTH) return width;
|
|
@@ -151,16 +148,7 @@ const BaseNodeComponent = (props)=>{
|
|
|
151
148
|
manifest,
|
|
152
149
|
statusContext
|
|
153
150
|
]);
|
|
154
|
-
const effectiveToolbarConfig = useMemo(()=>
|
|
155
|
-
if (!toolbarConfig || !isNodeReadOnly) return toolbarConfig;
|
|
156
|
-
return {
|
|
157
|
-
...toolbarConfig,
|
|
158
|
-
actions: disableToolbarActions(toolbarConfig.actions),
|
|
159
|
-
...toolbarConfig.overflowActions && {
|
|
160
|
-
overflowActions: disableToolbarActions(toolbarConfig.overflowActions)
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}, [
|
|
151
|
+
const effectiveToolbarConfig = useMemo(()=>toolbarConfig && isNodeReadOnly ? lockToolbarConfig(toolbarConfig) : toolbarConfig, [
|
|
164
152
|
toolbarConfig,
|
|
165
153
|
isNodeReadOnly
|
|
166
154
|
]);
|
|
@@ -66,7 +66,7 @@ function shouldPersistNodeChange(change) {
|
|
|
66
66
|
function isDefaultViewport(viewport) {
|
|
67
67
|
return 0 === viewport.x && 0 === viewport.y && 1 === viewport.zoom;
|
|
68
68
|
}
|
|
69
|
-
const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
69
|
+
const HierarchicalCanvas = ({ mode = 'design', readOnlyNodeIds, initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
70
70
|
const canvasRef = (0, external_react_namespaceObject.useRef)(null);
|
|
71
71
|
const containerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
72
72
|
const [reactFlowInstance, setReactFlowInstance] = (0, external_react_namespaceObject.useState)(null);
|
|
@@ -349,6 +349,7 @@ const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onC
|
|
|
349
349
|
onInit: handleInit,
|
|
350
350
|
onToolbarAction: handleToolbarAction,
|
|
351
351
|
mode: mode,
|
|
352
|
+
readOnlyNodeIds: readOnlyNodeIds,
|
|
352
353
|
defaultViewport: currentCanvas.viewport,
|
|
353
354
|
fitView: shouldFitView,
|
|
354
355
|
fitViewOptions: {
|
|
@@ -2,6 +2,7 @@ import type React from 'react';
|
|
|
2
2
|
import type { CanvasLevel } from '../../types/canvas.types';
|
|
3
3
|
interface HierarchicalCanvasProps {
|
|
4
4
|
mode?: 'view' | 'design' | 'readonly';
|
|
5
|
+
readOnlyNodeIds?: ReadonlySet<string>;
|
|
5
6
|
initialCanvases?: Record<string, CanvasLevel>;
|
|
6
7
|
initialPath?: string[];
|
|
7
8
|
onCanvasesChange?: (canvases: Record<string, CanvasLevel>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchicalCanvas.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/HierarchicalCanvas/HierarchicalCanvas.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA8B/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAe5D,UAAU,uBAAuB;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;IAKtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAK9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAMvB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,IAAI,CAAC;IAInE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACzC;AAyBD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"HierarchicalCanvas.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/HierarchicalCanvas/HierarchicalCanvas.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA8B/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAe5D,UAAU,uBAAuB;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;IAEtC,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAKtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAK9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAMvB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,IAAI,CAAC;IAInE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACzC;AAyBD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAqZhE,CAAC"}
|
|
@@ -38,7 +38,7 @@ function shouldPersistNodeChange(change) {
|
|
|
38
38
|
function isDefaultViewport(viewport) {
|
|
39
39
|
return 0 === viewport.x && 0 === viewport.y && 1 === viewport.zoom;
|
|
40
40
|
}
|
|
41
|
-
const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
41
|
+
const HierarchicalCanvas = ({ mode = 'design', readOnlyNodeIds, initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
42
42
|
const canvasRef = useRef(null);
|
|
43
43
|
const containerRef = useRef(null);
|
|
44
44
|
const [reactFlowInstance, setReactFlowInstance] = useState(null);
|
|
@@ -321,6 +321,7 @@ const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onC
|
|
|
321
321
|
onInit: handleInit,
|
|
322
322
|
onToolbarAction: handleToolbarAction,
|
|
323
323
|
mode: mode,
|
|
324
|
+
readOnlyNodeIds: readOnlyNodeIds,
|
|
324
325
|
defaultViewport: currentCanvas.viewport,
|
|
325
326
|
fitView: shouldFitView,
|
|
326
327
|
fitViewOptions: {
|
|
@@ -44,6 +44,7 @@ const nodePropsEqual_cjs_namespaceObject = require("../../utils/nodePropsEqual.c
|
|
|
44
44
|
const toolbar_resolver_cjs_namespaceObject = require("../../utils/toolbar-resolver.cjs");
|
|
45
45
|
const BaseCanvasModeProvider_cjs_namespaceObject = require("../BaseCanvas/BaseCanvasModeProvider.cjs");
|
|
46
46
|
const ConnectedHandlesContext_cjs_namespaceObject = require("../BaseCanvas/ConnectedHandlesContext.cjs");
|
|
47
|
+
const ReadOnlyNodesContext_cjs_namespaceObject = require("../BaseCanvas/ReadOnlyNodesContext.cjs");
|
|
47
48
|
const SelectionStateContext_cjs_namespaceObject = require("../BaseCanvas/SelectionStateContext.cjs");
|
|
48
49
|
const BaseNodeBadgeSlot_cjs_namespaceObject = require("../BaseNode/BaseNodeBadgeSlot.cjs");
|
|
49
50
|
const BaseNodeContainer_cjs_namespaceObject = require("../BaseNode/BaseNodeContainer.cjs");
|
|
@@ -51,6 +52,7 @@ const BaseNodeMissingManifest_cjs_namespaceObject = require("../BaseNode/BaseNod
|
|
|
51
52
|
const external_ButtonHandle_index_cjs_namespaceObject = require("../ButtonHandle/index.cjs");
|
|
52
53
|
const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs");
|
|
53
54
|
const external_Toolbar_index_cjs_namespaceObject = require("../Toolbar/index.cjs");
|
|
55
|
+
const NodeToolbar_utils_cjs_namespaceObject = require("../Toolbar/NodeToolbar/NodeToolbar.utils.cjs");
|
|
54
56
|
const external_LoopNode_helpers_cjs_namespaceObject = require("./LoopNode.helpers.cjs");
|
|
55
57
|
const external_LoopNodeExecutionCount_cjs_namespaceObject = require("./LoopNodeExecutionCount.cjs");
|
|
56
58
|
const DEFAULT_LOOP_ICON = 'repeat';
|
|
@@ -173,6 +175,8 @@ function LoopNodeComponent(props) {
|
|
|
173
175
|
]);
|
|
174
176
|
const { mode } = (0, BaseCanvasModeProvider_cjs_namespaceObject.useBaseCanvasMode)();
|
|
175
177
|
const isDesignMode = 'design' === mode;
|
|
178
|
+
const isNodeReadOnly = (0, ReadOnlyNodesContext_cjs_namespaceObject.useIsNodeReadOnly)(id);
|
|
179
|
+
const canEditNode = isDesignMode && !isNodeReadOnly;
|
|
176
180
|
const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(id);
|
|
177
181
|
const { multipleNodesSelected } = (0, SelectionStateContext_cjs_namespaceObject.useSelectionState)();
|
|
178
182
|
const isConnecting = (0, react_cjs_namespaceObject.useStore)(NodeUtils_cjs_namespaceObject.selectIsConnecting);
|
|
@@ -245,6 +249,10 @@ function LoopNodeComponent(props) {
|
|
|
245
249
|
statusContext,
|
|
246
250
|
toolbarConfigProp
|
|
247
251
|
]);
|
|
252
|
+
const effectiveToolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>toolbarConfig && isNodeReadOnly ? (0, NodeToolbar_utils_cjs_namespaceObject.lockToolbarConfig)(toolbarConfig) : toolbarConfig, [
|
|
253
|
+
toolbarConfig,
|
|
254
|
+
isNodeReadOnly
|
|
255
|
+
]);
|
|
248
256
|
const adornments = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
249
257
|
...(0, adornment_resolver_cjs_namespaceObject.resolveAdornments)(statusContext, {
|
|
250
258
|
hideExecutionStatusAdornment: true
|
|
@@ -302,8 +310,8 @@ function LoopNodeComponent(props) {
|
|
|
302
310
|
setIsHovered(false);
|
|
303
311
|
}, []);
|
|
304
312
|
const shouldShowHandles = (isConnecting || selected || isHovered) && !dragging;
|
|
305
|
-
const showHandleAddButtons =
|
|
306
|
-
const showEmptyStateButton =
|
|
313
|
+
const showHandleAddButtons = canEditNode && !multipleNodesSelected && !isConnecting && !dragging;
|
|
314
|
+
const showEmptyStateButton = canEditNode && !hasChildNodes && !!onAddFirstChild;
|
|
307
315
|
const interactionState = resolveInteractionState(dragging, selected, isHovered);
|
|
308
316
|
const activeStatus = suggestionType ?? validationState?.validationStatus ?? executionStatus;
|
|
309
317
|
const statusBorder = (0, BaseNodeContainer_cjs_namespaceObject.getStatusBorder)(activeStatus);
|
|
@@ -328,7 +336,7 @@ function LoopNodeComponent(props) {
|
|
|
328
336
|
"data-suggestion-type": suggestionType,
|
|
329
337
|
"data-validation-status": validationState?.validationStatus,
|
|
330
338
|
"aria-busy": resolvedData.loading || void 0,
|
|
331
|
-
className: (0, apollo_wind_namespaceObject.cn)('group/loop-shell relative box-border flex h-full w-full flex-col overflow-visible rounded-[20px] border bg-transparent', 'transition-[border-color,box-shadow,opacity] shadow-(--canvas-node-shadow-rest)', 'border-border', statusBorder, isHovered && 'shadow-(--canvas-node-shadow-hover)', isHovered && !hasStatusBorder && 'border-border-hover', selected && 'outline
|
|
339
|
+
className: (0, apollo_wind_namespaceObject.cn)('group/loop-shell relative box-border flex h-full w-full flex-col overflow-visible rounded-[20px] border bg-transparent', 'transition-[border-color,box-shadow,opacity] shadow-(--canvas-node-shadow-rest)', 'border-border', statusBorder, isHovered && 'shadow-(--canvas-node-shadow-hover)', isHovered && !hasStatusBorder && 'border-border-hover', selected && 'outline-2 outline-foreground-accent-muted', isDropTarget && 'bg-surface-hover outline-2 outline-brand', 'drag' === interactionState && 'cursor-grabbing shadow-(--canvas-node-shadow-lifted)'),
|
|
332
340
|
style: {
|
|
333
341
|
...nodeSizeStyle,
|
|
334
342
|
...display.background ? {
|
|
@@ -379,9 +387,9 @@ function LoopNodeComponent(props) {
|
|
|
379
387
|
onAddFirstChild: handleEmptyClick
|
|
380
388
|
})
|
|
381
389
|
}) : null,
|
|
382
|
-
|
|
390
|
+
effectiveToolbarConfig && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Toolbar_index_cjs_namespaceObject.NodeToolbar, {
|
|
383
391
|
nodeId: id,
|
|
384
|
-
config:
|
|
392
|
+
config: effectiveToolbarConfig,
|
|
385
393
|
expanded: selected || isHovered,
|
|
386
394
|
hidden: dragging || multipleNodesSelected,
|
|
387
395
|
portalToNodeOverlay: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoopNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNode.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoopNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNode.tsx"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAsInF,iBAAS,iBAAiB,CAAC,KAAK,EAAE,aAAa,2CAqS9C;AAED,eAAO,MAAM,QAAQ,+DAA6D,CAAC"}
|
|
@@ -16,6 +16,7 @@ import { areNodePropsEqualIgnoringPosition } from "../../utils/nodePropsEqual.js
|
|
|
16
16
|
import { resolveToolbar } from "../../utils/toolbar-resolver.js";
|
|
17
17
|
import { useBaseCanvasMode } from "../BaseCanvas/BaseCanvasModeProvider.js";
|
|
18
18
|
import { useConnectedHandles } from "../BaseCanvas/ConnectedHandlesContext.js";
|
|
19
|
+
import { useIsNodeReadOnly } from "../BaseCanvas/ReadOnlyNodesContext.js";
|
|
19
20
|
import { useSelectionState } from "../BaseCanvas/SelectionStateContext.js";
|
|
20
21
|
import { BaseBadgeSlot } from "../BaseNode/BaseNodeBadgeSlot.js";
|
|
21
22
|
import { getStatusBorder } from "../BaseNode/BaseNodeContainer.js";
|
|
@@ -23,6 +24,7 @@ import { MissingManifestNode } from "../BaseNode/BaseNodeMissingManifest.js";
|
|
|
23
24
|
import { ButtonHandles } from "../ButtonHandle/index.js";
|
|
24
25
|
import { CanvasTooltip } from "../CanvasTooltip.js";
|
|
25
26
|
import { NodeToolbar } from "../Toolbar/index.js";
|
|
27
|
+
import { lockToolbarConfig } from "../Toolbar/NodeToolbar/NodeToolbar.utils.js";
|
|
26
28
|
import { resolveContainerHandleGroups } from "./LoopNode.helpers.js";
|
|
27
29
|
import { LoopNodeExecutionCount } from "./LoopNodeExecutionCount.js";
|
|
28
30
|
const DEFAULT_LOOP_ICON = 'repeat';
|
|
@@ -145,6 +147,8 @@ function LoopNodeComponent(props) {
|
|
|
145
147
|
]);
|
|
146
148
|
const { mode } = useBaseCanvasMode();
|
|
147
149
|
const isDesignMode = 'design' === mode;
|
|
150
|
+
const isNodeReadOnly = useIsNodeReadOnly(id);
|
|
151
|
+
const canEditNode = isDesignMode && !isNodeReadOnly;
|
|
148
152
|
const connectedHandleIds = useConnectedHandles(id);
|
|
149
153
|
const { multipleNodesSelected } = useSelectionState();
|
|
150
154
|
const isConnecting = useStore(selectIsConnecting);
|
|
@@ -217,6 +221,10 @@ function LoopNodeComponent(props) {
|
|
|
217
221
|
statusContext,
|
|
218
222
|
toolbarConfigProp
|
|
219
223
|
]);
|
|
224
|
+
const effectiveToolbarConfig = useMemo(()=>toolbarConfig && isNodeReadOnly ? lockToolbarConfig(toolbarConfig) : toolbarConfig, [
|
|
225
|
+
toolbarConfig,
|
|
226
|
+
isNodeReadOnly
|
|
227
|
+
]);
|
|
220
228
|
const adornments = useMemo(()=>({
|
|
221
229
|
...resolveAdornments(statusContext, {
|
|
222
230
|
hideExecutionStatusAdornment: true
|
|
@@ -274,8 +282,8 @@ function LoopNodeComponent(props) {
|
|
|
274
282
|
setIsHovered(false);
|
|
275
283
|
}, []);
|
|
276
284
|
const shouldShowHandles = (isConnecting || selected || isHovered) && !dragging;
|
|
277
|
-
const showHandleAddButtons =
|
|
278
|
-
const showEmptyStateButton =
|
|
285
|
+
const showHandleAddButtons = canEditNode && !multipleNodesSelected && !isConnecting && !dragging;
|
|
286
|
+
const showEmptyStateButton = canEditNode && !hasChildNodes && !!onAddFirstChild;
|
|
279
287
|
const interactionState = resolveInteractionState(dragging, selected, isHovered);
|
|
280
288
|
const activeStatus = suggestionType ?? validationState?.validationStatus ?? executionStatus;
|
|
281
289
|
const statusBorder = getStatusBorder(activeStatus);
|
|
@@ -300,7 +308,7 @@ function LoopNodeComponent(props) {
|
|
|
300
308
|
"data-suggestion-type": suggestionType,
|
|
301
309
|
"data-validation-status": validationState?.validationStatus,
|
|
302
310
|
"aria-busy": resolvedData.loading || void 0,
|
|
303
|
-
className: cn('group/loop-shell relative box-border flex h-full w-full flex-col overflow-visible rounded-[20px] border bg-transparent', 'transition-[border-color,box-shadow,opacity] shadow-(--canvas-node-shadow-rest)', 'border-border', statusBorder, isHovered && 'shadow-(--canvas-node-shadow-hover)', isHovered && !hasStatusBorder && 'border-border-hover', selected && 'outline
|
|
311
|
+
className: cn('group/loop-shell relative box-border flex h-full w-full flex-col overflow-visible rounded-[20px] border bg-transparent', 'transition-[border-color,box-shadow,opacity] shadow-(--canvas-node-shadow-rest)', 'border-border', statusBorder, isHovered && 'shadow-(--canvas-node-shadow-hover)', isHovered && !hasStatusBorder && 'border-border-hover', selected && 'outline-2 outline-foreground-accent-muted', isDropTarget && 'bg-surface-hover outline-2 outline-brand', 'drag' === interactionState && 'cursor-grabbing shadow-(--canvas-node-shadow-lifted)'),
|
|
304
312
|
style: {
|
|
305
313
|
...nodeSizeStyle,
|
|
306
314
|
...display.background ? {
|
|
@@ -351,9 +359,9 @@ function LoopNodeComponent(props) {
|
|
|
351
359
|
onAddFirstChild: handleEmptyClick
|
|
352
360
|
})
|
|
353
361
|
}) : null,
|
|
354
|
-
|
|
362
|
+
effectiveToolbarConfig && /*#__PURE__*/ jsx(NodeToolbar, {
|
|
355
363
|
nodeId: id,
|
|
356
|
-
config:
|
|
364
|
+
config: effectiveToolbarConfig,
|
|
357
365
|
expanded: selected || isHovered,
|
|
358
366
|
hidden: dragging || multipleNodesSelected,
|
|
359
367
|
portalToNodeOverlay: true
|
|
@@ -31,6 +31,7 @@ const apollo_core_namespaceObject = require("@uipath/apollo-core");
|
|
|
31
31
|
const index_cjs_namespaceObject = require("../../layouts/index.cjs");
|
|
32
32
|
const external_react_namespaceObject = require("react");
|
|
33
33
|
const nodePropsEqual_cjs_namespaceObject = require("../../utils/nodePropsEqual.cjs");
|
|
34
|
+
const ReadOnlyNodesContext_cjs_namespaceObject = require("../BaseCanvas/ReadOnlyNodesContext.cjs");
|
|
34
35
|
const external_FloatingCanvasPanel_index_cjs_namespaceObject = require("../FloatingCanvasPanel/index.cjs");
|
|
35
36
|
const external_NodeContextMenu_index_cjs_namespaceObject = require("../NodeContextMenu/index.cjs");
|
|
36
37
|
const hooks_index_cjs_namespaceObject = require("../NodePropertiesPanel/hooks/index.cjs");
|
|
@@ -51,7 +52,7 @@ const StageNodeInner = (props)=>{
|
|
|
51
52
|
stageDetails?.tasks
|
|
52
53
|
]);
|
|
53
54
|
const isException = stageDetails?.isException;
|
|
54
|
-
const isReadOnly = !!stageDetails?.isReadOnly;
|
|
55
|
+
const isReadOnly = (0, ReadOnlyNodesContext_cjs_namespaceObject.useIsNodeReadOnly)(id) || !!stageDetails?.isReadOnly;
|
|
55
56
|
const selectedTaskId = stageDetails?.selectedTaskId;
|
|
56
57
|
const status = execution?.stageStatus?.status;
|
|
57
58
|
const [isHovered, setIsHovered] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -65,7 +66,7 @@ const StageNodeInner = (props)=>{
|
|
|
65
66
|
const [isAddingTask, setIsAddingTask] = (0, external_react_namespaceObject.useState)(false);
|
|
66
67
|
const [isReplacingTask, setIsReplacingTask] = (0, external_react_namespaceObject.useState)(false);
|
|
67
68
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
68
|
-
if (pendingReplaceTask) {
|
|
69
|
+
if (pendingReplaceTask && !isReadOnly) {
|
|
69
70
|
const match = allTasks.flatMap((group, gi)=>group.map((task, ti)=>({
|
|
70
71
|
task,
|
|
71
72
|
groupIndex: gi,
|
|
@@ -83,21 +84,22 @@ const StageNodeInner = (props)=>{
|
|
|
83
84
|
}, [
|
|
84
85
|
pendingReplaceTask,
|
|
85
86
|
selectedTaskId,
|
|
86
|
-
allTasks
|
|
87
|
+
allTasks,
|
|
88
|
+
isReadOnly
|
|
87
89
|
]);
|
|
88
90
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
89
|
-
if (false === selected) {
|
|
91
|
+
if (false === selected || isReadOnly) {
|
|
90
92
|
setIsAddingTask(false);
|
|
91
93
|
setIsReplacingTask(false);
|
|
92
94
|
}
|
|
93
95
|
}, [
|
|
94
|
-
selected
|
|
96
|
+
selected,
|
|
97
|
+
isReadOnly
|
|
95
98
|
]);
|
|
96
|
-
const shouldShowMenu = (0, external_react_namespaceObject.useMemo)(()=>menuItems && menuItems.length > 0 && (selected || isHovered)
|
|
99
|
+
const shouldShowMenu = (0, external_react_namespaceObject.useMemo)(()=>menuItems && menuItems.length > 0 && (selected || isHovered), [
|
|
97
100
|
menuItems,
|
|
98
101
|
selected,
|
|
99
|
-
isHovered
|
|
100
|
-
isReadOnly
|
|
102
|
+
isHovered
|
|
101
103
|
]);
|
|
102
104
|
const { setSelectedNodeId } = (0, hooks_index_cjs_namespaceObject.useSetNodeSelection)();
|
|
103
105
|
const handleStageClick = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
@@ -107,6 +109,7 @@ const StageNodeInner = (props)=>{
|
|
|
107
109
|
]);
|
|
108
110
|
const handleTaskAddClick = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
109
111
|
event.stopPropagation();
|
|
112
|
+
if (isReadOnly) return;
|
|
110
113
|
if (onTaskAdd) onTaskAdd();
|
|
111
114
|
else if (onAddTaskFromToolbox) setIsAddingTask(true);
|
|
112
115
|
setSelectedNodeId(id);
|
|
@@ -114,7 +117,8 @@ const StageNodeInner = (props)=>{
|
|
|
114
117
|
onTaskAdd,
|
|
115
118
|
onAddTaskFromToolbox,
|
|
116
119
|
setSelectedNodeId,
|
|
117
|
-
id
|
|
120
|
+
id,
|
|
121
|
+
isReadOnly
|
|
118
122
|
]);
|
|
119
123
|
const handleAddTaskToolboxItemSelected = (0, external_react_namespaceObject.useCallback)((item)=>{
|
|
120
124
|
onAddTaskFromToolbox?.(item);
|
|
@@ -190,7 +194,7 @@ const StageNodeInner = (props)=>{
|
|
|
190
194
|
})
|
|
191
195
|
]
|
|
192
196
|
}),
|
|
193
|
-
onAddTaskFromToolbox && isAddingTask && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FloatingCanvasPanel_index_cjs_namespaceObject.FloatingCanvasPanel, {
|
|
197
|
+
onAddTaskFromToolbox && isAddingTask && !isReadOnly && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FloatingCanvasPanel_index_cjs_namespaceObject.FloatingCanvasPanel, {
|
|
194
198
|
nodeId: id,
|
|
195
199
|
offset: 15,
|
|
196
200
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Toolbox_index_cjs_namespaceObject.Toolbox, {
|
|
@@ -201,7 +205,7 @@ const StageNodeInner = (props)=>{
|
|
|
201
205
|
onSearch: onTaskToolboxSearch
|
|
202
206
|
})
|
|
203
207
|
}),
|
|
204
|
-
onReplaceTaskFromToolbox && isReplacingTask && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FloatingCanvasPanel_index_cjs_namespaceObject.FloatingCanvasPanel, {
|
|
208
|
+
onReplaceTaskFromToolbox && isReplacingTask && !isReadOnly && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FloatingCanvasPanel_index_cjs_namespaceObject.FloatingCanvasPanel, {
|
|
205
209
|
nodeId: id,
|
|
206
210
|
offset: 15,
|
|
207
211
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Toolbox_index_cjs_namespaceObject.Toolbox, {
|
|
@@ -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":"AAkBA,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,mBAAmB,CAAC;AAiN5E,eAAO,MAAM,SAAS,8CA3MS,cAAc,6CA2MmC,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { Spacing } from "@uipath/apollo-core";
|
|
|
3
3
|
import { Column } from "../../layouts/index.js";
|
|
4
4
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { areNodePropsEqualIgnoringPosition } from "../../utils/nodePropsEqual.js";
|
|
6
|
+
import { useIsNodeReadOnly } from "../BaseCanvas/ReadOnlyNodesContext.js";
|
|
6
7
|
import { FloatingCanvasPanel } from "../FloatingCanvasPanel/index.js";
|
|
7
8
|
import { NodeContextMenu } from "../NodeContextMenu/index.js";
|
|
8
9
|
import { useSetNodeSelection } from "../NodePropertiesPanel/hooks/index.js";
|
|
@@ -23,7 +24,7 @@ const StageNodeInner = (props)=>{
|
|
|
23
24
|
stageDetails?.tasks
|
|
24
25
|
]);
|
|
25
26
|
const isException = stageDetails?.isException;
|
|
26
|
-
const isReadOnly = !!stageDetails?.isReadOnly;
|
|
27
|
+
const isReadOnly = useIsNodeReadOnly(id) || !!stageDetails?.isReadOnly;
|
|
27
28
|
const selectedTaskId = stageDetails?.selectedTaskId;
|
|
28
29
|
const status = execution?.stageStatus?.status;
|
|
29
30
|
const [isHovered, setIsHovered] = useState(false);
|
|
@@ -37,7 +38,7 @@ const StageNodeInner = (props)=>{
|
|
|
37
38
|
const [isAddingTask, setIsAddingTask] = useState(false);
|
|
38
39
|
const [isReplacingTask, setIsReplacingTask] = useState(false);
|
|
39
40
|
useEffect(()=>{
|
|
40
|
-
if (pendingReplaceTask) {
|
|
41
|
+
if (pendingReplaceTask && !isReadOnly) {
|
|
41
42
|
const match = allTasks.flatMap((group, gi)=>group.map((task, ti)=>({
|
|
42
43
|
task,
|
|
43
44
|
groupIndex: gi,
|
|
@@ -55,21 +56,22 @@ const StageNodeInner = (props)=>{
|
|
|
55
56
|
}, [
|
|
56
57
|
pendingReplaceTask,
|
|
57
58
|
selectedTaskId,
|
|
58
|
-
allTasks
|
|
59
|
+
allTasks,
|
|
60
|
+
isReadOnly
|
|
59
61
|
]);
|
|
60
62
|
useEffect(()=>{
|
|
61
|
-
if (false === selected) {
|
|
63
|
+
if (false === selected || isReadOnly) {
|
|
62
64
|
setIsAddingTask(false);
|
|
63
65
|
setIsReplacingTask(false);
|
|
64
66
|
}
|
|
65
67
|
}, [
|
|
66
|
-
selected
|
|
68
|
+
selected,
|
|
69
|
+
isReadOnly
|
|
67
70
|
]);
|
|
68
|
-
const shouldShowMenu = useMemo(()=>menuItems && menuItems.length > 0 && (selected || isHovered)
|
|
71
|
+
const shouldShowMenu = useMemo(()=>menuItems && menuItems.length > 0 && (selected || isHovered), [
|
|
69
72
|
menuItems,
|
|
70
73
|
selected,
|
|
71
|
-
isHovered
|
|
72
|
-
isReadOnly
|
|
74
|
+
isHovered
|
|
73
75
|
]);
|
|
74
76
|
const { setSelectedNodeId } = useSetNodeSelection();
|
|
75
77
|
const handleStageClick = useCallback(()=>{
|
|
@@ -79,6 +81,7 @@ const StageNodeInner = (props)=>{
|
|
|
79
81
|
]);
|
|
80
82
|
const handleTaskAddClick = useCallback((event)=>{
|
|
81
83
|
event.stopPropagation();
|
|
84
|
+
if (isReadOnly) return;
|
|
82
85
|
if (onTaskAdd) onTaskAdd();
|
|
83
86
|
else if (onAddTaskFromToolbox) setIsAddingTask(true);
|
|
84
87
|
setSelectedNodeId(id);
|
|
@@ -86,7 +89,8 @@ const StageNodeInner = (props)=>{
|
|
|
86
89
|
onTaskAdd,
|
|
87
90
|
onAddTaskFromToolbox,
|
|
88
91
|
setSelectedNodeId,
|
|
89
|
-
id
|
|
92
|
+
id,
|
|
93
|
+
isReadOnly
|
|
90
94
|
]);
|
|
91
95
|
const handleAddTaskToolboxItemSelected = useCallback((item)=>{
|
|
92
96
|
onAddTaskFromToolbox?.(item);
|
|
@@ -162,7 +166,7 @@ const StageNodeInner = (props)=>{
|
|
|
162
166
|
})
|
|
163
167
|
]
|
|
164
168
|
}),
|
|
165
|
-
onAddTaskFromToolbox && isAddingTask && /*#__PURE__*/ jsx(FloatingCanvasPanel, {
|
|
169
|
+
onAddTaskFromToolbox && isAddingTask && !isReadOnly && /*#__PURE__*/ jsx(FloatingCanvasPanel, {
|
|
166
170
|
nodeId: id,
|
|
167
171
|
offset: 15,
|
|
168
172
|
children: /*#__PURE__*/ jsx(Toolbox, {
|
|
@@ -173,7 +177,7 @@ const StageNodeInner = (props)=>{
|
|
|
173
177
|
onSearch: onTaskToolboxSearch
|
|
174
178
|
})
|
|
175
179
|
}),
|
|
176
|
-
onReplaceTaskFromToolbox && isReplacingTask && /*#__PURE__*/ jsx(FloatingCanvasPanel, {
|
|
180
|
+
onReplaceTaskFromToolbox && isReplacingTask && !isReadOnly && /*#__PURE__*/ jsx(FloatingCanvasPanel, {
|
|
177
181
|
nodeId: id,
|
|
178
182
|
offset: 15,
|
|
179
183
|
children: /*#__PURE__*/ jsx(Toolbox, {
|
|
@@ -52,9 +52,11 @@ const index_cjs_namespaceObject = require("../../../i18n/index.cjs");
|
|
|
52
52
|
const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
53
53
|
const useLatestRef_cjs_namespaceObject = require("../../hooks/useLatestRef.cjs");
|
|
54
54
|
const nodePropsEqual_cjs_namespaceObject = require("../../utils/nodePropsEqual.cjs");
|
|
55
|
+
const ReadOnlyNodesContext_cjs_namespaceObject = require("../BaseCanvas/ReadOnlyNodesContext.cjs");
|
|
55
56
|
const SelectionStateContext_cjs_namespaceObject = require("../BaseCanvas/SelectionStateContext.cjs");
|
|
56
57
|
const external_NodeViewportOverlay_cjs_namespaceObject = require("../NodeViewportOverlay.cjs");
|
|
57
58
|
const external_Toolbar_index_cjs_namespaceObject = require("../Toolbar/index.cjs");
|
|
59
|
+
const NodeToolbar_utils_cjs_namespaceObject = require("../Toolbar/NodeToolbar/NodeToolbar.utils.cjs");
|
|
58
60
|
const external_FormattingToolbar_cjs_namespaceObject = require("./FormattingToolbar.cjs");
|
|
59
61
|
const external_markdown_formatting_index_cjs_namespaceObject = require("./markdown-formatting/index.cjs");
|
|
60
62
|
const external_StickyNoteCanvasOptionsContext_cjs_namespaceObject = require("./StickyNoteCanvasOptionsContext.cjs");
|
|
@@ -71,7 +73,9 @@ const minHeight = 8 * external_constants_cjs_namespaceObject.GRID_SPACING;
|
|
|
71
73
|
const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly: readOnlyProp, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, enableMediaEmbedding: enableMediaEmbeddingProp, formattingActions, markdownComponents: customMarkdownComponents })=>{
|
|
72
74
|
const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
|
|
73
75
|
const canvasOptions = (0, external_StickyNoteCanvasOptionsContext_cjs_namespaceObject.useStickyNoteCanvasOptions)();
|
|
74
|
-
const
|
|
76
|
+
const isNodeReadOnly = (0, ReadOnlyNodesContext_cjs_namespaceObject.useIsNodeReadOnly)(id);
|
|
77
|
+
const stickyNoteReadOnly = readOnlyProp ?? canvasOptions.readOnly;
|
|
78
|
+
const readOnly = isNodeReadOnly || stickyNoteReadOnly;
|
|
75
79
|
const enableMediaEmbedding = enableMediaEmbeddingProp ?? canvasOptions.enableMediaEmbedding;
|
|
76
80
|
const { updateNodeData, deleteElements } = (0, react_cjs_namespaceObject.useReactFlow)();
|
|
77
81
|
const { multipleNodesSelected } = (0, SelectionStateContext_cjs_namespaceObject.useSelectionState)();
|
|
@@ -85,6 +89,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
85
89
|
const formattingToolbarRef = (0, external_react_namespaceObject.useRef)(null);
|
|
86
90
|
const skipBlurRef = (0, external_react_namespaceObject.useRef)(null);
|
|
87
91
|
const resizeActiveRef = (0, external_react_namespaceObject.useRef)(false);
|
|
92
|
+
const readOnlyRef = (0, useLatestRef_cjs_namespaceObject.useLatestRef)(readOnly);
|
|
88
93
|
const resizeLifecycle = {
|
|
89
94
|
content: data.content,
|
|
90
95
|
id,
|
|
@@ -155,6 +160,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
155
160
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
156
161
|
if (readOnly) {
|
|
157
162
|
setIsEditing(false);
|
|
163
|
+
setIsColorPickerOpen(false);
|
|
158
164
|
updateLocalContent(data.content || '');
|
|
159
165
|
}
|
|
160
166
|
}, [
|
|
@@ -224,6 +230,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
224
230
|
skipBlurRef.current = selection.value;
|
|
225
231
|
let completed = false;
|
|
226
232
|
const restoreSelection = (next)=>{
|
|
233
|
+
if (readOnlyRef.current) return;
|
|
227
234
|
setIsEditing(true);
|
|
228
235
|
requestAnimationFrame(()=>{
|
|
229
236
|
const currentTextarea = textAreaRef.current;
|
|
@@ -237,6 +244,10 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
237
244
|
const complete = (next, shouldPersist)=>{
|
|
238
245
|
if (completed) return;
|
|
239
246
|
completed = true;
|
|
247
|
+
if (readOnlyRef.current) {
|
|
248
|
+
skipBlurRef.current = null;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
240
251
|
skipBlurRef.current = shouldPersist ? next.value : null;
|
|
241
252
|
setActiveFormats((0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)(next));
|
|
242
253
|
if (shouldPersist) {
|
|
@@ -273,6 +284,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
273
284
|
}, [
|
|
274
285
|
id,
|
|
275
286
|
onContentChange,
|
|
287
|
+
readOnlyRef,
|
|
276
288
|
updateLocalContent,
|
|
277
289
|
updateNodeData
|
|
278
290
|
]);
|
|
@@ -437,6 +449,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
437
449
|
resizeLifecycleRef
|
|
438
450
|
]);
|
|
439
451
|
const handleColorChange = (0, external_react_namespaceObject.useCallback)((newColor)=>{
|
|
452
|
+
if (readOnly) return;
|
|
440
453
|
onColorChange?.(newColor);
|
|
441
454
|
updateNodeData(id, {
|
|
442
455
|
color: newColor
|
|
@@ -445,11 +458,15 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
445
458
|
}, [
|
|
446
459
|
id,
|
|
447
460
|
updateNodeData,
|
|
448
|
-
onColorChange
|
|
461
|
+
onColorChange,
|
|
462
|
+
readOnly
|
|
449
463
|
]);
|
|
450
464
|
const handleToggleColorPicker = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
465
|
+
if (readOnly) return;
|
|
451
466
|
setIsColorPickerOpen((prev)=>!prev);
|
|
452
|
-
}, [
|
|
467
|
+
}, [
|
|
468
|
+
readOnly
|
|
469
|
+
]);
|
|
453
470
|
const handleEditClick = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
454
471
|
if (readOnly) return;
|
|
455
472
|
setIsEditing(true);
|
|
@@ -463,6 +480,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
463
480
|
readOnly
|
|
464
481
|
]);
|
|
465
482
|
const handleDelete = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
483
|
+
if (readOnly) return;
|
|
466
484
|
deleteElements({
|
|
467
485
|
nodes: [
|
|
468
486
|
{
|
|
@@ -472,7 +490,8 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
472
490
|
});
|
|
473
491
|
}, [
|
|
474
492
|
id,
|
|
475
|
-
deleteElements
|
|
493
|
+
deleteElements,
|
|
494
|
+
readOnly
|
|
476
495
|
]);
|
|
477
496
|
const builtInMarkdownComponents = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
478
497
|
a: ({ node: _node, href, children, ...props })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
|
|
@@ -580,7 +599,11 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
580
599
|
color,
|
|
581
600
|
handleDelete
|
|
582
601
|
]);
|
|
583
|
-
const
|
|
602
|
+
const effectiveToolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>isNodeReadOnly ? (0, NodeToolbar_utils_cjs_namespaceObject.lockToolbarConfig)(toolbarConfig) : toolbarConfig, [
|
|
603
|
+
isNodeReadOnly,
|
|
604
|
+
toolbarConfig
|
|
605
|
+
]);
|
|
606
|
+
const shouldRenderToolbarOverlay = !stickyNoteReadOnly && selected && !dragging && !isResizing && !multipleNodesSelected;
|
|
584
607
|
const shouldRenderResizeControls = !readOnly || isResizing;
|
|
585
608
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
586
609
|
children: [
|
|
@@ -727,7 +750,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
|
|
|
727
750
|
}),
|
|
728
751
|
shouldRenderToolbarOverlay && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Toolbar_index_cjs_namespaceObject.NodeToolbar, {
|
|
729
752
|
nodeId: id,
|
|
730
|
-
config:
|
|
753
|
+
config: effectiveToolbarConfig,
|
|
731
754
|
expanded: true,
|
|
732
755
|
portalToNodeOverlay: true
|
|
733
756
|
}),
|