mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #4093 from node-red/subflow-nested-context
Generate stable ids for subflow instance internal nodes
This commit is contained in:
commit
4deca552fa
@ -474,7 +474,7 @@ class Subflow extends Flow {
|
|||||||
*/
|
*/
|
||||||
function createNodeInSubflow(subflowInstanceId, def) {
|
function createNodeInSubflow(subflowInstanceId, def) {
|
||||||
let node = clone(def);
|
let node = clone(def);
|
||||||
let nid = redUtil.generateId();
|
let nid = `${subflowInstanceId}-${node.id}` //redUtil.generateId();
|
||||||
// console.log("Create Node In subflow",node._alias, "--->",nid, "(",node.type,")")
|
// console.log("Create Node In subflow",node._alias, "--->",nid, "(",node.type,")")
|
||||||
// node_map[node.id] = node;
|
// node_map[node.id] = node;
|
||||||
node._alias = node.id;
|
node._alias = node.id;
|
||||||
|
@ -589,17 +589,28 @@ function deleteContext(id,flowId) {
|
|||||||
* If flowConfig is undefined, all flow/node contexts will be removed
|
* If flowConfig is undefined, all flow/node contexts will be removed
|
||||||
**/
|
**/
|
||||||
function clean(flowConfig) {
|
function clean(flowConfig) {
|
||||||
flowConfig = flowConfig || { allNodes: {} };
|
flowConfig = flowConfig || { allNodes: {}, subflows: {} };
|
||||||
var promises = [];
|
const knownNodes = new Set(Object.keys(flowConfig.allNodes))
|
||||||
for(var plugin in stores){
|
|
||||||
if(stores.hasOwnProperty(plugin)){
|
// We need to alias all of the subflow instance contents
|
||||||
promises.push(stores[plugin].clean(Object.keys(flowConfig.allNodes)));
|
for (const subflow of Object.values(flowConfig.subflows || {})) {
|
||||||
}
|
subflow.instances.forEach(instance => {
|
||||||
|
for (const nodeId of Object.keys(subflow.nodes || {})) {
|
||||||
|
knownNodes.add(`${instance.id}-${nodeId}`)
|
||||||
|
}
|
||||||
|
for (const nodeId of Object.keys(subflow.configs || {})) {
|
||||||
|
knownNodes.add(`${instance.id}-${nodeId}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
for (var id in contexts) {
|
var promises = [];
|
||||||
if (contexts.hasOwnProperty(id) && id !== "global") {
|
for (const store of Object.values(stores)){
|
||||||
|
promises.push(store.clean(Array.from(knownNodes)));
|
||||||
|
}
|
||||||
|
for (const id of Object.keys(contexts)) {
|
||||||
|
if (id !== "global") {
|
||||||
var idParts = id.split(":");
|
var idParts = id.split(":");
|
||||||
if (!flowConfig.allNodes.hasOwnProperty(idParts[0])) {
|
if (!knownNodes.has(idParts[0])) {
|
||||||
delete contexts[id];
|
delete contexts[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user