mirror of https://github.com/node-red/node-red.git
Merge 141b14237d into abe6593202
commit
0f855991bd
|
|
@ -684,7 +684,7 @@
|
|||
"title": "Remove nodes"
|
||||
},
|
||||
"removePlugin": {
|
||||
"body": "<p>Removed plugin __module__. Please reload the editor to clear left-overs.</p>"
|
||||
"body": "<p>Removed plugin __module__. Please reload the editor to continue.</p>"
|
||||
},
|
||||
"update": {
|
||||
"body": "<p>Updating '__module__'</p><p>Updating the node will require a restart of Node-RED to complete the update. This must be done manually.</p>",
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@
|
|||
"title": "Supprimer les noeuds"
|
||||
},
|
||||
"removePlugin": {
|
||||
"body": "<p>Suppression du plugin '__module__'. Veuillez recharger l'éditeur afin d'appliquer les changements.</p>"
|
||||
"body": "<p>Suppression du plugin '__module__'. Veuillez recharger l'éditeur pour continuer.</p>"
|
||||
},
|
||||
"update": {
|
||||
"body": "<p>Mise à jour de '__module__'</p><p>La mise à jour du noeud nécessitera un redémarrage de Node-RED pour terminer la mise à jour. Cela doit être fait manuellement.</p>",
|
||||
|
|
|
|||
|
|
@ -1624,23 +1624,40 @@ RED.palette.editor = (function() {
|
|||
refreshUpdateStatus();
|
||||
}
|
||||
|
||||
const pluginList = [];
|
||||
Object.entries(entry.pluginSet).forEach(([key, set]) => {
|
||||
if (set.plugins && set.plugins.length) {
|
||||
// Adds ID of plugins that exist in the runtime and possibly in the editor
|
||||
pluginList.push(...set.plugins.map((plugin) => plugin.id));
|
||||
} else {
|
||||
// Adds plugin ID that only exist in the editor
|
||||
pluginList.push(key);
|
||||
}
|
||||
});
|
||||
|
||||
// We assume that a plugin that implements onremove
|
||||
// cleans the editor accordingly of its left-overs.
|
||||
let found_onremove = true;
|
||||
|
||||
let keys = Object.keys(entry.pluginSet);
|
||||
keys.forEach((key) => {
|
||||
let set = entry.pluginSet[key];
|
||||
for (let i=0; i<set.plugins?.length; i++) {
|
||||
let plgn = RED.plugins.getPlugin(set.plugins[i].id);
|
||||
if (plgn && plgn.onremove && typeof plgn.onremove === 'function') {
|
||||
plgn.onremove();
|
||||
} else {
|
||||
if (plgn && plgn.onadd && typeof plgn.onadd === 'function') {
|
||||
// if there's no 'onadd', there shouldn't be any left-overs
|
||||
found_onremove = false;
|
||||
pluginList.forEach((id) => {
|
||||
const plugin = RED.plugins.getPlugin(id);
|
||||
if (plugin) {
|
||||
if (typeof plugin.onremove === 'function') {
|
||||
try {
|
||||
plugin.onremove();
|
||||
} catch (error) {
|
||||
console.warn(`Error while calling 'onremove' for plugin '${id}': `, error);
|
||||
}
|
||||
} else if (typeof plugin.onadd === 'function') {
|
||||
// We assume that the plugin adds something to the editor but is not able to remove it
|
||||
// Notify the user to refresh the editor to remove that plugin
|
||||
found_onremove = false;
|
||||
} else {
|
||||
// If there's no 'onadd', there shouldn't be any left-overs
|
||||
}
|
||||
} else {
|
||||
// Either the plugin exists only in the runtime or it is a known limitation
|
||||
// of purely editor plugins which must have their ID identical to that
|
||||
// defined in the package.json
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue