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 widget-toolkit v3 1/4] window: refactor construction of SafeDestroy items
Date: Tue, 30 Sep 2025 16:58:42 +0200	[thread overview]
Message-ID: <20250930145848.263162-6-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20250930145848.263162-1-m.koeppl@proxmox.com>

This is done to make extending SafeDestroy with additional functionality
easier.

Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
No functional change intended here. I mostly split the widget-toolkit
patches up into multiple parts to make review of the individual
extensions of the dialog easier. This is the first step that makes later
changes easier to implement and understand.

 src/window/SafeDestroy.js | 175 +++++++++++++++++++++-----------------
 1 file changed, 96 insertions(+), 79 deletions(-)

diff --git a/src/window/SafeDestroy.js b/src/window/SafeDestroy.js
index d38f085..76096cb 100644
--- a/src/window/SafeDestroy.js
+++ b/src/window/SafeDestroy.js
@@ -107,101 +107,118 @@ Ext.define('Proxmox.window.SafeDestroy', {
         },
     },
 
-    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',
-                ],
-            },
-            {
+        let body = {
+            xtype: 'container',
+            layout: 'hbox',
+            items: [
+                {
+                    xtype: 'component',
+                    cls: [
+                        Ext.baseCSSPrefix + 'message-box-icon',
+                        Ext.baseCSSPrefix + 'dlg-icon',
+                        Ext.baseCSSPrefix + 'message-box-warning',
+                    ],
+                },
+            ],
+        };
+
+        const itemId = me.getItem().id;
+        if (!Ext.isDefined(itemId)) {
+            throw 'no ID specified';
+        }
+
+        const taskName = me.getTaskName();
+        let label = `${gettext('Please enter the ID to confirm')} (${itemId})`;
+
+        let content = {
+            xtype: 'container',
+            layout: 'vbox',
+            items: [
+                {
+                    xtype: 'component',
+                    reference: 'messageCmp',
+                    html: Ext.htmlEncode(
+                        Proxmox.Utils.format_task_description(
+                            taskName,
+                            me.getItem().formattedIdentifier ?? itemId,
+                        ),
+                    ),
+                },
+                {
+                    itemId: 'confirmField',
+                    reference: 'confirmField',
+                    xtype: 'textfield',
+                    name: 'confirm',
+                    padding: '5 0 0 0',
+                    width: 340,
+                    labelWidth: 240,
+                    fieldLabel: label,
+                    hideTrigger: true,
+                    allowBlank: false,
+                },
+            ],
+        };
+
+        if (me.additionalItems && me.additionalItems.length > 0) {
+            content.items.push({
                 xtype: 'container',
+                height: 5,
+            });
+            for (const item of me.additionalItems) {
+                content.items.push(item);
+            }
+        }
+
+        if (Ext.isDefined(me.getNote())) {
+            content.items.push({
+                xtype: 'container',
+                reference: 'noteContainer',
                 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,
+                        reference: 'noteCmp',
+                        userCls: 'pmx-hint',
+                        html: `<span title="${me.getNote()}">${me.getNote()}</span>`,
                     },
-                ]
-                    .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();
+        body.items.push(content);
 
-        const itemId = me.getItem().id;
-        if (!Ext.isDefined(itemId)) {
-            throw 'no ID specified';
-        }
+        me.items = [body];
 
-        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 buttons = [
+            {
+                xtype: 'button',
+                reference: 'removeButton',
+                text: gettext('Remove'),
+                disabled: true,
+                width: 75,
+                margin: '0 5 0 0',
+            },
+        ];
 
-        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';
-        }
+        me.dockedItems = [
+            {
+                xtype: 'container',
+                dock: 'bottom',
+                cls: ['x-toolbar', 'x-toolbar-footer'],
+                layout: {
+                    type: 'hbox',
+                    pack: 'center',
+                },
+                items: buttons,
+            },
+        ];
 
-        let label = `${gettext('Please enter the ID to confirm')} (${itemId})`;
-        me.lookupReference('confirmField').setFieldLabel(Ext.htmlEncode(label));
+        me.callParent();
     },
 });
-- 
2.47.3



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

  parent reply	other threads:[~2025-09-30 15:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-30 14:58 [pve-devel] [PATCH container/docs/ha-manager/manager/widget-toolkit/qemu-server v3 00/11] fix #6613: update HA rules upon resource deletion Michael Köppl
2025-09-30 14:58 ` [pve-devel] [PATCH ha-manager v3 1/2] fix #6613: update rules containing the resource to be deleted Michael Köppl
2025-09-30 14:58 ` [pve-devel] [PATCH ha-manager v3 2/2] api: add purge parameter for resource deletion Michael Köppl
2025-09-30 14:58 ` [pve-devel] [PATCH qemu-server v3 1/1] fix #6613: pass purge param to delete_service_from_config Michael Köppl
2025-09-30 14:58 ` [pve-devel] [PATCH container " Michael Köppl
2025-09-30 14:58 ` Michael Köppl [this message]
2025-09-30 14:58 ` [pve-devel] [PATCH widget-toolkit v3 2/4] window: introduce dangerous parameter to SafeDestroy Michael Köppl
2025-09-30 14:58 ` [pve-devel] [PATCH widget-toolkit v3 3/4] window: make buttons in SafeDestroy configurable Michael Köppl
2025-09-30 14:58 ` [pve-devel] [PATCH widget-toolkit v3 4/4] window: add more general base dialog, make SafeDestroy concrete Michael Köppl
2025-09-30 14:58 ` [pve-devel] [PATCH manager v3 1/2] ui: add ConfirmRemoveResource window Michael Köppl
2025-09-30 14:58 ` [pve-devel] [PATCH manager v3 2/2] ui: use ConfirmRemoveResource window for removing resources Michael Köppl
2025-09-30 14:58 ` [pve-devel] [PATCH docs v3 1/1] add notes about effects of purge flag for resource and guest removal 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=20250930145848.263162-6-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