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 648317F419 for ; Fri, 12 Nov 2021 12:29:09 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 59C3318B80 for ; Fri, 12 Nov 2021 12:28:39 +0100 (CET) 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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id E8EA518B6A for ; Fri, 12 Nov 2021 12:28:37 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C46C74366A for ; Fri, 12 Nov 2021 12:28:37 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 12 Nov 2021 12:28:33 +0100 Message-Id: <20211112112834.40892-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.190 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [me.storage] Subject: [pve-devel] [PATCH manager 1/2] ui: backup: disable remove button when backup is protected 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: Fri, 12 Nov 2021 11:29:09 -0000 Suggested-by: Thomas Lamprecht Signed-off-by: Fabian Ebner --- www/manager6/grid/BackupView.js | 18 +++++++++++++++++- www/manager6/storage/BackupView.js | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/www/manager6/grid/BackupView.js b/www/manager6/grid/BackupView.js index fdc385a8..c08fb67d 100644 --- a/www/manager6/grid/BackupView.js +++ b/www/manager6/grid/BackupView.js @@ -8,6 +8,12 @@ Ext.define('PVE.grid.BackupView', { stateful: true, stateId: 'grid-guest-backup', + updateButtonStatus: function(record) { + let me = this; + + me.down('#removeButton').updateStatus(record); + }, + initComponent: function() { var me = this; @@ -62,7 +68,10 @@ Ext.define('PVE.grid.BackupView', { vmtypeFilter, searchFilter, vmidFilter, - ], + ], + listeners: { + load: () => me.updateButtonStatus(me.selModel.getSelection()[0]), + }, }); let updateFilter = function() { @@ -197,6 +206,10 @@ Ext.define('PVE.grid.BackupView', { selModel: sm, dangerous: true, delay: 5, + itemId: 'removeButton', + updateStatus: function(record) { + this.setDisabled(!record || record.data.protected); + }, confirmMsg: function(rec) { var msg = Ext.String.format(gettext('Are you sure you want to remove entry {0}'), "'" + rec.data.volid + "'"); @@ -379,6 +392,9 @@ Ext.define('PVE.grid.BackupView', { renderer: PVE.Utils.render_backup_verification, }, ], + listeners: { + selectionchange: (model, records) => me.updateButtonStatus(records[0]), + }, }); me.callParent(); diff --git a/www/manager6/storage/BackupView.js b/www/manager6/storage/BackupView.js index dca140fe..42fd6623 100644 --- a/www/manager6/storage/BackupView.js +++ b/www/manager6/storage/BackupView.js @@ -5,6 +5,14 @@ Ext.define('PVE.storage.BackupView', { showColumns: ['name', 'notes', 'protected', 'date', 'format', 'size'], + useCustomRemoveButton: true, + + updateButtonStatus: function(record) { + let me = this; + + me.down('#removeButton').updateStatus(record); + }, + initComponent: function() { var me = this; @@ -189,6 +197,18 @@ Ext.define('PVE.storage.BackupView', { }, '-', pruneButton, + { + xtype: 'proxmoxStdRemoveButton', + itemId: 'removeButton', + selModel: sm, + delay: 5, + callback: () => reload(), + baseurl: `/api2/extjs/nodes/${nodename}/storage/${me.storage}/content`, + enableFn: (record) => !record.data.protected, + updateStatus: function(record) { // enableFn is not called after store load + this.setDisabled(!record || record.data.protected); + }, + }, ); if (isPBS) { @@ -207,5 +227,7 @@ Ext.define('PVE.storage.BackupView', { } me.callParent(); + + me.store.on('load', () => me.updateButtonStatus(me.selModel.getSelection()[0])); }, }); -- 2.30.2