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
This commit is contained in:
@@ -72,14 +72,41 @@ export function Sidebar() {
|
|||||||
if (isInFlow) {
|
if (isInFlow) {
|
||||||
const position = screenToFlowPosition(screenPosition);
|
const position = screenToFlowPosition(screenPosition);
|
||||||
|
|
||||||
const newNode = {
|
const newNode = () => {
|
||||||
id: getId(),
|
switch (nodeType) {
|
||||||
type: nodeType,
|
case "phase":
|
||||||
position,
|
return {
|
||||||
data: { label: `${nodeType} node` },
|
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],
|
[setNodes, screenToFlowPosition],
|
||||||
|
|||||||
Reference in New Issue
Block a user