From 7d7a980e7caafab16f24316d19efd63c255f558b Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 29 Jan 2024 16:33:29 -0300 Subject: [PATCH] Fix selection validation and error message --- src/frontend/src/utils/reactflowUtils.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 008de0378..94bd9d6dc 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -677,6 +677,7 @@ export function validateSelection( if (selection.edges.length === 0) { selection.edges = edges; } + // get only edges that are connected to the nodes in the selection // first creates a set of all the nodes ids let nodesSet = new Set(selection.nodes.map((n) => n.id)); @@ -692,7 +693,17 @@ export function validateSelection( if (selection.nodes.length < 2) { errorsArray.push("Please select more than one node"); } - + if ( + selection.nodes.some( + (node) => + isInputNode(node.data as NodeDataType) || + isOutputNode(node.data as NodeDataType) + ) + ) { + errorsArray.push( + "Please select only nodes that are not input or output nodes" + ); + } //check if there are two or more nodes with free outputs if ( selection.nodes.filter(