From 650f73681dd41797587cf8e55b18cfb2fe487b0f Mon Sep 17 00:00:00 2001 From: Valentina Vallalta <125534835+valentina-vallalta@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:08:10 -0700 Subject: [PATCH] fix(Consumption): Changing parent ID for subgraph nodes (#4395) * changing parent ID to scope node fron subgraph nodes --- libs/designer/src/lib/ui/connections/dropzone.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/designer/src/lib/ui/connections/dropzone.tsx b/libs/designer/src/lib/ui/connections/dropzone.tsx index 7655c8ac8d4..782855af63c 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'; @@ -116,7 +116,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 the 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]);