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
2022-04-26 06:23:34 +00:00
committed by Thomas Lamprecht
parent fbd6f54f39
commit 1b7479c968
3 changed files with 17 additions and 15 deletions

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 {