[pve-devel] [PATCH v2 manager] firewall: add scope field to IPRefSelector

Leo Nunner l.nunner at proxmox.com
Tue Jun 13 14:06:34 CEST 2023


and send the scoped value to the firewall when choosing new values.
This happens for both IPSets and aliases.

Signed-off-by: Leo Nunner <l.nunner at proxmox.com>
---
 www/manager6/form/IPRefSelector.js | 35 +++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/www/manager6/form/IPRefSelector.js b/www/manager6/form/IPRefSelector.js
index 9ccc2fe10..b50ac1e10 100644
--- a/www/manager6/form/IPRefSelector.js
+++ b/www/manager6/form/IPRefSelector.js
@@ -8,7 +8,7 @@ Ext.define('PVE.form.IPRefSelector', {
 
     ref_type: undefined, // undefined = any [undefined, 'ipset' or 'alias']
 
-    valueField: 'ref',
+    valueField: 'scopedref',
     displayField: 'ref',
     notFoundIsValid: true,
 
@@ -26,7 +26,23 @@ Ext.define('PVE.form.IPRefSelector', {
 
 	var store = Ext.create('Ext.data.Store', {
 	    autoLoad: true,
-	    fields: ['type', 'name', 'ref', 'comment'],
+	    fields: [
+		'type',
+		'name',
+		'ref',
+		'comment',
+		'scope',
+		{
+		    name: 'scopedref',
+		    calculate: function(v) {
+			if (v.type === 'alias') {
+			    return `${v.scope}/${v.name}`;
+			} else {
+			    return `+${v.scope}/${v.name}`;
+			}
+		    },
+		},
+	    ],
 	    idProperty: 'ref',
 	    proxy: {
 		type: 'proxmox',
@@ -65,17 +81,30 @@ Ext.define('PVE.form.IPRefSelector', {
 		hideable: false,
 		width: 140,
 	    },
+	    {
+		header: gettext('Scope'),
+		dataIndex: 'scope',
+		hideable: false,
+		width: 140,
+		renderer: function(value) {
+		    return value === 'dc' ? gettext("Datacenter") : gettext("Guest");
+		},
+	    },
 	    {
 		header: gettext('Comment'),
 		dataIndex: 'comment',
 		renderer: Ext.String.htmlEncode,
+		minWidth: 60,
 		flex: 1,
 	    },
 	);
 
 	Ext.apply(me, {
 	    store: store,
-            listConfig: { columns: columns },
+            listConfig: {
+		columns: columns,
+		width: 500,
+	    },
 	});
 
 	me.on('change', disable_query_for_ips);
-- 
2.30.2






More information about the pve-devel mailing list