Handle users of env config nodes when adding/removing subflow node

This commit is contained in:
GogoVega 2024-11-07 21:58:11 +01:00
parent 54bf3f4402
commit 3d9bc265dd
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B

View File

@ -809,6 +809,20 @@ RED.nodes = (function() {
if (sf) {
sf.instances.splice(sf.instances.indexOf(node),1);
}
node.env?.forEach((prop) => {
if (prop.type === "conf-type" && prop.value) {
// Remove the node from the config node users
const configNode = getNode(prop.value);
if (configNode) {
if (configNode.users.indexOf(node) !== -1) {
configNode.users.splice(configNode.users.indexOf(node), 1);
RED.events.emit('nodes:change', configNode);
updatedConfigNode = true;
}
}
}
});
}
if (updatedConfigNode) {
@ -2684,6 +2698,22 @@ RED.nodes = (function() {
}
}
}
// Subflows can have config node env
if (n.type.indexOf("subflow:") === 0) {
n.env?.forEach((prop) => {
if (prop.type === "conf-type" && prop.value) {
// Add the node to the config node users
const configNode = getNode(prop.value);
if (configNode) {
if (configNode.users.indexOf(n) === -1) {
configNode.users.push(n);
RED.events.emit('nodes:change', configNode);
}
}
}
});
}
}
function flowVersion(version) {