Skip to content

Commit

Permalink
fix(Consumption): Changing parent ID for subgraph nodes (#4395)
Browse files Browse the repository at this point in the history
* changing parent ID to scope node fron subgraph nodes
  • Loading branch information
valentina-vallalta authored Mar 20, 2024
1 parent 3ea0d3a commit 650f736
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions libs/designer/src/lib/ui/connections/dropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -116,7 +116,16 @@ export const DropZone: React.FC<DropZoneProps> = ({ 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]);

Expand Down

0 comments on commit 650f736

Please sign in to comment.