From 143efce16beabdced2da4a71aa60ea0f0d7ddc86 Mon Sep 17 00:00:00 2001 From: GogoVega <92022724+GogoVega@users.noreply.github.com> Date: Mon, 2 Jun 2025 09:56:24 +0200 Subject: [PATCH 1/2] Add the link icon (node docs) to the nodes tab --- .../editor-client/src/js/ui/palette-editor.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 8b5ddc325..891819583 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 @@ -249,6 +249,11 @@ RED.palette.editor = (function() { nodeEntries[module].info.pending_version = nodeInfo.pending_version; } + if (loadedIndex[module] && loadedIndex[module].url) { + // Add the link to the node documentation if the catalog contains it + nodeEntries[module].info.url = loadedIndex[module].url; + } + for (const set in nodeInfo.sets) { if (nodeInfo.sets.hasOwnProperty(set)) { index.push(set); @@ -760,6 +765,11 @@ RED.palette.editor = (function() { nodeEntries[module].info.pending_version = pluginInfo.pending_version; } + if (loadedIndex[module] && loadedIndex[module].url) { + // Add the link to the plugin documentation if the catalog contains it + nodeEntries[module].info.url = loadedIndex[module].url; + } + for (const set in pluginInfo.sets) { if (pluginInfo.sets.hasOwnProperty(set)) { index.push(set); @@ -869,6 +879,12 @@ RED.palette.editor = (function() { var headerRow = $('
',{class:"red-ui-palette-module-header"}).appendTo(container); var titleRow = $('
').appendTo(headerRow); $('').text(entry.name).appendTo(titleRow); + + if (entry.url) { + // Add the link icon to the node documentation + $('').attr('href', entry.url).appendTo(titleRow); + } + var metaRow = $('
').appendTo(headerRow); var versionSpan = $('').text(entry.version).appendTo(metaRow); From 8b4759f3f8b824f7b6e792fb8b50a8a74c0a0f44 Mon Sep 17 00:00:00 2001 From: GogoVega <92022724+GogoVega@users.noreply.github.com> Date: Mon, 2 Jun 2025 09:58:29 +0200 Subject: [PATCH 2/2] Add msg and button to the node docs for a major update --- .../editor-client/locales/en-US/editor.json | 1 + .../editor-client/src/js/ui/palette-editor.js | 128 +++++++++++------- 2 files changed, 77 insertions(+), 52 deletions(-) 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__

", + "majorVersion": "

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) {