From 8f264a248aab6e6b0d209b53bd053eb20437df4a Mon Sep 17 00:00:00 2001 From: Valentina Vallalta Date: Wed, 20 Mar 2024 09:53:13 -0700 Subject: [PATCH 1/3] changing parent ID to scope node fron subgraph nodes --- libs/designer/src/lib/ui/connections/dropzone.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libs/designer/src/lib/ui/connections/dropzone.tsx b/libs/designer/src/lib/ui/connections/dropzone.tsx index c8920022424..0d3362d7aeb 100644 --- a/libs/designer/src/lib/ui/connections/dropzone.tsx +++ b/libs/designer/src/lib/ui/connections/dropzone.tsx @@ -2,7 +2,7 @@ import type { AppDispatch } from '../../core'; import { pasteOperation } from '../../core/actions/bjsworkflow/copypaste'; import { expandDiscoveryPanel } from '../../core/state/panel/panelSlice'; import { useUpstreamNodes } from '../../core/state/tokens/tokenSelectors'; -import { useGetAllOperationNodesWithin, useNodeDisplayName } from '../../core/state/workflow/workflowSelectors'; +import { useGetAllOperationNodesWithin, useNodeDisplayName, useNodeMetadata } from '../../core/state/workflow/workflowSelectors'; import { AllowDropTarget } from './dynamicsvgs/allowdroptarget'; import { BlockDropTarget } from './dynamicsvgs/blockdroptarget'; import { MenuDivider, MenuItem, MenuList, Popover, PopoverSurface, PopoverTrigger } from '@fluentui/react-components'; @@ -113,7 +113,16 @@ export const DropZone: React.FC = ({ graphId, parentId, childId, setShowCallout(false); }, [dispatch, graphId, parentId]); - const upstreamNodesOfChild = useUpstreamNodes(removeIdTag(childId ?? parentId ?? graphId)); + const nodeMetadata = useNodeMetadata(removeIdTag(parentId ?? '')); + // For subgraph nodes, we want to use the id of the scope node as thr parentId to get the dependancies + const newParentId = useMemo(() => { + if (nodeMetadata?.subgraphType) { + return nodeMetadata.parentNodeId; + } else { + return parentId; + } + }, [nodeMetadata, parentId]); + const upstreamNodesOfChild = useUpstreamNodes(removeIdTag(childId ?? newParentId ?? graphId)); const immediateAncestor = useGetAllOperationNodesWithin(parentId && !containsIdTag(parentId) ? parentId : ''); const upstreamNodes = useMemo(() => new Set([...upstreamNodesOfChild, ...immediateAncestor]), [immediateAncestor, upstreamNodesOfChild]); @@ -123,6 +132,7 @@ export const DropZone: React.FC = ({ graphId, parentId, childId, drop: () => ({ graphId, parentId, childId }), canDrop: (item: { id: string; dependencies?: string[]; graphId?: string }) => { // This supports preventing moving a node with a dependency above its upstream node + console.log('### id', { dependency: item.dependencies, upstreamNodes, parentId, childId, graphId }); for (const dec of item.dependencies ?? []) { if (!upstreamNodes.has(dec)) { return false; From 86f5d401fd33be764fd5918668ed0643416d1328 Mon Sep 17 00:00:00 2001 From: Valentina Vallalta Date: Wed, 20 Mar 2024 10:20:16 -0700 Subject: [PATCH 2/3] removing print statement --- libs/designer/src/lib/ui/connections/dropzone.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/designer/src/lib/ui/connections/dropzone.tsx b/libs/designer/src/lib/ui/connections/dropzone.tsx index 0d3362d7aeb..79f4244b66d 100644 --- a/libs/designer/src/lib/ui/connections/dropzone.tsx +++ b/libs/designer/src/lib/ui/connections/dropzone.tsx @@ -132,7 +132,6 @@ export const DropZone: React.FC = ({ graphId, parentId, childId, drop: () => ({ graphId, parentId, childId }), canDrop: (item: { id: string; dependencies?: string[]; graphId?: string }) => { // This supports preventing moving a node with a dependency above its upstream node - console.log('### id', { dependency: item.dependencies, upstreamNodes, parentId, childId, graphId }); for (const dec of item.dependencies ?? []) { if (!upstreamNodes.has(dec)) { return false; From 4cda143beaf2f04a2f288f4c8c04f726ecb37b01 Mon Sep 17 00:00:00 2001 From: Valentina Vallalta Date: Wed, 20 Mar 2024 11:43:44 -0700 Subject: [PATCH 3/3] fixing typo --- libs/designer/src/lib/ui/connections/dropzone.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/designer/src/lib/ui/connections/dropzone.tsx b/libs/designer/src/lib/ui/connections/dropzone.tsx index 79f4244b66d..233350049a3 100644 --- a/libs/designer/src/lib/ui/connections/dropzone.tsx +++ b/libs/designer/src/lib/ui/connections/dropzone.tsx @@ -114,7 +114,7 @@ export const DropZone: React.FC = ({ graphId, parentId, childId, }, [dispatch, graphId, parentId]); const nodeMetadata = useNodeMetadata(removeIdTag(parentId ?? '')); - // For subgraph nodes, we want to use the id of the scope node as thr parentId to get the dependancies + // For subgraph nodes, we want to use the id of the scope node as the parentId to get the dependancies const newParentId = useMemo(() => { if (nodeMetadata?.subgraphType) { return nodeMetadata.parentNodeId;