ui: node certs: make delete button safer, add confirmation

IMO the behavior was really dangerous prev., possibly causing
downtime of API accessing stuff with a single mistaken click.

Follow our general pattern and ask for confirmation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-05-19 11:03:28 +02:00
parent b1b0fcbcd3
commit 028e4cd309

View File

@ -252,26 +252,23 @@ Ext.define('PVE.node.Certificates', {
}, },
}, },
{ {
xtype: 'button', xtype: 'proxmoxStdRemoveButton',
itemId: 'deletebtn', itemId: 'deletebtn',
text: gettext('Delete Custom Certificate'), text: gettext('Delete Custom Certificate'),
handler: function() { dangerous: true,
var me = this.up('grid'); selModel: false,
Proxmox.Utils.API2Request({ getUrl: function(rec) {
url: '/nodes/' + me.nodename + '/certificates/custom?restart=1', let view = this.up('grid');
method: 'DELETE', return `/nodes/${view.nodename}/certificates/custom?restart=1`;
success: function(response, opt) { },
var txt = gettext('pveproxy will be restarted with new certificates, please reload the GUI!'); confirmMsg: gettext('Delete custom certificate and switch to generated one?'),
Ext.getBody().mask(txt, ['pve-static-mask']); callback: function(options, success, response) {
// reload after 10 seconds automatically if (success) {
Ext.defer(function() { let txt = gettext('API server will be restarted to use new certificates, please reload web-interface!');
window.location.reload(true); Ext.getBody().mask(txt, ['pve-static-mask']);
}, 10000); // reload after 10 seconds automatically
}, Ext.defer(() => window.location.reload(true), 10000);
failure: function(response, opt) { }
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
});
}, },
}, },
'-', '-',