mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #4811 from GogoVega/handle-bad-subflow
Handle the import of an incomplete Subflow
This commit is contained in:
commit
84a2fbed2e
@ -1064,6 +1064,8 @@ RED.nodes = (function() {
|
|||||||
sf.name = subflowName;
|
sf.name = subflowName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sf.instances = [];
|
||||||
|
|
||||||
subflows[sf.id] = sf;
|
subflows[sf.id] = sf;
|
||||||
allNodes.addTab(sf.id);
|
allNodes.addTab(sf.id);
|
||||||
linkTabMap[sf.id] = [];
|
linkTabMap[sf.id] = [];
|
||||||
@ -1116,7 +1118,7 @@ RED.nodes = (function() {
|
|||||||
module: "node-red"
|
module: "node-red"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sf.instances = [];
|
|
||||||
sf._def = RED.nodes.getType("subflow:"+sf.id);
|
sf._def = RED.nodes.getType("subflow:"+sf.id);
|
||||||
RED.events.emit("subflows:add",sf);
|
RED.events.emit("subflows:add",sf);
|
||||||
}
|
}
|
||||||
@ -1758,7 +1760,8 @@ RED.nodes = (function() {
|
|||||||
// Remove the old subflow definition - but leave the instances in place
|
// Remove the old subflow definition - but leave the instances in place
|
||||||
var removalResult = RED.subflow.removeSubflow(n.id, true);
|
var removalResult = RED.subflow.removeSubflow(n.id, true);
|
||||||
// Create the list of nodes for the new subflow def
|
// Create the list of nodes for the new subflow def
|
||||||
var subflowNodes = [n].concat(zMap[n.id]);
|
// Need to sort the list in order to remove missing nodes
|
||||||
|
var subflowNodes = [n].concat(zMap[n.id]).filter((s) => !!s);
|
||||||
// Import the new subflow - no clashes should occur as we've removed
|
// Import the new subflow - no clashes should occur as we've removed
|
||||||
// the old version
|
// the old version
|
||||||
var result = importNodes(subflowNodes);
|
var result = importNodes(subflowNodes);
|
||||||
@ -2187,7 +2190,7 @@ RED.nodes = (function() {
|
|||||||
x:parseFloat(n.x || 0),
|
x:parseFloat(n.x || 0),
|
||||||
y:parseFloat(n.y || 0),
|
y:parseFloat(n.y || 0),
|
||||||
z:n.z,
|
z:n.z,
|
||||||
type:0,
|
type: n.type,
|
||||||
info: n.info,
|
info: n.info,
|
||||||
changed:false,
|
changed:false,
|
||||||
_config:{}
|
_config:{}
|
||||||
@ -2248,7 +2251,6 @@ RED.nodes = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node.type = n.type;
|
|
||||||
node._def = def;
|
node._def = def;
|
||||||
if (node.type === "group") {
|
if (node.type === "group") {
|
||||||
node._def = RED.group.def;
|
node._def = RED.group.def;
|
||||||
@ -2278,6 +2280,15 @@ RED.nodes = (function() {
|
|||||||
outputs: n.outputs|| (n.wires && n.wires.length) || 0,
|
outputs: n.outputs|| (n.wires && n.wires.length) || 0,
|
||||||
set: registry.getNodeSet("node-red/unknown")
|
set: registry.getNodeSet("node-red/unknown")
|
||||||
}
|
}
|
||||||
|
var orig = {};
|
||||||
|
for (var p in n) {
|
||||||
|
if (n.hasOwnProperty(p) && p!="x" && p!="y" && p!="z" && p!="id" && p!="wires") {
|
||||||
|
orig[p] = n[p];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node._orig = orig;
|
||||||
|
node.name = n.type;
|
||||||
|
node.type = "unknown";
|
||||||
} else {
|
} else {
|
||||||
if (subflow_denylist[parentId] || createNewIds || options.importMap[n.id] === "copy") {
|
if (subflow_denylist[parentId] || createNewIds || options.importMap[n.id] === "copy") {
|
||||||
parentId = subflow.id;
|
parentId = subflow.id;
|
||||||
@ -2475,9 +2486,11 @@ RED.nodes = (function() {
|
|||||||
n = new_subflows[i];
|
n = new_subflows[i];
|
||||||
n.in.forEach(function(input) {
|
n.in.forEach(function(input) {
|
||||||
input.wires.forEach(function(wire) {
|
input.wires.forEach(function(wire) {
|
||||||
var link = {source:input, sourcePort:0, target:node_map[wire.id]};
|
if (node_map.hasOwnProperty(wire.id)) {
|
||||||
addLink(link);
|
var link = {source:input, sourcePort:0, target:node_map[wire.id]};
|
||||||
new_links.push(link);
|
addLink(link);
|
||||||
|
new_links.push(link);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
delete input.wires;
|
delete input.wires;
|
||||||
});
|
});
|
||||||
@ -2486,11 +2499,13 @@ RED.nodes = (function() {
|
|||||||
var link;
|
var link;
|
||||||
if (subflow_map[wire.id] && subflow_map[wire.id].id == n.id) {
|
if (subflow_map[wire.id] && subflow_map[wire.id].id == n.id) {
|
||||||
link = {source:n.in[wire.port], sourcePort:wire.port,target:output};
|
link = {source:n.in[wire.port], sourcePort:wire.port,target:output};
|
||||||
} else {
|
} else if (node_map.hasOwnProperty(wire.id) || subflow_map.hasOwnProperty(wire.id)) {
|
||||||
link = {source:node_map[wire.id]||subflow_map[wire.id], sourcePort:wire.port,target:output};
|
link = {source:node_map[wire.id]||subflow_map[wire.id], sourcePort:wire.port,target:output};
|
||||||
}
|
}
|
||||||
addLink(link);
|
if (link) {
|
||||||
new_links.push(link);
|
addLink(link);
|
||||||
|
new_links.push(link);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
delete output.wires;
|
delete output.wires;
|
||||||
});
|
});
|
||||||
@ -2499,11 +2514,13 @@ RED.nodes = (function() {
|
|||||||
var link;
|
var link;
|
||||||
if (subflow_map[wire.id] && subflow_map[wire.id].id == n.id) {
|
if (subflow_map[wire.id] && subflow_map[wire.id].id == n.id) {
|
||||||
link = {source:n.in[wire.port], sourcePort:wire.port,target:n.status};
|
link = {source:n.in[wire.port], sourcePort:wire.port,target:n.status};
|
||||||
} else {
|
} else if (node_map.hasOwnProperty(wire.id) || subflow_map.hasOwnProperty(wire.id)) {
|
||||||
link = {source:node_map[wire.id]||subflow_map[wire.id], sourcePort:wire.port,target:n.status};
|
link = {source:node_map[wire.id]||subflow_map[wire.id], sourcePort:wire.port,target:n.status};
|
||||||
}
|
}
|
||||||
addLink(link);
|
if (link) {
|
||||||
new_links.push(link);
|
addLink(link);
|
||||||
|
new_links.push(link);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
delete n.status.wires;
|
delete n.status.wires;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user