mirror of https://github.com/node-red/node-red.git
Add RED.palette.editor.updates prop and event registry:updates-available
parent
a312dbd878
commit
a8422099ba
|
|
@ -1839,7 +1839,7 @@ RED.palette.editor = (function() {
|
|||
interactive: true,
|
||||
direction: "bottom",
|
||||
content: function () {
|
||||
const count = updateAvailable.length || 0;
|
||||
const count = moduleUpdates.length || 0
|
||||
const content = $('<div style="display: flex; flex-direction: column; gap: 5px;"></div>');
|
||||
if (updateStatusState.version) {
|
||||
$(`<a class='red-ui-button' href="https://github.com/node-red/node-red/releases/tag/${updateStatusState.version}" target="_blank">${RED._("telemetry.updateAvailableDesc", updateStatusState)}</a>`).appendTo(content)
|
||||
|
|
@ -1849,7 +1849,7 @@ RED.palette.editor = (function() {
|
|||
updateStatusWidgetPopover.close()
|
||||
RED.actions.invoke("core:manage-palette", {
|
||||
view: "nodes",
|
||||
filter: '"' + updateAvailable.join('", "') + '"'
|
||||
filter: '"' + moduleUpdates.map(u => u.package).join('", "') + '"'
|
||||
});
|
||||
}).appendTo(content)
|
||||
}
|
||||
|
|
@ -1871,7 +1871,7 @@ RED.palette.editor = (function() {
|
|||
function refreshUpdateStatus() {
|
||||
clearTimeout(pendingRefreshTimeout)
|
||||
pendingRefreshTimeout = setTimeout(() => {
|
||||
updateAvailable = [];
|
||||
moduleUpdates.length = 0
|
||||
for (const module of Object.keys(nodeEntries)) {
|
||||
if (loadedIndex.hasOwnProperty(module)) {
|
||||
const moduleInfo = nodeEntries[module].info;
|
||||
|
|
@ -1879,35 +1879,49 @@ RED.palette.editor = (function() {
|
|||
// Module updated
|
||||
continue;
|
||||
}
|
||||
const current = moduleInfo.version
|
||||
const latest = loadedIndex[module].version
|
||||
if (updateAllowed &&
|
||||
semVerCompare(loadedIndex[module].version, moduleInfo.version) > 0 &&
|
||||
semVerCompare(latest, current) > 0 &&
|
||||
RED.utils.checkModuleAllowed(module, null, updateAllowList, updateDenyList)
|
||||
) {
|
||||
updateAvailable.push(module);
|
||||
moduleUpdates.push({ package: module, current, latest })
|
||||
}
|
||||
}
|
||||
}
|
||||
updateStatusState.moduleCount = updateAvailable.length;
|
||||
updateStatusState.moduleCount = moduleUpdates.length
|
||||
updateStatus();
|
||||
}, 200)
|
||||
}
|
||||
|
||||
function updateStatus() {
|
||||
if (updateStatusState.moduleCount || updateStatusState.version) {
|
||||
const updates = RED.palette.editor.updates
|
||||
if (updates.count > 0) {
|
||||
updateStatusWidget.empty();
|
||||
let count = updateStatusState.moduleCount || 0;
|
||||
if (updateStatusState.version) {
|
||||
count ++
|
||||
}
|
||||
$(`<span><i class="fa fa-cube"></i> ${RED._("telemetry.updateAvailable", { count: count })}</span>`).appendTo(updateStatusWidget);
|
||||
$(`<span><i class="fa fa-cube"></i> ${RED._("telemetry.updateAvailable", { count: updates.count })}</span>`).appendTo(updateStatusWidget);
|
||||
RED.statusBar.show("red-ui-status-package-update");
|
||||
} else {
|
||||
RED.statusBar.hide("red-ui-status-package-update");
|
||||
}
|
||||
RED.events.emit("registry:updates-available", updates)
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
install: install
|
||||
install: install,
|
||||
get updates() {
|
||||
const palette = [...moduleUpdates]
|
||||
let core = null
|
||||
let count = palette.length
|
||||
if (updateStatusState.version) {
|
||||
core = { current: RED.settings.version, latest: updateStatusState.version }
|
||||
count ++
|
||||
}
|
||||
return {
|
||||
count,
|
||||
core,
|
||||
palette
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in New Issue