From c15b058db7ce3b35668de63d7f77a6a1fe37d8d0 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 17 May 2022 08:52:13 +0200 Subject: [PATCH] ui: form/DataStoreSelector: show maintenance mode in selector to not having to query the activeTasks everywhere, change the renderer to omit the check/spinner when no activeTasks are given Signed-off-by: Dominik Csapak --- www/Utils.js | 17 ++++++++++------- www/form/DataStoreSelector.js | 9 +++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/www/Utils.js b/www/Utils.js index 52d24348..a2349033 100644 --- a/www/Utils.js +++ b/www/Utils.js @@ -663,14 +663,17 @@ Ext.define('PBS.Utils', { let [type, message] = PBS.Utils.parseMaintenanceMode(mode); - const conflictingTasks = activeTasks.write + (type === 'offline' ? activeTasks.read : 0); - let extra = ''; - if (conflictingTasks > 0) { - extra += '| '; - extra += Ext.String.format(gettext('{0} conflicting tasks still active.'), conflictingTasks); - } else { - extra += ''; + + if (activeTasks !== undefined) { + const conflictingTasks = activeTasks.write + (type === 'offline' ? activeTasks.read : 0); + + if (conflictingTasks > 0) { + extra += '| '; + extra += Ext.String.format(gettext('{0} conflicting tasks still active.'), conflictingTasks); + } else { + extra += ''; + } } if (message) { diff --git a/www/form/DataStoreSelector.js b/www/form/DataStoreSelector.js index a1471a84..90f20bee 100644 --- a/www/form/DataStoreSelector.js +++ b/www/form/DataStoreSelector.js @@ -29,6 +29,15 @@ Ext.define('PBS.form.DataStoreSelector', { renderer: Ext.String.htmlEncode, flex: 1, }, + { + header: gettext('Maintenance'), + sortable: true, + dataIndex: 'maintenance', + renderer: (value) => { + return PBS.Utils.renderMaintenance(value); + }, + flex: 1, + } ], }, });