all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 1/2] ui: backup: disable remove button when backup is protected
Date: Fri, 12 Nov 2021 12:28:33 +0100	[thread overview]
Message-ID: <20211112112834.40892-1-f.ebner@proxmox.com> (raw)

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 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





             reply	other threads:[~2021-11-12 11:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12 11:28 Fabian Ebner [this message]
2021-11-12 11:28 ` [pve-devel] [PATCH manager 2/2] ui: backup: protect button: use dynamic protect/unprotect text Fabian Ebner
2022-03-16 16:36   ` Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211112112834.40892-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal