From 6c56d1df28bc75fc7afbb8fd99c7ff3284d67bef Mon Sep 17 00:00:00 2001 From: Jesus Rocha Date: Mon, 12 Dec 2022 13:09:44 -0800 Subject: [PATCH] union node validation ensures upstream attributes match Union node name Signed-off-by: Jesus Rocha --- src/utils/validation/UnionNode.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/utils/validation/UnionNode.js b/src/utils/validation/UnionNode.js index a542f90..698fb2b 100644 --- a/src/utils/validation/UnionNode.js +++ b/src/utils/validation/UnionNode.js @@ -40,6 +40,13 @@ export default class UnionNode { error: 'The Union upstream nodes require attributes aligned', }; } + if (this.upstreamAttributeNameAligned()) { + return { + isValid: false, + error: + 'The Union upstream nodes require attribute to be equal to Union name', + }; + } return { isValid: true }; } @@ -67,6 +74,22 @@ export default class UnionNode { }); return isInvalidAttributes; } + upstreamAttributeNameAligned() { + const pipelineLinks = this.canvasController.getLinks(this.pipelineId); + const upstreamNodes = getImmediateUpstreamNodes( + this.nodeProps.nodeId, + pipelineLinks, + ); + let isInvalidAttribute = false; + const uNode = this.nodes.find((no) => no.nodeId === this.nodeProps.nodeId); + upstreamNodes.forEach((n, i) => { + const node = this.nodes.find((no) => no.nodeId === n); + if (uNode.label !== node.renamed) { + isInvalidAttribute = true; + } + }); + return isInvalidAttribute; + } checkCardinality(nodeId) { const inputPorts = this.canvasController.getNodeInputPorts( nodeId,