From df7def01a1e8a2b9909cf06212418b3e274e5ccf Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 2 Jul 2021 23:12:53 +0200 Subject: [PATCH] ui: repo status: code cleanup/refactoring Signed-off-by: Thomas Lamprecht --- src/node/APTRepositories.js | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js index eb22ba1..f34ebd8 100644 --- a/src/node/APTRepositories.js +++ b/src/node/APTRepositories.js @@ -433,16 +433,27 @@ Ext.define('Proxmox.node.APTRepositories', { let store = vm.get('errorstore'); store.removeAll(); + 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 text = gettext('Repositories are configured in a recommended way'); - let status = 'good'; + let addGood = message => store.add({ status: 'good', message }); + + let addWarn = message => { + if (status === 'good') { + status = 'warning'; + text = message; + } + store.add({ status: 'warning', message }); + }; let activeSubscription = vm.get('subscriptionActive'); let enterprise = vm.get('enterpriseRepo'); @@ -450,22 +461,6 @@ Ext.define('Proxmox.node.APTRepositories', { let test = vm.get('testRepo'); let wrongSuites = vm.get('suitesWarning'); - let addGood = function(message) { - store.add({ - status: 'good', - message, - }); - }; - - let addWarn = function(message) { - status = 'warning'; - text = message; - store.add({ - status, - message, - }); - }; - if (!enterprise && !nosubscription && !test) { addWarn(Ext.String.format(gettext('No {0} repository is enabled!'), vm.get('product'))); } else if (enterprise && !nosubscription && !test && activeSubscription) { @@ -491,11 +486,7 @@ Ext.define('Proxmox.node.APTRepositories', { } if (errors.length > 0) { - vm.set('state', { - iconCls: Proxmox.Utils.get_health_icon('critical', true), - text: gettext('Error parsing repositories'), - }); - return; + text = gettext('Error parsing repositories'); } let iconCls = Proxmox.Utils.get_health_icon(status, true); -- 2.39.2