mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #4148 from GerwinvBeek/Bugs/not-loading-missing-subflow
Handle missing subflow when loading flows into the editor
This commit is contained in:
		| @@ -2095,16 +2095,27 @@ RED.nodes = (function() { | ||||
|                     } else if (n.type.substring(0,7) === "subflow") { | ||||
|                         var parentId = n.type.split(":")[1]; | ||||
|                         var subflow = subflow_denylist[parentId]||subflow_map[parentId]||getSubflow(parentId); | ||||
|                         if (createNewIds || options.importMap[n.id] === "copy") { | ||||
|                             parentId = subflow.id; | ||||
|                             node.type = "subflow:"+parentId; | ||||
|                             node._def = registry.getNodeType(node.type); | ||||
|                             delete node.i; | ||||
|                         if (!subflow){ | ||||
|                             node._def = { | ||||
|                                 color:"#fee", | ||||
|                                 defaults: {}, | ||||
|                                 label: "unknown: "+n.type, | ||||
|                                 labelStyle: "red-ui-flow-node-label-italic", | ||||
|                                 outputs: n.outputs|| (n.wires && n.wires.length) || 0, | ||||
|                                 set: registry.getNodeSet("node-red/unknown") | ||||
|                             } | ||||
|                         } else { | ||||
|                             if (createNewIds || options.importMap[n.id] === "copy") { | ||||
|                                 parentId = subflow.id; | ||||
|                                 node.type = "subflow:"+parentId; | ||||
|                                 node._def = registry.getNodeType(node.type); | ||||
|                                 delete node.i; | ||||
|                             } | ||||
|                             node.name = n.name; | ||||
|                             node.outputs = subflow.out.length; | ||||
|                             node.inputs = subflow.in.length; | ||||
|                             node.env = n.env; | ||||
|                         } | ||||
|                         node.name = n.name; | ||||
|                         node.outputs = subflow.out.length; | ||||
|                         node.inputs = subflow.in.length; | ||||
|                         node.env = n.env; | ||||
|                     } else if (n.type === 'junction') { | ||||
|                          node._def = {defaults:{}} | ||||
|                          node._config.x = node.x | ||||
|   | ||||
| @@ -45,11 +45,13 @@ RED.editor = (function() { | ||||
|         var hasChanged; | ||||
|         if (node.type.indexOf("subflow:")===0) { | ||||
|             subflow = RED.nodes.subflow(node.type.substring(8)); | ||||
|             isValid = subflow.valid; | ||||
|             hasChanged = subflow.changed; | ||||
|             if (isValid === undefined) { | ||||
|                 isValid = validateNode(subflow); | ||||
|             if (subflow){ | ||||
|                 isValid = subflow.valid; | ||||
|                 hasChanged = subflow.changed; | ||||
|                 if (isValid === undefined) { | ||||
|                     isValid = validateNode(subflow); | ||||
|                     hasChanged = subflow.changed; | ||||
|                 } | ||||
|             } | ||||
|             validationErrors = validateNodeProperties(node, node._def.defaults, node); | ||||
|             node.valid = isValid && validationErrors.length === 0; | ||||
|   | ||||
| @@ -199,7 +199,9 @@ function parseConfig(config) { | ||||
|                if (subflowDetails) { | ||||
|                    var subflowType = subflowDetails[1] | ||||
|                    n.subflow = subflowType; | ||||
|                    flow.subflows[subflowType].instances.push(n) | ||||
|                    if (flow.subflows[subflowType]) { | ||||
|                        flow.subflows[subflowType].instances.push(n) | ||||
|                    } | ||||
|                } | ||||
|                if (container) { | ||||
|                    container.nodes[n.id] = n; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user