From: Thomas Lamprecht Date: Mon, 5 Jul 2021 14:38:14 +0000 (+0200) Subject: node: repos: factor out addCritical into closure X-Git-Url: https://git.proxmox.com/?p=proxmox-widget-toolkit.git;a=commitdiff_plain;h=6c9af17882a855edfa48ec933beb38de386ed556 node: repos: factor out addCritical into closure now that there's more use for it Signed-off-by: Thomas Lamprecht --- diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js index e30396b..c7cbc54 100644 --- a/src/node/APTRepositories.js +++ b/src/node/APTRepositories.js @@ -436,17 +436,7 @@ Ext.define('Proxmox.node.APTRepositories', { let status = 'good'; // start with best, the helper below will downgrade if needed let text = gettext('All OK, you have production-ready repositories configured!'); - let errors = vm.get('errors'); - errors.forEach((error) => { - status = 'critical'; - store.add({ - status: 'critical', - message: `${error.path} - ${error.error}`, - }); - }); - let addGood = message => store.add({ status: 'good', message }); - let addWarn = (message, important) => { if (status !== 'critical') { status = 'warning'; @@ -454,6 +444,14 @@ Ext.define('Proxmox.node.APTRepositories', { } store.add({ status: 'warning', message }); }; + let addCritical = (message, important) => { + status = 'critical'; + text = important ? message : gettext('Error'); + store.add({ status: 'critical', message }); + }; + + let errors = vm.get('errors'); + errors.forEach(error => addCritical(`${error.path} - ${error.error}`)); let activeSubscription = vm.get('subscriptionActive'); let enterprise = vm.get('enterpriseRepo'); @@ -462,12 +460,9 @@ Ext.define('Proxmox.node.APTRepositories', { let wrongSuites = vm.get('suitesWarning'); if (!enterprise && !nosubscription && !test) { - status = 'critical'; - text = gettext('Error'); - store.add({ - status: 'critical', - message: Ext.String.format(gettext('No {0} repository is enabled, you do not get any updates!'), vm.get('product')), - }); + addCritical( + Ext.String.format(gettext('No {0} repository is enabled, you do not get any updates!'), vm.get('product')), + ); } else if (enterprise && !nosubscription && !test && activeSubscription) { addGood(Ext.String.format(gettext('You get supported updates for {0}'), vm.get('product'))); } else if (nosubscription || test) {