]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
utils: add helper to format node's repository status
authorFabian Ebner <f.ebner@proxmox.com>
Fri, 9 Jul 2021 12:44:14 +0000 (14:44 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 9 Jul 2021 14:58:51 +0000 (16:58 +0200)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
src/Utils.js

index ab85deeda32796e2121a7980876b4e37f622c5cb..19ce1f2bb1b1d0278754e786d276c9b93cd2aa6e 100644 (file)
@@ -1151,6 +1151,27 @@ utilities: {
        return icon;
     },
 
+    formatNodeRepoStatus: function(status, product) {
+       let fmt = (txt, cls) => `<i class="fa fa-fw fa-lg fa-${cls}"></i>${txt}`;
+
+       let getUpdates = Ext.String.format(gettext('{0} updates'), product);
+       let noRepo = Ext.String.format(gettext('No {0} repository enabled!'), product);
+
+       if (status === 'ok') {
+           return fmt(getUpdates, 'check-circle good') + ' ' +
+               fmt(gettext('Production-ready Enterprise repository enabled'), 'check-circle good');
+       } else if (status === 'no-sub') {
+           return fmt(gettext('Production-ready Enterprise repository enabled'), 'check-circle good') + ' ' +
+                   fmt(gettext('Enterprise repository needs valid subscription'), 'exclamation-circle warning');
+       } else if (status === 'non-production') {
+           return fmt(getUpdates, 'check-circle good') + ' ' +
+                  fmt(gettext('Non production-ready repository enabled!'), 'exclamation-circle warning');
+       } else if (status === 'no-repo') {
+           return fmt(noRepo, 'exclamation-circle critical');
+       }
+
+       return Proxmox.Utils.unknownText;
+    },
 },
 
     singleton: true,