]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
ui: repo status: code cleanup/refactoring
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 2 Jul 2021 21:12:53 +0000 (23:12 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 2 Jul 2021 21:12:53 +0000 (23:12 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/node/APTRepositories.js

index eb22ba1cb2426d51fabdc40c6eab33ae0c96bf90..f34ebd8812567b1358d4a92155051a1912b2c469 100644 (file)
@@ -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);