ui: datastore/Content: change group remove to SafeDestroy Window
so that a user does not accidentally remove a whole group instead of a snapshot Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
7ba99fef86
commit
a904e3755d
@ -384,6 +384,7 @@ Ext.define('PBS.Utils', {
|
|||||||
dirremove: [gettext('Directory'), gettext('Remove')],
|
dirremove: [gettext('Directory'), gettext('Remove')],
|
||||||
'eject-media': [gettext('Drive'), gettext('Eject Media')],
|
'eject-media': [gettext('Drive'), gettext('Eject Media')],
|
||||||
"format-media": [gettext('Drive'), gettext('Format media')],
|
"format-media": [gettext('Drive'), gettext('Format media')],
|
||||||
|
"forget-group": [gettext('Group'), gettext('Remove Group')],
|
||||||
garbage_collection: ['Datastore', gettext('Garbage Collect')],
|
garbage_collection: ['Datastore', gettext('Garbage Collect')],
|
||||||
'inventory-update': [gettext('Drive'), gettext('Inventory Update')],
|
'inventory-update': [gettext('Drive'), gettext('Inventory Update')],
|
||||||
'label-media': [gettext('Drive'), gettext('Label Media')],
|
'label-media': [gettext('Drive'), gettext('Label Media')],
|
||||||
|
@ -374,38 +374,35 @@ Ext.define('PBS.DataStoreContent', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onForget: function(view, rI, cI, item, e, rec) {
|
forgetGroup: function(data) {
|
||||||
let me = this;
|
let me = this;
|
||||||
view = this.getView();
|
let view = me.getView();
|
||||||
|
|
||||||
if (!(rec && rec.data)) return;
|
Ext.create('Proxmox.window.SafeDestroy', {
|
||||||
let data = rec.data;
|
url: `/admin/datastore/${view.datastore}/groups`,
|
||||||
if (!view.datastore) return;
|
params: {
|
||||||
|
|
||||||
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 = {
|
|
||||||
"backup-type": data.backup_type,
|
"backup-type": data.backup_type,
|
||||||
"backup-id": data.backup_id,
|
"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({
|
Ext.Msg.show({
|
||||||
title: gettext('Confirm'),
|
title: gettext('Confirm'),
|
||||||
icon: Ext.Msg.WARNING,
|
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,
|
buttons: Ext.Msg.YESNO,
|
||||||
defaultFocus: 'no',
|
defaultFocus: 'no',
|
||||||
callback: function(btn) {
|
callback: function(btn) {
|
||||||
@ -414,8 +411,12 @@ Ext.define('PBS.DataStoreContent', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Proxmox.Utils.API2Request({
|
Proxmox.Utils.API2Request({
|
||||||
url,
|
url: `/admin/datastore/${view.datastore}/snapshots`,
|
||||||
params,
|
params: {
|
||||||
|
"backup-type": data["backup-type"],
|
||||||
|
"backup-id": data["backup-id"],
|
||||||
|
"backup-time": (data['backup-time'].getTime()/1000).toFixed(0),
|
||||||
|
},
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
waitMsgTarget: view,
|
waitMsgTarget: view,
|
||||||
failure: function(response, opts) {
|
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) {
|
downloadFile: function(tV, rI, cI, item, e, rec) {
|
||||||
let me = this;
|
let me = this;
|
||||||
let view = me.getView();
|
let view = me.getView();
|
||||||
|
Loading…
Reference in New Issue
Block a user