fix #7108: ui: ipset: do not offer aliases that are already added

When adding an entry to an IPSet, the alias selector lists all aliases,
including those that are already part of the IPSet. Selecting one of
them only results in an "already exists" error from the API.

Pass the current entries of the IPSet to the add window and filter the
matching aliases out of the selector. Aliases are stored in the IPSet
with the same scoped reference the selector uses as value, so an exact
comparison is sufficient.

Signed-off-by: Michal Fox <me@dualfroz.com>
Reviewed-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
Tested-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
Link: https://lore.proxmox.com/20260929142331.2990690-1-me@dualfroz.com
This commit is contained in:
dualfroz committed 2026-09-30 12:19:59 +02:00
1 parent 25c14ebf7d
commit baf8bb7941
2 files changed
+9

No files matched your search

+4
View File
@@ -8,6 +8,9 @@ Ext.define('PVE.form.IPRefSelector', {
ref_type: undefined, // undefined = any [undefined, 'ipset' or 'alias'] ref_type: undefined, // undefined = any [undefined, 'ipset' or 'alias']
// list of references that should not be offered, e.g. because they are already in use
excludeRefs: [],
valueField: 'scopedref', valueField: 'scopedref',
displayField: 'ref', displayField: 'ref',
notFoundIsValid: true, notFoundIsValid: true,
@@ -54,6 +57,7 @@ Ext.define('PVE.form.IPRefSelector', {
property: 'ref', property: 'ref',
direction: 'ASC', direction: 'ASC',
}, },
filters: [(rec) => !me.excludeRefs.includes(rec.data.scopedref)],
}); });
var columns = []; var columns = [];
+5
View File
@@ -187,6 +187,9 @@ Ext.define('PVE.IPSetCidrEdit', {
cidr: undefined, cidr: undefined,
// entries already in the IPSet, not offered again when adding a new one
existingCidrs: [],
initComponent: function () { initComponent: function () {
var me = this; var me = this;
@@ -211,6 +214,7 @@ Ext.define('PVE.IPSetCidrEdit', {
xtype: 'pveIPRefSelector', xtype: 'pveIPRefSelector',
name: 'cidr', name: 'cidr',
ref_type: 'alias', ref_type: 'alias',
excludeRefs: me.existingCidrs,
autoSelect: false, autoSelect: false,
editable: true, editable: true,
base_url: me.list_refs_url, base_url: me.list_refs_url,
@@ -359,6 +363,7 @@ Ext.define(
var win = Ext.create('PVE.IPSetCidrEdit', { var win = Ext.create('PVE.IPSetCidrEdit', {
base_url: me.base_url, base_url: me.base_url,
list_refs_url: me.list_refs_url, list_refs_url: me.list_refs_url,
existingCidrs: store.collect('cidr'),
}); });
win.show(); win.show();
win.on('destroy', reload); win.on('destroy', reload);