mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3921 from node-red/fix-group-unknown
Handle replacing unknown node inside group or subflow
This commit is contained in:
commit
3cb84222f8
@ -1965,7 +1965,7 @@ RED.nodes = (function() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const keepNodesCurrentZ = reimport && n.z && RED.workspaces.contains(n.z)
|
||||
const keepNodesCurrentZ = reimport && n.z && (RED.workspaces.contains(n.z) || RED.nodes.subflow(n.z))
|
||||
if (!keepNodesCurrentZ && n.z && !workspace_map[n.z] && !subflow_map[n.z]) {
|
||||
n.z = activeWorkspace;
|
||||
}
|
||||
@ -2067,7 +2067,7 @@ RED.nodes = (function() {
|
||||
node.id = getID();
|
||||
} else {
|
||||
node.id = n.id;
|
||||
const keepNodesCurrentZ = reimport && node.z && RED.workspaces.contains(node.z)
|
||||
const keepNodesCurrentZ = reimport && node.z && (RED.workspaces.contains(node.z) || RED.nodes.subflow(node.z))
|
||||
if (!keepNodesCurrentZ && (node.z == null || (!workspace_map[node.z] && !subflow_map[node.z]))) {
|
||||
if (createMissingWorkspace) {
|
||||
if (missingWorkspace === null) {
|
||||
@ -2740,6 +2740,7 @@ RED.nodes = (function() {
|
||||
}
|
||||
});
|
||||
|
||||
const nodeGroupMap = {}
|
||||
var replaceNodeIds = Object.keys(replaceNodes);
|
||||
if (replaceNodeIds.length > 0) {
|
||||
var reimportList = [];
|
||||
@ -2750,6 +2751,12 @@ RED.nodes = (function() {
|
||||
} else {
|
||||
allNodes.removeNode(n);
|
||||
}
|
||||
if (n.g) {
|
||||
// reimporting a node *without* including its group object
|
||||
// will cause the g property to be cleared. Cache it
|
||||
// here so we can restore it
|
||||
nodeGroupMap[n.id] = n.g
|
||||
}
|
||||
reimportList.push(convertNode(n));
|
||||
RED.events.emit('nodes:remove',n);
|
||||
});
|
||||
@ -2771,6 +2778,18 @@ RED.nodes = (function() {
|
||||
var newNodeMap = {};
|
||||
result.nodes.forEach(function(n) {
|
||||
newNodeMap[n.id] = n;
|
||||
if (nodeGroupMap[n.id]) {
|
||||
// This node is in a group - need to substitute the
|
||||
// node reference inside the group
|
||||
n.g = nodeGroupMap[n.id]
|
||||
const group = RED.nodes.group(n.g)
|
||||
if (group) {
|
||||
var index = group.nodes.findIndex(gn => gn.id === n.id)
|
||||
if (index > -1) {
|
||||
group.nodes[index] = n
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
RED.nodes.eachLink(function(l) {
|
||||
if (newNodeMap.hasOwnProperty(l.source.id)) {
|
||||
|
Loading…
Reference in New Issue
Block a user