all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager 09/10] ui: sdn: fabrics: wireguard: support resetting the interfaces
Date: Fri, 20 Nov 2026 17:00:24 +0100	[thread overview]
Message-ID: <20261120160026.512565-10-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20261120160026.512565-1-s.hanreich@proxmox.com>

Resetting the form data of the node edit window had no effect on the
interfaces of a WireGuard node, since the interface panel only used
the default reset of the field mixin, which does not touch the
interface store.

Reload the interfaces of the node, or remove all interfaces when
creating a node, and update the dirty and validity state afterwards,
so that the window updates its buttons. Peers that reference missing
interfaces are only reported when loading the node, not again on
every reset.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 .../sdn/fabrics/wireguard/InterfacePanel.js   | 89 ++++++++++++-------
 1 file changed, 59 insertions(+), 30 deletions(-)

diff --git a/www/manager6/sdn/fabrics/wireguard/InterfacePanel.js b/www/manager6/sdn/fabrics/wireguard/InterfacePanel.js
index 8c5def67..7ba53efd 100644
--- a/www/manager6/sdn/fabrics/wireguard/InterfacePanel.js
+++ b/www/manager6/sdn/fabrics/wireguard/InterfacePanel.js
@@ -458,7 +458,8 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', {
         me.getViewModel().set('availablePeers', availablePeers);
     },
 
-    setNode: async function (node) {
+    // returns the peers that were dropped, since their interface does not exist on the node
+    loadInterfaces: function (node) {
         let me = this;
 
         let ifaces = {};
@@ -485,6 +486,27 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', {
                 Ext.create('Pve.sdn.Fabric.WireGuard.InterfacePeer', peer),
             );
         }
+
+        me.getViewModel().set('currentNode', node);
+
+        me.isLoading = true;
+        try {
+            me.getViewModel().getStore('interfaces').setData(Object.values(ifaces));
+        } finally {
+            me.isLoading = false;
+        }
+
+        me.selectFirstInterface();
+
+        return droppedPeers;
+    },
+
+    setNode: async function (node) {
+        let me = this;
+
+        me.loadedNode = node;
+
+        let droppedPeers = me.loadInterfaces(node);
         if (droppedPeers.length > 0) {
             console.warn(
                 `WireGuard: dropping ${droppedPeers.length} peer(s) referencing missing interfaces:`,
@@ -501,17 +523,20 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', {
             );
         }
 
-        me.getViewModel().set('currentNode', node);
+        me.previousDirty = false;
+    },
 
-        me.isLoading = true;
-        try {
-            me.getViewModel().getStore('interfaces').setData(Object.values(ifaces));
-        } finally {
-            me.isLoading = false;
+    reset: function () {
+        let me = this;
+
+        if (me.loadedNode) {
+            // the dropped peers were already reported when loading the node
+            me.loadInterfaces(me.loadedNode);
+        } else {
+            me.getViewModel().getStore('interfaces').removeAll();
         }
-        me.previousDirty = false;
 
-        me.selectFirstInterface();
+        me.refreshState();
     },
 
     isDirty: function () {
@@ -562,6 +587,25 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', {
             .items.every((iface) => me.isInterfaceValid(iface));
     },
 
+    refreshState: function () {
+        let me = this;
+
+        if (me.isLoading) {
+            return;
+        }
+        let dirtyStatus = me.isDirty();
+        if (dirtyStatus !== me.previousDirty) {
+            me.previousDirty = dirtyStatus;
+            me.fireEvent('dirtychange');
+        }
+
+        let validStatus = me.isValid();
+        if (validStatus !== me.previousValid) {
+            me.previousValid = validStatus;
+            me.fireEvent('validitychange', me, validStatus);
+        }
+    },
+
     initComponent: function () {
         let me = this;
 
@@ -569,31 +613,16 @@ Ext.define('PVE.sdn.Fabric.WireGuard.InterfacePanel', {
 
         let store = me.getViewModel().getStore('interfaces');
 
-        let refreshDirty = () => {
-            if (me.isLoading) {
-                return;
-            }
-            let dirtyStatus = me.isDirty();
-            if (dirtyStatus !== me.previousDirty) {
-                me.previousDirty = dirtyStatus;
-                me.fireEvent('dirtychange');
-            }
-
-            let validStatus = me.isValid();
-            if (validStatus !== me.previousValid) {
-                me.previousValid = validStatus;
-                me.fireEvent('validitychange', me, validStatus);
-            }
-        };
+        let refreshState = () => me.refreshState();
 
         me.lookupReference('peerSelector').on({
-            datachanged: refreshDirty,
-            update: refreshDirty,
+            datachanged: refreshState,
+            update: refreshState,
         });
         store.on({
-            add: refreshDirty,
-            remove: refreshDirty,
-            update: refreshDirty,
+            add: refreshState,
+            remove: refreshState,
+            update: refreshState,
         });
     },
 
-- 
2.47.3





  parent reply	other threads:[~2026-11-20 16:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 16:00 [PATCH docs/manager/network/proxmox-perl-rs 00/10] WireGuard fabric follow-ups Stefan Hanreich
2026-11-20 16:00 ` [PATCH proxmox-perl-rs 01/10] pve-rs: sdn: fabrics: wireguard: return empty status for non-member nodes Stefan Hanreich
2026-11-20 16:00 ` [PATCH proxmox-perl-rs 02/10] pve-rs: sdn: status: wireguard: only report type of WireGuard interfaces Stefan Hanreich
2026-11-20 16:00 ` [PATCH proxmox-perl-rs 03/10] pve-rs: sdn: status: wireguard: only report running interface keys and ports Stefan Hanreich
2026-11-20 16:00 ` [PATCH pve-network 04/10] api: fabric status: document omitted WireGuard interface values Stefan Hanreich
2026-11-20 16:00 ` [PATCH pve-manager 05/10] ui: sdn: fabrics: wireguard: block saving invalid " Stefan Hanreich
2026-11-20 16:00 ` [PATCH pve-manager 06/10] ui: sdn: fabrics: wireguard: show persistent keepalive of neighbors Stefan Hanreich
2026-11-20 16:00 ` [PATCH pve-manager 07/10] ui: sdn: fabrics: wireguard: show '-' for unknown status values Stefan Hanreich
2026-11-20 16:00 ` [PATCH pve-manager 08/10] ui: sdn: fabrics: wireguard: add reload button to status grids Stefan Hanreich
2026-11-20 16:00 ` Stefan Hanreich [this message]
2026-11-20 16:00 ` [PATCH pve-docs 10/10] sdn: fabrics: wireguard: document status values and keepalive column Stefan Hanreich

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=20261120160026.512565-10-s.hanreich@proxmox.com \
    --to=s.hanreich@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal