From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4F82770C0D for ; Thu, 30 Sep 2021 13:42:53 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 39AF61EDC8 for ; Thu, 30 Sep 2021 13:42:23 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 0AD111ED33 for ; Thu, 30 Sep 2021 13:42:20 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id D706244C4E for ; Thu, 30 Sep 2021 13:42:19 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Thu, 30 Sep 2021 13:42:12 +0200 Message-Id: <20210930114215.240095-10-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210930114215.240095-1-f.ebner@proxmox.com> References: <20210930114215.240095-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -1.304 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% ENA_SUBJ_ODD_CASE 3.2 Subject has odd case KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 manager 2/5] ui: storage content: avoid redundant options hasNotesColumn and hideColumns X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2021 11:42:53 -0000 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 --- 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