mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Handle users of env config nodes when saving subflow node config
This commit is contained in:
parent
3d9bc265dd
commit
f2d72b1050
@ -20,10 +20,31 @@
|
||||
apply: function(editState) {
|
||||
var old_env = node.env;
|
||||
var new_env = [];
|
||||
|
||||
if (/^subflow:/.test(node.type)) {
|
||||
// Get the list of environment variables from the node properties
|
||||
new_env = RED.subflow.exportSubflowInstanceEnv(node);
|
||||
}
|
||||
|
||||
if (old_env && old_env.length) {
|
||||
old_env.forEach(function (prop) {
|
||||
if (prop.type === "conf-type" && prop.value) {
|
||||
const stillInUse = new_env?.some((p) => p.type === "conf-type" && p.name === prop.name && p.value === prop.value);
|
||||
if (!stillInUse) {
|
||||
// Remove the node from the config node users
|
||||
// Only for empty value or modified
|
||||
const configNode = RED.nodes.node(prop.value);
|
||||
if (configNode) {
|
||||
if (configNode.users.indexOf(node) !== -1) {
|
||||
configNode.users.splice(configNode.users.indexOf(node), 1);
|
||||
RED.events.emit('nodes:change', configNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Get the values from the Properties table tab
|
||||
var items = this.list.editableList('items');
|
||||
items.each(function (i,el) {
|
||||
@ -41,7 +62,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (new_env && new_env.length > 0) {
|
||||
new_env.forEach(function(prop) {
|
||||
if (prop.type === "cred") {
|
||||
@ -52,6 +72,15 @@
|
||||
editState.changed = true;
|
||||
}
|
||||
delete prop.value;
|
||||
} else if (prop.type === "conf-type" && prop.value) {
|
||||
const configNode = RED.nodes.node(prop.value);
|
||||
if (configNode) {
|
||||
if (configNode.users.indexOf(node) === -1) {
|
||||
// Add the node to the config node users
|
||||
configNode.users.push(node);
|
||||
RED.events.emit('nodes:change', configNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -44,6 +44,7 @@
|
||||
apply: function(editState) {
|
||||
var newValue;
|
||||
var d;
|
||||
// If the node is a subflow, the node's properties (exepts name) are saved by `envProperties`
|
||||
if (node._def.defaults) {
|
||||
for (d in node._def.defaults) {
|
||||
if (node._def.defaults.hasOwnProperty(d)) {
|
||||
|
@ -1362,7 +1362,7 @@ RED.subflow = (function() {
|
||||
item.value = ""+input.prop("checked");
|
||||
break;
|
||||
case "conf-types":
|
||||
item.value = input.val()
|
||||
item.value = input.val() === "_ADD_" ? "" : input.val();
|
||||
item.type = "conf-type"
|
||||
}
|
||||
if (ui.type === "cred" || item.type !== data.parent.type || item.value !== data.parent.value) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user