1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add config node to refer to when exporting subflow

This commit is contained in:
Kazuhiro Ito 2021-01-29 11:05:15 +09:00
parent 3a0074d96e
commit dad47ade38

View File

@ -849,40 +849,47 @@ RED.nodes = (function() {
subflowSet.push(n); subflowSet.push(n);
} }
}); });
RED.nodes.eachConfig(function(n) {
if (n.z == subflowId) {
subflowSet.push(n);
}
});
var exportableSubflow = createExportableNodeSet(subflowSet, exportedIds, exportedSubflows, exportedConfigNodes); var exportableSubflow = createExportableNodeSet(subflowSet, exportedIds, exportedSubflows, exportedConfigNodes);
nns = exportableSubflow.concat(nns); nns = exportableSubflow.concat(nns);
} }
} }
if (node.type !== "subflow") { if (node.type !== "subflow") {
var convertedNode = RED.nodes.convertNode(node); if (nns.findIndex((v) => v && v.id === node.id) == -1) {
for (var d in node._def.defaults) { var convertedNode = RED.nodes.convertNode(node);
if (node._def.defaults[d].type) { for (var d in node._def.defaults) {
var nodeList = node[d]; if (node._def.defaults[d].type) {
if (!Array.isArray(nodeList)) { var nodeList = node[d];
nodeList = [nodeList]; if (!Array.isArray(nodeList)) {
} nodeList = [nodeList];
nodeList = nodeList.filter(function(id) { }
if (id in configNodes) { nodeList = nodeList.filter(function(id) {
var confNode = configNodes[id]; if (id in configNodes) {
if (confNode._def.exportable !== false) { var confNode = configNodes[id];
if (!(id in exportedConfigNodes)) { if (confNode._def.exportable !== false) {
exportedConfigNodes[id] = true; if (!(id in exportedConfigNodes)) {
set.push(confNode); exportedConfigNodes[id] = true;
return true; set.push(confNode);
} return true;
} }
return false; }
return false;
}
return true;
})
if (nodeList.length === 0) {
convertedNode[d] = Array.isArray(node[d])?[]:""
} else {
convertedNode[d] = Array.isArray(node[d])?nodeList:nodeList[0]
} }
return true;
})
if (nodeList.length === 0) {
convertedNode[d] = Array.isArray(node[d])?[]:""
} else {
convertedNode[d] = Array.isArray(node[d])?nodeList:nodeList[0]
} }
} }
nns.push(convertedNode);
} }
nns.push(convertedNode);
if (node.type === "group") { if (node.type === "group") {
nns = nns.concat(createExportableNodeSet(node.nodes, exportedIds, exportedSubflows, exportedConfigNodes)); nns = nns.concat(createExportableNodeSet(node.nodes, exportedIds, exportedSubflows, exportedConfigNodes));
} }