@@ -17,7 +17,7 @@ import {
1717 useStoreApi ,
1818 type XYPosition ,
1919} from "@xyflow/react" ;
20- import type { ComponentType , DragEvent } from "react" ;
20+ import type { DragEvent } from "react" ;
2121import { useEffect , useRef , useState } from "react" ;
2222
2323import { ConfirmationDialog } from "@/components/shared/Dialogs" ;
@@ -55,47 +55,38 @@ import { getBulkUpdateConfirmationDetails } from "./ConfirmationDialogs/BulkUpda
5555import { getDeleteConfirmationDetails } from "./ConfirmationDialogs/DeleteConfirmation" ;
5656import { getReplaceConfirmationDetails } from "./ConfirmationDialogs/ReplaceConfirmation" ;
5757import { ConnectionLine } from "./Edges/ConnectionLine" ;
58- import SmoothEdge from "./Edges/SmoothEdge" ;
59- import GhostNode from "./GhostNode/GhostNode" ;
6058import type { GhostNodeData } from "./GhostNode/types" ;
6159import {
6260 computeDropPositionFromRefs ,
6361 createGhostEdge ,
6462} from "./GhostNode/utils" ;
65- import IONode from "./IONode/IONode" ;
6663import SelectionToolbar from "./SelectionToolbar" ;
6764import { handleGroupNodes } from "./Subgraphs/create/handleGroupNodes" ;
6865import { NewSubgraphDialog } from "./Subgraphs/create/NewSubgraphDialog" ;
6966import { canGroupNodes } from "./Subgraphs/create/utils" ;
7067import { SubgraphBreadcrumbs } from "./Subgraphs/view/SubgraphBreadcrumbs" ;
71- import TaskNode from "./TaskNode/TaskNode" ;
72- import type { NodesAndEdges } from "./types" ;
68+ import {
69+ edgeTypes ,
70+ isTaskNodeType ,
71+ type NodesAndEdges ,
72+ nodeTypes ,
73+ } from "./types" ;
7374import addTask from "./utils/addTask" ;
7475import { createConnectedIONode } from "./utils/createConnectedIONode" ;
7576import { duplicateNodes } from "./utils/duplicateNodes" ;
7677import { isPositionInNode } from "./utils/geometry" ;
78+ import { getNodeFromEvent } from "./utils/getNodeFromEvent" ;
7779import { getPositionFromEvent } from "./utils/getPositionFromEvent" ;
78- import { getTaskFromEvent } from "./utils/getTaskFromEvent" ;
7980import { handleConnection } from "./utils/handleConnection" ;
8081import { removeEdge } from "./utils/removeEdge" ;
8182import { removeNode } from "./utils/removeNode" ;
8283import { replaceTaskNode } from "./utils/replaceTaskNode" ;
8384import { updateNodePositions } from "./utils/updateNodePosition" ;
8485
85- const nodeTypes : Record < string , ComponentType < any > > = {
86- task : TaskNode ,
87- input : IONode ,
88- output : IONode ,
89- ghost : GhostNode ,
90- } ;
91-
9286const SELECTABLE_NODES = new Set ( [ "task" , "input" , "output" ] ) ;
9387const UPGRADEABLE_NODES = new Set ( [ "task" ] ) ;
9488const REPLACEABLE_NODES = new Set ( [ "task" ] ) ;
95-
96- const edgeTypes : Record < string , ComponentType < any > > = {
97- customEdge : SmoothEdge ,
98- } ;
89+ const FAST_PLACE_NODE_TYPES = new Set < Node [ "type" ] > ( [ "task" ] ) ;
9990
10091const useScheduleExecutionOnceWhenConditionMet = (
10192 condition : boolean ,
@@ -110,8 +101,6 @@ const useScheduleExecutionOnceWhenConditionMet = (
110101 } , [ condition , callback ] ) ;
111102} ;
112103
113- const FAST_PLACE_NODE_TYPES = new Set < Node [ "type" ] > ( [ "task" ] ) ;
114-
115104const FlowCanvas = ( {
116105 readOnly,
117106 nodesConnectable,
@@ -362,7 +351,11 @@ const FlowCanvas = ({
362351 currentSubgraphPath ,
363352 notify ,
364353 ) ;
365- const newNodes = createNodesFromComponentSpec ( subgraphSpec , nodeData ) ;
354+ const newNodes = createNodesFromComponentSpec (
355+ subgraphSpec ,
356+ nodeData ,
357+ readOnly ,
358+ ) ;
366359
367360 const updatedNewNodes = newNodes . map ( ( node ) => ( {
368361 ...node ,
@@ -561,14 +554,19 @@ const FlowCanvas = ({
561554 return ;
562555 }
563556
564- const { taskSpec : droppedTask , taskType } = getTaskFromEvent ( event ) ;
557+ const { spec : droppedTask , nodeType } = getNodeFromEvent ( event ) ;
558+
559+ if ( ! nodeType ) {
560+ console . error ( "Dropped node type not identified." ) ;
561+ return ;
562+ }
565563
566- if ( ! taskType ) {
567- console . error ( "Dropped task type not identified." ) ;
564+ if ( ! isTaskNodeType ( nodeType ) ) {
565+ console . error ( "Dropped node type is not supported:" , nodeType ) ;
568566 return ;
569567 }
570568
571- if ( ! droppedTask && taskType === "task" ) {
569+ if ( ! droppedTask && nodeType === "task" ) {
572570 console . error ( "Unable to find dropped task." ) ;
573571 return ;
574572 }
@@ -626,7 +624,7 @@ const FlowCanvas = ({
626624 const position = getPositionFromEvent ( event , reactFlowInstance ) ;
627625
628626 const { spec : newSubgraphSpec } = addTask (
629- taskType ,
627+ nodeType ,
630628 droppedTask ,
631629 position ,
632630 currentSubgraphSpec ,
0 commit comments