[pve-devel] [PATCH FOLLOW-UP widget-toolkit 1/1] window: remove SafeDestroy
Michael Köppl
m.koeppl at proxmox.com
Wed Sep 24 18:17:13 CEST 2025
The SafeDestroy window can be replaced by the ConfirmRemovalDialog,
which allows additional customization of the dialog. This is done
mostly to streamline the implementation, basing removal dialogs that
require additional items (such as the confirmation text field, check
boxes, etc.) on the same component.
Signed-off-by: Michael Köppl <m.koeppl at proxmox.com>
---
src/Makefile | 1 -
src/window/SafeDestroy.js | 207 --------------------------------------
2 files changed, 208 deletions(-)
delete mode 100644 src/window/SafeDestroy.js
diff --git a/src/Makefile b/src/Makefile
index a7dfa17..cb576e1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -83,7 +83,6 @@ JSSRC= \
panel/WebhookEditPanel.js \
window/Edit.js \
window/PasswordEdit.js \
- window/SafeDestroy.js \
window/ConfirmRemoveDialog.js \
window/PackageVersions.js \
window/TaskViewer.js \
diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
deleted file mode 100644
index d38f085..0000000
--- a/src/window/SafeDestroy.js
+++ /dev/null
@@ -1,207 +0,0 @@
-// Pop-up a message window where the user has to manually enter the resource ID to enable the
-// destroy confirmation button to ensure that they got the correct resource selected for.
-Ext.define('Proxmox.window.SafeDestroy', {
- extend: 'Ext.window.Window',
- alias: 'widget.proxmoxSafeDestroy',
-
- title: gettext('Confirm'),
- modal: true,
- buttonAlign: 'center',
- bodyPadding: 10,
- width: 450,
- layout: { type: 'hbox' },
- defaultFocus: 'confirmField',
- showProgress: false,
-
- additionalItems: [],
-
- // gets called if we have a progress bar or taskview and it detected that
- // the task finished. function(success)
- taskDone: Ext.emptyFn,
-
- // gets called when the api call is finished, right at the beginning
- // function(success, response, options)
- apiCallDone: Ext.emptyFn,
-
- config: {
- item: {
- id: undefined,
- formattedIdentifier: undefined,
- },
- url: undefined,
- note: undefined,
- taskName: undefined,
- params: {},
- },
-
- getParams: function () {
- let me = this;
-
- if (Ext.Object.isEmpty(me.params)) {
- return '';
- }
- return '?' + Ext.Object.toQueryString(me.params);
- },
-
- controller: {
- xclass: 'Ext.app.ViewController',
-
- control: {
- 'field[name=confirm]': {
- change: function (f, value) {
- const view = this.getView();
- const removeButton = this.lookupReference('removeButton');
- if (value === view.getItem().id.toString()) {
- removeButton.enable();
- } else {
- removeButton.disable();
- }
- },
- specialkey: function (field, event) {
- const removeButton = this.lookupReference('removeButton');
- if (!removeButton.isDisabled() && event.getKey() === event.ENTER) {
- removeButton.fireEvent('click', removeButton, event);
- }
- },
- },
- 'button[reference=removeButton]': {
- click: function () {
- const view = this.getView();
- Proxmox.Utils.API2Request({
- url: view.getUrl() + view.getParams(),
- method: 'DELETE',
- waitMsgTarget: view,
- failure: function (response, opts) {
- view.apiCallDone(false, response, opts);
- view.close();
- Ext.Msg.alert('Error', response.htmlStatus);
- },
- success: function (response, options) {
- const hasProgressBar = !!(view.showProgress && response.result.data);
-
- view.apiCallDone(true, response, options);
-
- if (hasProgressBar) {
- // stay around so we can trigger our close events
- // when background action is completed
- view.hide();
-
- const upid = response.result.data;
- const win = Ext.create('Proxmox.window.TaskProgress', {
- upid: upid,
- taskDone: view.taskDone,
- listeners: {
- destroy: function () {
- view.close();
- },
- },
- });
- win.show();
- } else {
- view.close();
- }
- },
- });
- },
- },
- },
- },
-
- buttons: [
- {
- reference: 'removeButton',
- text: gettext('Remove'),
- disabled: true,
- },
- ],
-
- initComponent: function () {
- let me = this;
-
- me.items = [
- {
- xtype: 'component',
- cls: [
- Ext.baseCSSPrefix + 'message-box-icon',
- Ext.baseCSSPrefix + 'message-box-warning',
- Ext.baseCSSPrefix + 'dlg-icon',
- ],
- },
- {
- xtype: 'container',
- flex: 1,
- layout: {
- type: 'vbox',
- align: 'stretch',
- },
- items: [
- {
- xtype: 'component',
- reference: 'messageCmp',
- },
- {
- itemId: 'confirmField',
- reference: 'confirmField',
- xtype: 'textfield',
- name: 'confirm',
- labelWidth: 300,
- hideTrigger: true,
- allowBlank: false,
- },
- ]
- .concat(me.additionalItems)
- .concat([
- {
- xtype: 'container',
- reference: 'noteContainer',
- flex: 1,
- hidden: true,
- layout: {
- type: 'vbox',
- },
- items: [
- {
- xtype: 'component',
- reference: 'noteCmp',
- userCls: 'pmx-hint',
- },
- ],
- },
- ]),
- },
- ];
-
- me.callParent();
-
- const itemId = me.getItem().id;
- if (!Ext.isDefined(itemId)) {
- throw 'no ID specified';
- }
-
- if (Ext.isDefined(me.getNote())) {
- me.lookupReference('noteCmp').setHtml(
- `<span title="${me.getNote()}">${me.getNote()}</span>`,
- );
- const noteContainer = me.lookupReference('noteContainer');
- noteContainer.setHidden(false);
- noteContainer.setDisabled(false);
- }
-
- let taskName = me.getTaskName();
- if (Ext.isDefined(taskName)) {
- me.lookupReference('messageCmp').setHtml(
- Ext.htmlEncode(
- Proxmox.Utils.format_task_description(
- taskName,
- me.getItem().formattedIdentifier ?? itemId,
- ),
- ),
- );
- } else {
- throw 'no task name specified';
- }
-
- let label = `${gettext('Please enter the ID to confirm')} (${itemId})`;
- me.lookupReference('confirmField').setFieldLabel(Ext.htmlEncode(label));
- },
-});
--
2.47.3
More information about the pve-devel
mailing list