[pve-devel] [PATCH v2 manager 2/5] ui: storage content: avoid redundant options hasNotesColumn and hideColumns

Fabian Ebner f.ebner at proxmox.com
Thu Sep 30 13:42:12 CEST 2021


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 <f.ebner at proxmox.com>
---

New in v2.

 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);
 	}
-- 
2.30.2






More information about the pve-devel mailing list