ui: utils: add function for parsing maintenance mode

...since the same code is used is more than one place

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
This commit is contained in:
Hannes Laimer authored and Thomas Lamprecht committed 2022-04-27 19:21:19 +02:00
1 parent fbd6f54f39
commit 1b7479c968
3 files changed
+17 -15

No files matched your search

+2 -5
View File
@@ -49,12 +49,9 @@ Ext.define('PBS.DataStoreInfo', {
success: function(response) {
const config = response.result.data;
if (config['maintenance-mode']) {
const [_type, msg] = config['maintenance-mode'].split(/,(.+)/);
const message = msg ? ': ' + msg.split("=")[1]
.replace(/^"(.*)"$/, '$1')
.replaceAll('\\"', '"') : '';
const [_type, msg] = PBS.Utils.parseMaintenanceMode(config['maintenance-mode']);
me.view.el.mask(
`${gettext('Datastore is in maintenance mode')}${message}`,
`${gettext('Datastore is in maintenance mode')}${msg ? ': ' + msg : ''}`,
'fa pbs-maintenance-mask',
);
} else {