From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 83E7D1FF142 for ; Tue, 07 Apr 2026 09:36:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0B2DAEA70; Tue, 7 Apr 2026 09:37:06 +0200 (CEST) From: Arthur Bied-Charreton 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 Message-ID: <20260407073658.90818-6-a.bied-charreton@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260407073658.90818-1-a.bied-charreton@proxmox.com> References: <20260407073658.90818-1-a.bied-charreton@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.091 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: T7WEU4YZMFAT6D72HNKXTC7WFP7LLR2Y X-Message-ID-Hash: T7WEU4YZMFAT6D72HNKXTC7WFP7LLR2Y X-MailFrom: abied-charreton@jett.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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