[pve-devel] [PATCH widget-toolkit v3 3/4] window: make buttons in SafeDestroy configurable
Michael Köppl
m.koeppl at proxmox.com
Tue Sep 30 16:58:44 CEST 2025
The SafeDestroy dialog can now feature either 1 or 2 buttons. By
default, "Remove" will be the only button. By overriding the
confirmButtonText and/or declineButtonText variables, the button texts
can be configured and the second button can be added to the dialog. This
enables additional use cases for the dialog.
Signed-off-by: Michael Köppl <m.koeppl at proxmox.com>
---
src/window/SafeDestroy.js | 37 ++++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
index ffa7d1d..4193db1 100644
--- a/src/window/SafeDestroy.js
+++ b/src/window/SafeDestroy.js
@@ -19,6 +19,10 @@ Ext.define('Proxmox.window.SafeDestroy', {
// will be displayed.
dangerous: true,
+ confirmButtonText: gettext('Remove'),
+ // second button will only be displayed if a text is given
+ declineButtonText: undefined,
+
additionalItems: [],
// gets called if we have a progress bar or taskview and it detected that
@@ -56,21 +60,21 @@ Ext.define('Proxmox.window.SafeDestroy', {
'field[name=confirm]': {
change: function (f, value) {
const view = this.getView();
- const removeButton = this.lookupReference('removeButton');
+ const confirmButton = this.lookupReference('confirmButton');
if (value === view.getItem().id.toString()) {
- removeButton.enable();
+ confirmButton.enable();
} else {
- removeButton.disable();
+ confirmButton.disable();
}
},
specialkey: function (field, event) {
- const removeButton = this.lookupReference('removeButton');
- if (!removeButton.isDisabled() && event.getKey() === event.ENTER) {
- removeButton.fireEvent('click', removeButton, event);
+ const confirmButton = this.lookupReference('confirmButton');
+ if (!confirmButton.isDisabled() && event.getKey() === event.ENTER) {
+ confirmButton.fireEvent('click', confirmButton, event);
}
},
},
- 'button[reference=removeButton]': {
+ 'button[reference=confirmButton]': {
click: function () {
const view = this.getView();
Proxmox.Utils.API2Request({
@@ -110,6 +114,12 @@ Ext.define('Proxmox.window.SafeDestroy', {
});
},
},
+ 'button[reference=declineButton]': {
+ click: function () {
+ const view = this.getView();
+ view.close();
+ },
+ },
},
},
@@ -210,14 +220,23 @@ Ext.define('Proxmox.window.SafeDestroy', {
let buttons = [
{
xtype: 'button',
- reference: 'removeButton',
- text: gettext('Remove'),
+ reference: 'confirmButton',
+ text: me.confirmButtonText,
disabled: me.dangerous,
width: 75,
margin: '0 5 0 0',
},
];
+ if (me.declineButtonText) {
+ buttons.push({
+ xtype: 'button',
+ reference: 'declineButton',
+ text: me.declineButtonText,
+ width: 75,
+ });
+ }
+
me.dockedItems = [
{
xtype: 'container',
--
2.47.3
More information about the pve-devel
mailing list