From 53f204d8b951782705adc9c05efcd751f1e885bc Mon Sep 17 00:00:00 2001 From: GogoVega <92022724+GogoVega@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:25:45 +0100 Subject: [PATCH] Do not import `global-config` if it only contains modules --- .../@node-red/editor-client/src/js/ui/view.js | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js index 5872c0f40..bb1e5c664 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js @@ -5676,17 +5676,38 @@ RED.view = (function() { filteredNodesToImport = nodesToImport.filter(function (n) { if (n.type === "global-config") { importedGlobalConfig = n + // Do not import it if one exists + // The properties of this one will be merged after import + return false + } + return true + }); + } else { + filteredNodesToImport = nodesToImport.filter(function (n) { + if (n.type === "global-config") { + importedGlobalConfig = n + if (n.env && n.env.length) { + // No existing global-config + // Contains env and maybe modules, so import it + return true + } + // Contains modules only - do not import it return false } return true }); } + + const modules = importedGlobalConfig?.modules || {} + // Ensure do not import modules - since it can contain it + delete importedGlobalConfig?.modules + var result = RED.nodes.import(filteredNodesToImport,{ generateIds: options.generateIds, addFlow: addNewFlow, importMap: options.importMap, markChanged: true, - modules: importedGlobalConfig ? (importedGlobalConfig.modules || {}) : {} + modules: modules }); if (result) { var new_nodes = result.nodes; @@ -5810,7 +5831,7 @@ RED.view = (function() { } } - if (importedGlobalConfig) { + if (importedGlobalConfig && existingGlobalConfig) { // merge global env to existing global-config var existingEnv = existingGlobalConfig.env || []; var importedEnv = importedGlobalConfig.env || []