diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index 67ed35f33..b7cebefb6 100644 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -641,6 +641,7 @@ "installed": "installed", "conflict": "conflict", "conflictTip": "
This module cannot be installed as it includes a
node type that has already been installed
Conflicts with __module__
This is a major version update of the node. Check the documentation for details of the update.
", "loading": "Loading catalogues...", "tab-nodes": "Nodes", "tab-install": "Install", 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 891819583..7b4bd0dda 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 @@ -1298,64 +1298,88 @@ RED.palette.editor = (function() { $('').appendTo(installTab); } - function update(entry,version,url,container,done) { + function update(entry, version, url, container, done) { if (RED.settings.get('externalModules.palette.allowInstall', true) === false) { done(new Error('Palette not editable')); return; } - var notification = RED.notify(RED._("palette.editor.confirm.update.body",{module:entry.name}),{ + + let notification; + let msg = RED._("palette.editor.confirm.update.body", { module: entry.name }); + const buttons = [ + { + text: RED._("common.label.cancel"), + click: function () { + notification.close(); + } + }, + { + text: RED._("palette.editor.confirm.button.update"), + class: "primary red-ui-palette-module-install-confirm-button-update", + click: function () { + const spinner = RED.utils.addSpinnerOverlay(container, true); + const buttonRow = $('').appendTo(spinner); + $('').text(RED._("eventLog.view")).appendTo(buttonRow).on("click", function (evt) { + evt.preventDefault(); + RED.actions.invoke("core:show-event-log"); + }); + installNodeModule(entry.name, version, url, function (xhr) { + spinner.remove(); + if (xhr) { + if (xhr.responseJSON) { + const notification = RED.notify(RED._('palette.editor.errors.updateFailed',{module: entry.name,message:xhr.responseJSON.message}),{ + type: 'error', + modal: true, + fixed: true, + buttons: [ + { + text: RED._("common.label.close"), + click: function () { + notification.close(); + } + }, { + text: RED._("eventLog.view"), + click: function () { + notification.close(); + RED.actions.invoke("core:show-event-log"); + } + } + ] + }); + } + } + done(xhr); + }); + notification.close(); + } + } + ]; + + const currentVersion = semverre.exec(nodeEntries[entry.name].info.version); + const targetVersion = semverre.exec(version); + if (currentVersion && targetVersion) { + if (targetVersion[1] > currentVersion[1]) { + // Updating to Major version + msg = msg + RED._("palette.editor.majorVersion"); + + if (entry.url) { + // Add a button to open the node documentation + buttons.splice(1, 0, { + text: RED._("palette.editor.confirm.button.review"), + class: "primary red-ui-palette-module-install-confirm-button-review", + click: function () { + window.open(entry.url); + } + }); + } + } + } + + notification = RED.notify(msg, { modal: true, fixed: true, - buttons: [ - { - text: RED._("common.label.cancel"), - click: function() { - notification.close(); - } - }, - { - text: RED._("palette.editor.confirm.button.update"), - class: "primary red-ui-palette-module-install-confirm-button-update", - click: function() { - var spinner = RED.utils.addSpinnerOverlay(container, true); - var buttonRow = $('').appendTo(spinner); - $('').text(RED._("eventLog.view")).appendTo(buttonRow).on("click", function(evt) { - evt.preventDefault(); - RED.actions.invoke("core:show-event-log"); - }); - RED.eventLog.startEvent(RED._("palette.editor.confirm.button.install")+" : "+entry.name+" "+version); - installNodeModule(entry.name,version,url,function(xhr) { - spinner.remove(); - if (xhr) { - if (xhr.responseJSON) { - var notification = RED.notify(RED._('palette.editor.errors.updateFailed',{module: entry.name,message:xhr.responseJSON.message}),{ - type: 'error', - modal: true, - fixed: true, - buttons: [ - { - text: RED._("common.label.close"), - click: function() { - notification.close(); - } - },{ - text: RED._("eventLog.view"), - click: function() { - notification.close(); - RED.actions.invoke("core:show-event-log"); - } - } - ] - }); - } - } - done(xhr); - }); - notification.close(); - } - } - ] - }) + buttons: buttons + }); } function remove(entry,container,done) { if (RED.settings.get('externalModules.palette.allowInstall', true) === false) {