From affdc0c3cdd7e35be5c99d5d9c5756c063f5583d Mon Sep 17 00:00:00 2001 From: JGerla Date: Wed, 1 Oct 2025 13:45:20 +0200 Subject: [PATCH] feat: modified DnD sidebar to provide different node types Modified the drag and drop sidebar to create a node of the correct type instead of creating only default nodes, regardless of specified node types for a respective option. ref: N25B-114 --- .../components/DragDropSidebar.tsx | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/visualProgrammingUI/components/DragDropSidebar.tsx b/src/visualProgrammingUI/components/DragDropSidebar.tsx index 9c1e3dd..219e3a2 100644 --- a/src/visualProgrammingUI/components/DragDropSidebar.tsx +++ b/src/visualProgrammingUI/components/DragDropSidebar.tsx @@ -72,14 +72,41 @@ export function Sidebar() { if (isInFlow) { const position = screenToFlowPosition(screenPosition); - const newNode = { - id: getId(), - type: nodeType, - position, - data: { label: `${nodeType} node` }, - }; + const newNode = () => { + switch (nodeType) { + case "phase": + return { + id: getId(), + type: nodeType, + position, + data: {label: `"new"`, number: (-1)}, + }; + case "start": + return { + id: getId(), + type: nodeType, + position, + data: {label: `new start node`}, + }; + case "end": + return { + id: getId(), + type: nodeType, + position, + data: {label: `new end node`}, + }; + default: { + return { + id: getId(), + type: nodeType, + position, + data: {label: `new default node`}, + }; + } + } + } - setNodes((nds) => nds.concat(newNode)); + setNodes((nds) => nds.concat(newNode())); } }, [setNodes, screenToFlowPosition],