From 19eb8e9a6d0ff472c99f9f9f472b553c9054a86d Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 7 Jan 2019 14:54:35 +0000 Subject: [PATCH] Update palette manager properly when module updated --- .../node_modules/@node-red/editor-client/src/js/red.js | 2 +- .../@node-red/editor-client/src/js/ui/palette-editor.js | 2 +- packages/node_modules/@node-red/registry/lib/registry.js | 7 +++++++ packages/node_modules/@node-red/runtime/lib/nodes/index.js | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/red.js b/packages/node_modules/@node-red/editor-client/src/js/red.js index 3e91a8b56..b00413e8a 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/red.js +++ b/packages/node_modules/@node-red/editor-client/src/js/red.js @@ -391,7 +391,7 @@ var RED = (function() { typeList = ""; RED.notify(RED._("palette.event.nodeDisabled", {count:msg.types.length})+typeList,"success"); } - } else if (topic == "node/upgraded") { + } else if (topic == "notification/node/upgraded") { RED.notify(RED._("palette.event.nodeUpgraded", {module:msg.module,version:msg.version}),"success"); RED.nodes.registry.setModulePendingUpdated(msg.module,msg.version); } diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js b/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js index c8f4e3d7d..d04e460d8 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js @@ -289,7 +289,7 @@ RED.palette.editor = (function() { } if (moduleInfo.pending_version) { nodeEntry.versionSpan.html(moduleInfo.version+' '+moduleInfo.pending_version).appendTo(nodeEntry.metaRow) - nodeEntry.updateButton.text(RED._('palette.editor.updated')).addClass('disabled').show(); + nodeEntry.updateButton.text(RED._('palette.editor.updated')).addClass('disabled').css('display', 'inline-block'); } else if (loadedIndex.hasOwnProperty(module)) { if (semVerCompare(loadedIndex[module].version,moduleInfo.version) === 1) { nodeEntry.updateButton.show(); diff --git a/packages/node_modules/@node-red/registry/lib/registry.js b/packages/node_modules/@node-red/registry/lib/registry.js index 8581fadb0..89f04eacc 100644 --- a/packages/node_modules/@node-red/registry/lib/registry.js +++ b/packages/node_modules/@node-red/registry/lib/registry.js @@ -270,6 +270,10 @@ function getNodeInfo(typeOrId) { if (config.hasOwnProperty("loaded")) { info.loaded = config.loaded; } + if (module.pending_version) { + info.pending_version = module.pending_version; + } + info.version = module.version; return info; } @@ -342,6 +346,9 @@ function getModuleInfo(module) { path: moduleConfigs[module].path, nodes: [] }; + if (moduleConfigs[module] && moduleConfigs[module].pending_version) { + m.pending_version = moduleConfigs[module].pending_version; + } for (var i = 0; i < nodes.length; ++i) { var nodeInfo = filterNodeInfo(moduleConfigs[module].nodes[nodes[i]]); nodeInfo.version = m.version; diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/index.js b/packages/node_modules/@node-red/runtime/lib/nodes/index.js index bfeb7d8fd..365f002d6 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/index.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/index.js @@ -151,8 +151,8 @@ function reportNodeStateChange(info,enabled) { } function installModule(module,version) { - var ex_module = registry.getModuleInfo(module); - var isUpgrade = !!ex_module; + var existingModule = registry.getModuleInfo(module); + var isUpgrade = !!existingModule; return registry.installModule(module,version).then(function(info) { if (isUpgrade) { events.emit("runtime-event",{id:"node/upgraded",retain:false,payload:{module:module,version:version}});