From 866f305686119fea0cc0fb2f196c12a169dc8b5c Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 13 May 2021 13:57:29 +0100 Subject: [PATCH 1/3] Open subflow tab next to active tab rather than at the end --- .../@node-red/editor-client/src/js/ui/common/tabs.js | 3 +++ .../@node-red/editor-client/src/js/ui/workspaces.js | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js index bcc0aef32..ee6ea1960 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js @@ -785,6 +785,9 @@ RED.tabs = (function() { count: function() { return ul.find("li.red-ui-tab").length; }, + activeIndex: function() { + return ul.find("li.active").index() + }, contains: function(id) { return ul.find("a[href='#"+id+"']").length > 0; }, diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js b/packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js index 606149bd5..a7a4e024f 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js @@ -493,7 +493,11 @@ RED.workspaces = (function() { if (!workspace_tabs.contains(id)) { var sf = RED.nodes.subflow(id); if (sf) { - addWorkspace({type:"subflow",id:id,icon:"red/images/subflow_tab.svg",label:sf.name, closeable: true}); + addWorkspace( + {type:"subflow",id:id,icon:"red/images/subflow_tab.svg",label:sf.name, closeable: true}, + null, + workspace_tabs.activeIndex()+1 + ); } else { return; } From 15aa249f6492fd37451d9222a5cce5dd588568c9 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 13 May 2021 14:06:43 +0100 Subject: [PATCH 2/3] Stop module with missing types from preventing editor load --- packages/node_modules/@node-red/editor-client/src/js/nodes.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 9b580f9a0..e134487a1 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -86,6 +86,10 @@ RED.nodes = (function() { } }, addNodeSet: function(ns) { + if (!ns.types) { + // A node has been loaded without any types. Ignore it. + return; + } ns.added = false; nodeSets[ns.id] = ns; for (var j=0;j Date: Thu, 13 May 2021 14:28:01 +0100 Subject: [PATCH 3/3] Prevent unknown node from breaking editor If a node provides a .js file that registers a type but its .html is empty, then the editor will know about the type, but there will be no node definition. This fix handles that in some of the utility functions for generating node appearance. This wasn't an exhaustive check for these things - just some obvious candidates that I hit in testing 'bad' nodes --- .../node_modules/@node-red/editor-client/src/js/ui/utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js index bb17ea395..9a8f0baa5 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js @@ -875,6 +875,7 @@ RED.utils = (function() { } function getDefaultNodeIcon(def,node) { + def = def || {}; var icon_url; if (node && node.type === "subflow") { icon_url = "node-red/subflow.svg"; @@ -912,6 +913,7 @@ RED.utils = (function() { } function getNodeIcon(def,node) { + def = def || {}; if (node && node.type === '_selection_') { return "font-awesome/fa-object-ungroup"; } else if (node && node.type === 'group') { @@ -999,6 +1001,7 @@ RED.utils = (function() { } function getNodeColor(type, def) { + def = def || {}; var result = def.color; var paletteTheme = RED.settings.theme('palette.theme') || []; if (paletteTheme.length > 0) {