public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager 5/5] aliases: Add option to update references on rename/delete
Date: Tue,  7 Apr 2026 09:36:58 +0200	[thread overview]
Message-ID: <20260407073658.90818-6-a.bied-charreton@proxmox.com> (raw)
In-Reply-To: <20260407073658.90818-1-a.bied-charreton@proxmox.com>

Add checkboxes to the alias edit & remove dialogs which allow opting
into updating/deleting all references that would be left dangling
otherwise.

This adds a remove button with a custom AliasConfirmRemoveDialog built
on top of ConfirmRemoveDialog to allow setting the extra URL parameter
in the DELETE request, which StdRemoveButton does not support out of the
box.

Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
 www/manager6/grid/FirewallAliases.js | 101 +++++++++++++++++++++------
 1 file changed, 79 insertions(+), 22 deletions(-)

diff --git a/www/manager6/grid/FirewallAliases.js b/www/manager6/grid/FirewallAliases.js
index 06801d33..85cfea89 100644
--- a/www/manager6/grid/FirewallAliases.js
+++ b/www/manager6/grid/FirewallAliases.js
@@ -1,3 +1,32 @@
+Ext.define('PVE.window.AliasConfirmRemoveDialog', {
+    extend: 'Proxmox.window.ConfirmRemoveDialog',
+    alias: 'widget.pveAliasConfirmRemoveDialog',
+    width: 350,
+
+    additionalItems: [
+        {
+            xtype: 'proxmoxcheckbox',
+            reference: 'deleteRefsCheckbox',
+            fieldLabel: gettext('Delete referencing rules and IPSets'),
+            labelWidth: 260,
+            autoEl: {
+                tag: 'span',
+                'data-qtip': gettext(
+                    'Delete all rules and IPSets referencing this alias. If left unchecked, some firewall configurations may end up in invalid states.',
+                ),
+            },
+        },
+    ],
+
+    getParams: function () {
+        let me = this;
+        if (me.lookupReference('deleteRefsCheckbox').getValue()) {
+            me.params['delete-references'] = 1;
+        }
+        return me.callParent();
+    },
+});
+
 Ext.define('PVE.FirewallAliasEdit', {
     extend: 'Proxmox.window.Edit',
 
@@ -20,27 +49,44 @@ Ext.define('PVE.FirewallAliasEdit', {
             me.method = 'PUT';
         }
 
+        let items = [
+            {
+                xtype: 'textfield',
+                name: me.isCreate ? 'name' : 'rename',
+                fieldLabel: gettext('Name'),
+                allowBlank: false,
+            },
+            {
+                xtype: 'textfield',
+                name: 'cidr',
+                fieldLabel: gettext('IP/CIDR'),
+                allowBlank: false,
+            },
+            {
+                xtype: 'textfield',
+                name: 'comment',
+                fieldLabel: gettext('Comment'),
+            },
+        ];
+        if (!me.isCreate) {
+            items.push({
+                xtype: 'proxmoxcheckbox',
+                name: 'update-references',
+                fieldLabel: gettext('Update referencing rules and IPSets'),
+                labelWidth: 350,
+                anchor: '100%',
+                autoEl: {
+                    tag: 'span',
+                    'data-qtip': gettext(
+                        'Update all rules and IPSets referencing this alias to use the new identifier. If left unchecked, some firewall configurations may end up in invalid states.',
+                    ),
+                },
+            });
+        }
+
         let ipanel = Ext.create('Proxmox.panel.InputPanel', {
             isCreate: me.isCreate,
-            items: [
-                {
-                    xtype: 'textfield',
-                    name: me.isCreate ? 'name' : 'rename',
-                    fieldLabel: gettext('Name'),
-                    allowBlank: false,
-                },
-                {
-                    xtype: 'textfield',
-                    name: 'cidr',
-                    fieldLabel: gettext('IP/CIDR'),
-                    allowBlank: false,
-                },
-                {
-                    xtype: 'textfield',
-                    name: 'comment',
-                    fieldLabel: gettext('Comment'),
-                },
-            ],
+            items,
         });
 
         Ext.apply(me, {
@@ -158,15 +204,26 @@ Ext.define('PVE.FirewallAliases', {
             },
         });
 
-        me.removeBtn = Ext.create('Proxmox.button.StdRemoveButton', {
+        me.removeBtn = Ext.create('Proxmox.button.Button', {
+            text: gettext('Remove'),
             disabled: true,
+            dangerous: true,
             selModel: sm,
             enableFn: (rec) =>
                 !!caps.vms['VM.Config.Network'] ||
                 !!caps.dc['Sys.Modify'] ||
                 !!caps.nodes['Sys.Modify'],
-            baseurl: me.base_url + '/',
-            callback: reload,
+            handler: function (btn, event, rec) {
+                Ext.create('PVE.window.AliasConfirmRemoveDialog', {
+                    item: { id: rec.data.name },
+                    url: me.base_url + '/' + rec.data.name,
+                    text: Ext.String.format(
+                        gettext("Are you sure you want to remove Alias '{0}'?"),
+                        rec.data.name,
+                    ),
+                    apiCallDone: reload,
+                }).show();
+            },
         });
 
         Ext.apply(me, {
-- 
2.47.3




      parent reply	other threads:[~2026-04-07  7:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07  7:36 [PATCH firewall/manager 0/5] Allow updating references to firewall objects when editing them Arthur Bied-Charreton
2026-04-07  7:36 ` [PATCH pve-firewall 1/5] Add helpers for updating alias and ipset references Arthur Bied-Charreton
2026-04-07  7:36 ` [PATCH pve-firewall 2/5] ipset: Add option to update references on rename/delete Arthur Bied-Charreton
2026-04-07  7:36 ` [PATCH pve-firewall 3/5] aliases: " Arthur Bied-Charreton
2026-04-07  7:36 ` [PATCH pve-manager 4/5] ipset: " Arthur Bied-Charreton
2026-04-07  7:36 ` Arthur Bied-Charreton [this message]

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=20260407073658.90818-6-a.bied-charreton@proxmox.com \
    --to=a.bied-charreton@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