From: "Christoph Heiss" <c.heiss@proxmox.com>
To: "Gabriel Goller" <g.goller@proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-manager 6/7] fabrics: Add main FabricView
Date: Wed, 02 Apr 2025 11:50:57 +0200 [thread overview]
Message-ID: <D8W26409CVS4.14VE1ODAGF54M@proxmox.com> (raw)
In-Reply-To: <20250328171340.885413-51-g.goller@proxmox.com>
Some comments inline - did the review mostly in tandem with testing the
UI, to get a better context.
On Fri Mar 28, 2025 at 6:13 PM CET, Gabriel Goller wrote:
[..]
> diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
> index 74728c8320e9..68f7be8d6042 100644
> --- a/www/manager6/dc/Config.js
> +++ b/www/manager6/dc/Config.js
> @@ -229,6 +229,14 @@ Ext.define('PVE.dc.Config', {
> hidden: true,
> iconCls: 'fa fa-shield',
> itemId: 'sdnfirewall',
> + },
> + {
> + xtype: 'pveSDNFabricView',
> + groups: ['sdn'],
> + title: gettext('Fabrics'),
Do we really want to translate 'Fabrics'? Or rather just keep the name
always at 'Fabrics' as the name of the concept/feature itself? Since it
is a established term, after all. I'd keep it, IMHO.
(But we seem to translate everything else here in the file, so really
not sure.)
> + hidden: true,
> + iconCls: 'fa fa-road',
> + itemId: 'sdnfabrics',
> });
> }
>
> diff --git a/www/manager6/sdn/FabricsView.js b/www/manager6/sdn/FabricsView.js
> new file mode 100644
> index 000000000000..0ef12defb1a8
> --- /dev/null
> +++ b/www/manager6/sdn/FabricsView.js
[..]
> +Ext.define('PVE.sdn.Fabric.View', {
[..]
> + {
> + text: gettext('Protocol'),
> + dataIndex: 'protocol',
> + width: 100,
> + renderer: function(value, metaData, rec) {
> + if (rec.data.type !== 'fabric') {
> + return "";
> + }
> +
> + return PVE.Utils.render_sdn_pending(rec, value, 'protocol');
> + },
A mapping for the internal protocol name to a user-visible would be nice
here, i.e. 'ospf' -> 'OSPF' and 'openfabric' -> 'OpenFabric'. Not much
difference currently, but would look a bit better in the UI :)
> + },
> + {
> + text: gettext('Loopback IP'),
> + dataIndex: 'router_id',
> + width: 150,
> + renderer: function(value, metaData, rec) {
> + if (rec.data.type === 'fabric') {
> + return PVE.Utils.render_sdn_pending(rec, rec.data.loopback_prefix, 'loopback_prefix');
> + }
> +
> + return PVE.Utils.render_sdn_pending(rec, value, 'router_id');
> + },
> + },
> + {
> + text: gettext('Action'),
> + xtype: 'actioncolumn',
> + dataIndex: 'text',
> + width: 100,
> + items: [
> + {
> + handler: 'addActionTreeColumn',
> + getTip: (_v, _m, _rec) => gettext('Add'),
nit: "Add Node" would be better here for node rows, if that's possible.
> + getClass: (_v, _m, { data }) => {
> + if (data.type === 'fabric') {
> + return 'fa fa-plus-circle';
> + }
> +
> + return 'pmx-hidden';
> + },
> + isActionDisabled: (_v, _r, _c, _i, { data }) => data.type !== 'fabric',
> + },
> + {
> + tooltip: gettext('Edit'),
^ same as above
> + handler: 'editAction',
> + getClass: (_v, _m, { data }) => {
> + // the fabric type (openfabric, ospf, etc.) cannot be edited
> + if (data.type) {
> + return 'fa fa-pencil fa-fw';
> + }
> +
> + return 'pmx-hidden';
> + },
> + isActionDisabled: (_v, _r, _c, _i, { data }) => !data.type,
> + },
> + {
> + tooltip: gettext('Delete'),
^ and same here as well
> + handler: 'deleteAction',
> + getClass: (_v, _m, { data }) => {
> + // the fabric type (openfabric, ospf, etc.) cannot be deleted
> + if (data.type) {
> + return 'fa critical fa-trash-o';
> + }
> +
> + return 'pmx-hidden';
> + },
> + isActionDisabled: (_v, _r, _c, _i, { data }) => !data.type,
> + },
> + ],
> + },
> + {
> + header: gettext('Interfaces'),
> + width: 100,
> + dataIndex: 'interface',
> + renderer: function(value, metaData, rec) {
> + let interfaces = rec.data.pending?.interface || rec.data.interface || [];
nit: could be const (see [0] tho regarding rules for const/let)
[0] https://pve.proxmox.com/wiki/Javascript_Style_Guide#Variables
> +
> + let names = interfaces.map((iface) => {
> + let properties = Proxmox.Utils.parsePropertyString(iface);
nit: same here, as well for some other things in this file
> + return properties.name;
> + });
> +
> + names.sort();
> + return names.join(", ");
> + },
> + },
[..]
> +
> + initComponent: function() {
> + let me = this;
> +
> +
> + let add_button = new Proxmox.button.Button({
New variables should generally be camelCase [0].
[1] https://pve.proxmox.com/wiki/Javascript_Style_Guide#Casing
> + text: gettext('Add Node'),
> + handler: 'addActionTbar',
> + disabled: true,
> + });
Since there is also an "add node" button in the "Action" column for each
fabric, do we need a separate one in the top-bar as well?
> +
> + let set_add_button_status = function() {
> + let selection = me.view.getSelection();
> +
> + if (selection.length === 0) {
> + return;
> + }
> +
> + add_button.setDisabled(selection[0].data.type !== 'fabric');
> + };
> +
> + Ext.apply(me, {
> + tbar: [
> + {
> + text: gettext('Add Fabric'),
> + menu: [
> + {
> + text: gettext('OpenFabric'),
'OpenFabric' also should not be translated, right? As its the name of
the implementation/protocol.
> + handler: 'openAddOpenFabricWindow',
> + },
> + {
> + text: gettext('OSPF'),
^ same here
> + handler: 'openAddOspfWindow',
> + },
> + ],
> + },
[..]
> + controller: {
> + xclass: 'Ext.app.ViewController',
> +
> + reload: function() {
> + let me = this;
> +
> + Proxmox.Utils.API2Request({
> + url: `/cluster/sdn/fabrics/?pending=1`,
> + method: 'GET',
> + success: function(response, opts) {
> + let ospf = response.result.data.ospf;
> + let openfabric = response.result.data.openfabric;
> +
> + // add some metadata so we can merge the objects later and still know the protocol/type
> + ospf = ospf.map(x => {
> + if (x.state && x.state === 'new') {
> + Object.assign(x, x.pending);
> + }
> +
> + if (x.ty === 'fabric') {
> + return Object.assign(x, { protocol: "ospf", name: x.area });
> + } else if (x.ty === 'node') {
> + let id = x.node_id.split("_");
> + return Object.assign(x,
> + {
> + protocol: "ospf",
> + node: id[1],
> + fabric: id[0],
> + },
> + );
> + } else {
> + return x;
> + }
> + });
Perhaps factor this out a bit into a separate function, making the
success() definition here a bit more succinct?
> + openfabric = openfabric.map(x => {
> + if (x.state && x.state === 'new') {
> + Object.assign(x, x.pending);
> + }
> +
> + if (x.ty === 'fabric') {
> + return Object.assign(x, { protocol: "openfabric", name: x.fabric_id });
> + } else if (x.ty === 'node') {
> + let id = x.node_id.split("_");
> + return Object.assign(x,
> + {
> + protocol: "openfabric",
> + node: id[1],
> + fabric: id[0],
> + },
> + );
> + } else {
> + return x;
> + }
> + });
^ same for the openfabric mapping
> +
> + let allFabrics = openfabric.concat(ospf);
> + let fabrics = allFabrics.filter(e => e.ty === "fabric").map((fabric) => {
> + if (!fabric.state || fabric.state !== 'deleted') {
> + fabric.children = allFabrics.filter(e => e.ty === "node")
> + .filter((node) =>
> + node.fabric === fabric.name && node.protocol === fabric.protocol)
> + .map((node) => {
> + Object.assign(node, {
> + leaf: true,
> + type: 'node',
> + iconCls: 'fa fa-desktop x-fa-treepanel',
> + name: node.node,
> + _fabric: fabric.name,
> + });
> +
> + return node;
> + });
^ and same here, moving it into a separate function instead of
open-coding it here. Would make the whole bit here more readable/easier
to understand.
> + }
> +
> + Object.assign(fabric, {
> + type: 'fabric',
> + protocol: fabric.protocol,
> + expanded: true,
> + name: fabric.fabric_id || fabric.area,
> + iconCls: 'fa fa-road x-fa-treepanel',
> + });
> +
> + return fabric;
> + });
> +
[..]
> +
> + addActionTreeColumn: function(_grid, _rI, _cI, _item, _e, rec) {
> + let me = this;
nit: never used, just drop it
> + this.addAction(rec);
> + },
> +
[..]
> +
> + deleteAction: function(table, rI, cI, item, e, { data }) {
> + let me = this;
> + let view = me.getView();
> +
> + Ext.Msg.show({
> + title: gettext('Confirm'),
> + icon: Ext.Msg.WARNING,
> + message: Ext.String.format(gettext('Are you sure you want to remove the fabric {0}?'), `${data.name}`),
nit: unnecessary string interpolation
> + buttons: Ext.Msg.YESNO,
> + defaultFocus: 'no',
> + callback: function(btn) {
> + if (btn !== 'yes') {
> + return;
> + }
> +
> + let url;
> + if (data.type === "node") {
> + url = `/cluster/sdn/fabrics/${data.protocol}/${data._fabric}/node/${data.name}`;
> + } else if (data.type === "fabric") {
> + url = `/cluster/sdn/fabrics/${data.protocol}/${data.name}`;
> + } else {
> + console.warn("deleteAction: missing type");
> + }
> +
> + Proxmox.Utils.API2Request({
> + url,
> + method: 'DELETE',
> + waitMsgTarget: view,
> + failure: function(response, opts) {
> + Ext.Msg.alert(gettext('Error'), response.htmlStatus);
Could use `Proxmox.Utils.errorText` here instead of `gettext('Error')`.
> + },
> + callback: me.reload.bind(me),
nit: `() => me.reload()` is already used multiple times in this file, so
use that here too for consistency? Think it's the preferred style
anyway.
> + });
> + },
> + });
> + },
> +
> + openAddOpenFabricWindow: function() {
> + let me = this;
> +
> + let window = Ext.create('PVE.sdn.Fabric.OpenFabric.Fabric.Edit', {
> + autoShow: true,
> + autoLoad: false,
> + isCreate: true,
> + });
> +
> + window.on('destroy', () => me.reload());
> + },
> +
> + openAddOspfWindow: function() {
> + let me = this;
> +
> + let window = Ext.create('PVE.sdn.Fabric.Ospf.Fabric.Edit', {
> + autoShow: true,
> + autoLoad: false,
> + isCreate: true,
> + });
> +
> + window.on('destroy', () => me.reload());
> + },
> +
> + init: function(view) {
> + let me = this;
> + me.reload();
> + },
> + },
> +});
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-04-02 9:51 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 17:12 [pve-devel] [PATCH cluster/docs/manager/network/proxmox{, -ve-rs, -firewall, -perl-rs} 00/52] Add SDN Fabrics Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox 1/1] serde: add string_as_bool module for boolean string parsing Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 01/17] add proxmox-network-types crate Gabriel Goller
2025-03-31 14:09 ` Thomas Lamprecht
2025-03-31 14:38 ` Stefan Hanreich
2025-03-31 16:20 ` Thomas Lamprecht
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 02/17] network-types: add common hostname and openfabric types Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 03/17] network-types: add openfabric NET type Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 04/17] network-types: move Ipv4Cidr and Ipv6Cidr types Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 05/17] frr: create proxmox-frr crate Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 06/17] frr: add common frr types Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 07/17] frr: add openfabric types Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 08/17] frr: add ospf types Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 09/17] frr: add route-map types Gabriel Goller
2025-03-28 17:12 ` [pve-devel] [PATCH proxmox-ve-rs 10/17] frr: add generic types over openfabric and ospf Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-ve-rs 11/17] frr: add serializer for all FRR types Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-ve-rs 12/17] ve-config: add openfabric section-config Gabriel Goller
2025-03-31 13:48 ` Christoph Heiss
2025-03-31 15:04 ` Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-ve-rs 13/17] ve-config: add ospf section-config Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-ve-rs 14/17] ve-config: add FRR conversion helpers for openfabric and ospf Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-ve-rs 15/17] ve-config: add validation for section-config Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-ve-rs 16/17] ve-config: add section-config to frr types conversion Gabriel Goller
2025-03-31 13:51 ` Christoph Heiss
2025-03-31 14:31 ` Stefan Hanreich
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-ve-rs 17/17] ve-config: add integrations tests Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-firewall 1/1] firewall: nftables: migrate to proxmox-network-types Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-perl-rs 1/7] perl-rs: sdn: initial fabric infrastructure Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-perl-rs 2/7] perl-rs: sdn: add CRUD helpers for OpenFabric fabric management Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-perl-rs 3/7] perl-rs: sdn: OpenFabric perlmod methods Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-perl-rs 4/7] perl-rs: sdn: implement OSPF interface file configuration generation Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-perl-rs 5/7] perl-rs: sdn: add CRUD helpers for OSPF fabric management Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-perl-rs 6/7] perl-rs: sdn: OSPF perlmod methods Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH proxmox-perl-rs 7/7] perl-rs: sdn: implement OSPF interface file configuration generation Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-cluster 1/1] cluster: add sdn fabrics config files Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 01/17] sdn: fix value returned by pending_config Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 02/17] debian: add dependency to proxmox-perl-rs Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 03/17] fabrics: add fabrics module Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 04/17] refactor: controller: move frr methods into helper Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 05/17] controllers: implement new api for frr config generation Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 06/17] sdn: add frr config generation helper Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 07/17] test: isis: add test for standalone configuration Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 08/17] sdn: frr: add daemon status to frr helper Gabriel Goller
2025-04-02 10:41 ` Fabian Grünbichler
2025-04-02 10:50 ` Stefan Hanreich
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 09/17] sdn: running: apply fabrics config Gabriel Goller
2025-04-02 10:41 ` Fabian Grünbichler
2025-04-02 12:26 ` Stefan Hanreich
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 10/17] fabrics: generate ifupdown configuration Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 11/17] api: add fabrics subfolder Gabriel Goller
2025-04-02 10:41 ` Fabian Grünbichler
2025-04-02 12:20 ` Stefan Hanreich
2025-04-02 12:29 ` Fabian Grünbichler
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 12/17] api: fabrics: add common helpers Gabriel Goller
2025-04-02 10:41 ` Fabian Grünbichler
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 13/17] fabric: openfabric: add api endpoints Gabriel Goller
2025-04-02 10:37 ` Fabian Grünbichler
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 14/17] fabric: ospf: " Gabriel Goller
2025-04-02 10:37 ` Fabian Grünbichler
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 15/17] test: fabrics: add test cases for ospf and openfabric + evpn Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 16/17] frr: bump frr config version to 10.2.1 Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-network 17/17] frr: fix reloading frr configuration Gabriel Goller
2025-04-02 10:37 ` Fabian Grünbichler
2025-04-02 10:42 ` Stefan Hanreich
2025-03-28 17:13 ` [pve-devel] [PATCH pve-manager 1/7] api: use new generalized frr and etc network config helper functions Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-manager 2/7] fabrics: add common interface panel Gabriel Goller
2025-04-02 9:26 ` Friedrich Weber
2025-04-02 10:04 ` Gabriel Goller
2025-04-02 10:10 ` Friedrich Weber
2025-03-28 17:13 ` [pve-devel] [PATCH pve-manager 3/7] fabrics: add additional interface fields for openfabric and ospf Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-manager 4/7] fabrics: add FabricEdit components Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-manager 5/7] fabrics: add NodeEdit components Gabriel Goller
2025-04-03 9:16 ` Christoph Heiss
2025-04-04 15:45 ` Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-manager 6/7] fabrics: Add main FabricView Gabriel Goller
2025-04-02 9:26 ` Friedrich Weber
2025-04-02 9:50 ` Christoph Heiss [this message]
2025-04-02 10:40 ` Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-manager 7/7] utils: avoid line-break in pending changes message Gabriel Goller
2025-03-28 17:13 ` [pve-devel] [PATCH pve-docs 1/1] fabrics: add initial documentation for sdn fabrics Gabriel Goller
2025-03-31 8:44 ` Shannon Sterz
2025-03-31 12:24 ` Gabriel Goller
2025-04-02 8:43 ` Gabriel Goller
2025-04-02 8:49 ` Christoph Heiss
2025-04-02 9:09 ` Gabriel Goller
2025-04-02 9:16 ` Christoph Heiss
2025-04-03 8:30 ` [pve-devel] [PATCH cluster/docs/manager/network/proxmox{, -ve-rs, -firewall, -perl-rs} 00/52] Add SDN Fabrics Friedrich Weber
2025-04-03 10:21 ` Gabriel Goller
2025-04-03 13:44 ` Friedrich Weber
2025-04-03 14:03 ` Stefan Hanreich
2025-04-03 14:20 ` Friedrich Weber
2025-04-04 7:53 ` Stefan Hanreich
2025-04-04 10:55 ` Hannes Duerr
2025-04-04 12:48 ` Gabriel Goller
2025-04-04 12:53 ` Hannes Duerr
2025-04-04 14:26 ` Gabriel Goller
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=D8W26409CVS4.14VE1ODAGF54M@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=g.goller@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