all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager 1/2] ui: backup: disable remove button when backup is protected
@ 2021-11-12 11:28 Fabian Ebner
  2021-11-12 11:28 ` [pve-devel] [PATCH manager 2/2] ui: backup: protect button: use dynamic protect/unprotect text Fabian Ebner
  0 siblings, 1 reply; 3+ messages in thread
From: Fabian Ebner @ 2021-11-12 11:28 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-16 16:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12 11:28 [pve-devel] [PATCH manager 1/2] ui: backup: disable remove button when backup is protected Fabian Ebner
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

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