Add update available widget

This commit is contained in:
Nick O'Leary
2025-04-23 17:35:58 +01:00
parent 86558126ab
commit 6220f990c4
2 changed files with 21 additions and 4 deletions

View File

@@ -317,6 +317,7 @@ var RED = (function() {
function completeLoad(showProjectWelcome) {
var persistentNotifications = {};
let updateAvailableWidget = null
RED.comms.subscribe("notification/#",function(topic,msg) {
var parts = topic.split("/");
var notificationId = parts[1];
@@ -358,7 +359,23 @@ var RED = (function() {
});
return;
}
if (notificationId === "update-available") {
if (!updateAvailableWidget) {
updateAvailableWidget = $('<button type="button" class="red-ui-footer-button red-ui-update-status"></button>').text(RED._("telemetry.updateAvailable"));
updateAvailableWidget.on("click", function (evt) {
window.open(`https://github.com/node-red/node-red/releases/tag/${msg.version}`, "_blank");
});
const tooltip = RED.popover.tooltip(updateAvailableWidget, function () {
return RED._("telemetry.updateAvailableDesc", msg)
});
RED.statusBar.add({
id: "red-ui-status-update-available",
align: "right",
element: updateAvailableWidget
});
setTimeout(() => { tooltip.open(); setTimeout(() => tooltip.close(), 7000) }, 1000)
}
}
if (msg.text) {
msg.default = msg.text;
var text = RED._(msg.text,msg);

View File

@@ -1525,7 +1525,7 @@ RED.palette.editor = (function() {
});
RED.statusBar.add({
id: "update",
id: "red-ui-status-package-update",
align: "right",
element: updateStatusWidget
});
@@ -1560,11 +1560,11 @@ RED.palette.editor = (function() {
function updateStatus(opts) {
if (opts.count) {
RED.statusBar.show("update");
RED.statusBar.show("red-ui-status-package-update");
updateStatusWidget.empty();
$('<span><i class="fa fa-cube"></i> ' + opts.count + '</span>').appendTo(updateStatusWidget);
} else {
RED.statusBar.hide("update");
RED.statusBar.hide("red-ui-status-package-update");
}
}