From 7c65b8bfe023d46e77e37db2d4ff5f127643f679 Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Fri, 9 Jul 2021 14:44:14 +0200 Subject: [PATCH] utils: add helper to format node's repository status Signed-off-by: Fabian Ebner --- src/Utils.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Utils.js b/src/Utils.js index ab85dee..19ce1f2 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -1151,6 +1151,27 @@ utilities: { return icon; }, + formatNodeRepoStatus: function(status, product) { + let fmt = (txt, cls) => `${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,