From: Christoph Heiss <[email protected]> This allows selectively enabling IPv4/6 in the child components, without having to re-define the respective fields in every child component. A later commit will introduce the Wireguard fabric, which will have neither a IPv4 nor IPv6 prefix for now, so the option to exclude those fields will be used there as well.
Co-authored-by: Stefan Hanreich <[email protected]> Signed-off-by: Christoph Heiss <[email protected]> --- www/manager6/sdn/fabrics/FabricEdit.js | 68 +++++++++++++++---- .../sdn/fabrics/openfabric/FabricEdit.js | 32 --------- www/manager6/sdn/fabrics/ospf/FabricEdit.js | 2 + 3 files changed, 58 insertions(+), 44 deletions(-) diff --git a/www/manager6/sdn/fabrics/FabricEdit.js b/www/manager6/sdn/fabrics/FabricEdit.js index 07d169287..6111bbb51 100644 --- a/www/manager6/sdn/fabrics/FabricEdit.js +++ b/www/manager6/sdn/fabrics/FabricEdit.js @@ -5,8 +5,18 @@ Ext.define('PVE.sdn.Fabric.Fabric.Edit', { width: 400, fabricId: undefined, + + hasIpv4Support: true, + hasIpv6Support: true, + baseUrl: '/cluster/sdn/fabrics/fabric', + viewModel: { + data: { + showIpv6ForwardingHint: false, + }, + }, + items: [ { xtype: 'textfield', @@ -24,18 +34,6 @@ Ext.define('PVE.sdn.Fabric.Fabric.Edit', { disabled: '{!isCreate}', }, }, - { - xtype: 'proxmoxtextfield', - fieldLabel: gettext('IPv4 Prefix'), - labelWidth: 120, - name: 'ip_prefix', - allowBlank: true, - skipEmptyText: true, - cbind: { - disabled: '{!isCreate}', - deleteEmpty: '{!isCreate}', - }, - }, ], additionalItems: [], @@ -53,6 +51,52 @@ Ext.define('PVE.sdn.Fabric.Fabric.Edit', { me.url = me.baseUrl; } + if (me.hasIpv4Support) { + me.items.push({ + xtype: 'proxmoxtextfield', + fieldLabel: gettext('IPv4 Prefix'), + labelWidth: 120, + name: 'ip_prefix', + allowBlank: true, + skipEmptyText: true, + cbind: { + disabled: '{!isCreate}', + deleteEmpty: '{!isCreate}', + }, + }); + } + + if (me.hasIpv6Support) { + me.items.push( + { + xtype: 'displayfield', + value: 'To make IPv6 fabrics work, enable global IPv6 forwarding on all nodes. Click on the Help button for more details.', + bind: { + hidden: '{!showIpv6ForwardingHint}', + }, + userCls: 'pmx-hint', + }, + { + xtype: 'proxmoxtextfield', + fieldLabel: gettext('IPv6 Prefix'), + labelWidth: 120, + name: 'ip6_prefix', + allowBlank: true, + skipEmptyText: true, + cbind: { + disabled: '{!isCreate}', + deleteEmpty: '{!isCreate}', + }, + listeners: { + change: function (textbox, value) { + let vm = textbox.up('window').getViewModel(); + vm.set('showIpv6ForwardingHint', !!value); + }, + }, + }, + ); + } + me.items.push(...me.additionalItems); me.callParent(); diff --git a/www/manager6/sdn/fabrics/openfabric/FabricEdit.js b/www/manager6/sdn/fabrics/openfabric/FabricEdit.js index 14b71fae2..b89764293 100644 --- a/www/manager6/sdn/fabrics/openfabric/FabricEdit.js +++ b/www/manager6/sdn/fabrics/openfabric/FabricEdit.js @@ -4,43 +4,11 @@ Ext.define('PVE.sdn.Fabric.OpenFabric.Fabric.Edit', { subject: 'OpenFabric', onlineHelp: 'pvesdn_openfabric_fabric', - viewModel: { - data: { - showIpv6ForwardingHint: false, - }, - }, - extraRequestParams: { protocol: 'openfabric', }, additionalItems: [ - { - xtype: 'displayfield', - value: 'To make IPv6 fabrics work, enable global IPv6 forwarding on all nodes. Click on the Help button for more details.', - bind: { - hidden: '{!showIpv6ForwardingHint}', - }, - userCls: 'pmx-hint', - }, - { - xtype: 'proxmoxtextfield', - fieldLabel: gettext('IPv6 Prefix'), - labelWidth: 120, - name: 'ip6_prefix', - allowBlank: true, - skipEmptyText: true, - cbind: { - disabled: '{!isCreate}', - deleteEmpty: '{!isCreate}', - }, - listeners: { - change: function (textbox, value) { - let vm = textbox.up('window').getViewModel(); - vm.set('showIpv6ForwardingHint', !!value); - }, - }, - }, { xtype: 'proxmoxintegerfield', // TRANSLATORS: See https://en.wikipedia.org/wiki/IS-IS#Packet_types diff --git a/www/manager6/sdn/fabrics/ospf/FabricEdit.js b/www/manager6/sdn/fabrics/ospf/FabricEdit.js index 4c4e17c99..cbbe8c9c8 100644 --- a/www/manager6/sdn/fabrics/ospf/FabricEdit.js +++ b/www/manager6/sdn/fabrics/ospf/FabricEdit.js @@ -4,6 +4,8 @@ Ext.define('PVE.sdn.Fabric.Ospf.Fabric.Edit', { subject: 'OSPF', onlineHelp: 'pvesdn_ospf_fabric', + hasIpv6Support: false, + extraRequestParams: { protocol: 'ospf', }, -- 2.47.3
