public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH FOLLOW-UP widget-toolkit 1/1] window: remove SafeDestroy
Date: Wed, 24 Sep 2025 18:17:13 +0200	[thread overview]
Message-ID: <20250924161714.434858-2-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20250924161714.434858-1-m.koeppl@proxmox.com>

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@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



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

  reply	other threads:[~2025-09-24 16:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24 16:17 [pve-devel] [PATCH FOLLOW-UP manager/widget-toolkit 0/2] replace SafeDestroy Michael Köppl
2025-09-24 16:17 ` Michael Köppl [this message]
2025-09-24 16:17 ` [pve-devel] [PATCH FOLLOW-UP manager 1/1] ui: replace SafeDestroy with ConfirmRemoveDialog Michael Köppl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250924161714.434858-2-m.koeppl@proxmox.com \
    --to=m.koeppl@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal