mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 07:31:07 +01:00
Add update available widget
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user