From 828854215c684b1d9a015bd68db35d8303d0267c Mon Sep 17 00:00:00 2001 From: Tyler Ohlsen Date: Wed, 4 Oct 2023 15:23:23 -0700 Subject: [PATCH] Clean up isValidConnection Signed-off-by: Tyler Ohlsen --- .../workflow_detail/workspace_component/utils.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/public/pages/workflow_detail/workspace_component/utils.ts b/public/pages/workflow_detail/workspace_component/utils.ts index fe968539..fc424e8b 100644 --- a/public/pages/workflow_detail/workspace_component/utils.ts +++ b/public/pages/workflow_detail/workspace_component/utils.ts @@ -32,19 +32,23 @@ export function isValidConnection( const sourceHandle = connection.sourceHandle; const targetHandle = connection.targetHandle; const targetNodeId = connection.target; - const inputClass = sourceHandle || ''; + // We store the output classes in a pipe-delimited string. Converting back to a list. - const outputClasses = targetHandle?.split('|') || []; + const sourceClasses = sourceHandle?.split('|') || []; + const targetClass = targetHandle || ''; - if (outputClasses?.includes(inputClass)) { + if (sourceClasses?.includes(targetClass)) { const targetNode = rfInstance.getNode(targetNodeId || ''); if (targetNode) { const inputConfig = targetNode.data.inputs.find( - (input: IComponentInput) => input.baseClass === inputClass + (input: IComponentInput) => sourceClasses.includes(input.baseClass) ) as IComponentInput; const existingEdge = rfInstance .getEdges() - .find((edge) => edge.targetHandle === targetHandle); + .find( + (edge) => + edge.target === targetNodeId && edge.targetHandle === targetHandle + ); if (existingEdge && inputConfig.acceptMultiple === false) { return false; }