[pbs-devel] [PATCH proxmox-backup 2/2] ui: datastore/Content: change group remove to SafeDestroy Window

Dominik Csapak d.csapak at proxmox.com
Mon May 17 09:03:15 CEST 2021


so that a user does not accidentally remove a whole group instead
of a snapshot

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/Utils.js             |  1 +
 www/datastore/Content.js | 68 +++++++++++++++++++++++++---------------
 2 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/www/Utils.js b/www/Utils.js
index 14561ad4..f614d77e 100644
--- a/www/Utils.js
+++ b/www/Utils.js
@@ -384,6 +384,7 @@ Ext.define('PBS.Utils', {
 	    dirremove: [gettext('Directory'), gettext('Remove')],
 	    'eject-media': [gettext('Drive'), gettext('Eject Media')],
 	    "format-media": [gettext('Drive'), gettext('Format media')],
+	    "forget-group": [gettext('Group'), gettext('Remove Group')],
 	    garbage_collection: ['Datastore', gettext('Garbage Collect')],
 	    'inventory-update': [gettext('Drive'), gettext('Inventory Update')],
 	    'label-media': [gettext('Drive'), gettext('Label Media')],
diff --git a/www/datastore/Content.js b/www/datastore/Content.js
index ca90f82a..5be5bb93 100644
--- a/www/datastore/Content.js
+++ b/www/datastore/Content.js
@@ -374,38 +374,35 @@ Ext.define('PBS.DataStoreContent', {
 	    });
 	},
 
-	onForget: function(view, rI, cI, item, e, rec) {
+	forgetGroup: function(data) {
 	    let me = this;
-	    view = this.getView();
-
-	    if (!(rec && rec.data)) return;
-	    let data = rec.data;
-	    if (!view.datastore) return;
+	    let view = me.getView();
 
-	    let params;
-	    let message;
-	    let url;
-	    if (rec.parentNode.id !== 'root') {
-		message = Ext.String.format(gettext('Are you sure you want to remove snapshot {0}'), `'${data.text}'`);
-		url = `/admin/datastore/${view.datastore}/snapshots`;
-		params = {
-		    "backup-type": data["backup-type"],
-		    "backup-id": data["backup-id"],
-		    "backup-time": (data['backup-time'].getTime()/1000).toFixed(0),
-		};
-	    } else {
-		message = Ext.String.format(gettext('Are you sure you want to remove group {0}'), `'${data.text}'`);
-		url = `/admin/datastore/${view.datastore}/groups`;
-		params = {
+	    Ext.create('Proxmox.window.SafeDestroy', {
+		url: `/admin/datastore/${view.datastore}/groups`,
+		params: {
 		    "backup-type": data.backup_type,
 		    "backup-id": data.backup_id,
-		};
-	    }
+		},
+		item: {
+		    id: data.text,
+		},
+		autoShow: true,
+		taskName: 'forget-group',
+		listeners: {
+		    destroy: () => me.reload(),
+		},
+	    });
+	},
+
+	forgetSnapshot: function(data) {
+	    let me = this;
+	    let view = me.getView();
 
 	    Ext.Msg.show({
 		title: gettext('Confirm'),
 		icon: Ext.Msg.WARNING,
-		message,
+		message: Ext.String.format(gettext('Are you sure you want to remove snapshot {0}'), `'${data.text}'`),
 		buttons: Ext.Msg.YESNO,
 		defaultFocus: 'no',
 		callback: function(btn) {
@@ -414,8 +411,12 @@ Ext.define('PBS.DataStoreContent', {
 		    }
 
 		    Proxmox.Utils.API2Request({
-			url,
-			params,
+			url: `/admin/datastore/${view.datastore}/snapshots`,
+			params: {
+			    "backup-type": data["backup-type"],
+			    "backup-id": data["backup-id"],
+			    "backup-time": (data['backup-time'].getTime()/1000).toFixed(0),
+			},
 			method: 'DELETE',
 			waitMsgTarget: view,
 			failure: function(response, opts) {
@@ -427,6 +428,21 @@ Ext.define('PBS.DataStoreContent', {
 	    });
 	},
 
+	onForget: function(view, rI, cI, item, e, rec) {
+	    let me = this;
+	    view = this.getView();
+
+	    if (!(rec && rec.data)) return;
+	    let data = rec.data;
+	    if (!view.datastore) return;
+
+	    if (rec.parentNode.id !== 'root') {
+		me.forgetSnapshot(data);
+	    } else {
+		me.forgetGroup(data);
+	    }
+	},
+
 	downloadFile: function(tV, rI, cI, item, e, rec) {
 	    let me = this;
 	    let view = me.getView();
-- 
2.20.1






More information about the pbs-devel mailing list