From c0eadd5543acd027049d24d415c79a1390d6bcfb Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Thu, 30 Sep 2021 13:42:12 +0200 Subject: [PATCH] ui: storage content: avoid redundant options hasNotesColumn and hideColumns Replace both by a showColumns option instead. As the current use of hasNotesColumn already indicates, when new content-specific columns are added, it is more natural for each derived class to specify the columns it wants, rather than those it doesn't. For hideColumns, there was no user. For hasNotesColumn, the only user was the backup view. Set the column information in the storage.BackupView class itself rather than the instance (like hasNotesColumn was). Signed-off-by: Fabian Ebner --- www/manager6/storage/BackupView.js | 2 ++ www/manager6/storage/Browser.js | 1 - www/manager6/storage/ContentView.js | 14 ++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/www/manager6/storage/BackupView.js b/www/manager6/storage/BackupView.js index 0613c94d..5fec3b18 100644 --- a/www/manager6/storage/BackupView.js +++ b/www/manager6/storage/BackupView.js @@ -3,6 +3,8 @@ Ext.define('PVE.storage.BackupView', { alias: 'widget.pveStorageBackupView', + showColumns: ['name', 'notes', 'date', 'format', 'size'], + initComponent: function() { var me = this; diff --git a/www/manager6/storage/Browser.js b/www/manager6/storage/Browser.js index fe5df3e2..1916ff6a 100644 --- a/www/manager6/storage/Browser.js +++ b/www/manager6/storage/Browser.js @@ -63,7 +63,6 @@ Ext.define('PVE.storage.Browser', { iconCls: 'fa fa-floppy-o', itemId: 'contentBackup', pluginType: plugin, - hasNotesColumn: true, }); } if (contents.includes('images')) { diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js index 3f5b686b..9ba2b4ce 100644 --- a/www/manager6/storage/ContentView.js +++ b/www/manager6/storage/ContentView.js @@ -371,12 +371,14 @@ Ext.define('PVE.storage.ContentView', { }, }; - if (me.hideColumns) { - me.hideColumns.forEach(key => delete availableColumns[key]); - } - if (!me.hasNotesColumn) { - delete availableColumns.notes; - } + let showColumns = me.showColumns || ['name', 'date', 'format', 'size']; + + Object.keys(availableColumns).forEach(function(key) { + if (!showColumns.includes(key)) { + delete availableColumns[key]; + } + }); + if (me.extraColumns && typeof me.extraColumns === 'object') { Object.assign(availableColumns, me.extraColumns); }