public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager v3 6/8] ui: views: use the view name as key of the component
Date: Mon, 30 Nov 2026 13:52:40 +0100	[thread overview]
Message-ID: <20261130125325.2392967-7-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261130125325.2392967-1-d.csapak@proxmox.com>

so that showing another view in the same place creates a new component
instead of updating the existing one.

Most of the state of the component belongs to the view. When the view
changed, that state was reset by hand, which is easy to miss for new
state: the refresh settings stayed those of the old view, and the
remote list was only watched if the component was created for the
default dashboard.

This did not matter so far, since each view has its own page in the
main menu, so the view of a component never changes. It will when users
can select a view as dashboard, since the dashboard page then changes
its view in place.

Since another view now always gets a new component, drop the resetting
of the state.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/dashboard/view.rs | 35 ++++-------------------------------
 1 file changed, 4 insertions(+), 31 deletions(-)

diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs
index f7045aa8..63c35a83 100644
--- a/ui/src/dashboard/view.rs
+++ b/ui/src/dashboard/view.rs
@@ -7,7 +7,7 @@ use gloo_timers::callback::Interval;
 use http::StatusCode;
 use js_sys::Date;
 use serde_json::{Value, json};
-use yew::virtual_dom::{VComp, VNode};
+use yew::virtual_dom::{Key, VComp, VNode};
 
 use proxmox_client::ApiResponseData;
 use proxmox_yew_comp::percent_encoding::percent_encode_component;
@@ -106,7 +106,9 @@ pub struct View {
 
 impl From<View> for VNode {
     fn from(val: View) -> Self {
-        let comp = VComp::new::<ViewComp>(Rc::new(val), None);
+        // most of the state belongs to the view, so another view gets a new component
+        let key = val.view.as_ref().map(|view| Key::from(view.as_str()));
+        let comp = VComp::new::<ViewComp>(Rc::new(val), key);
         VNode::from(comp)
     }
 }
@@ -1073,35 +1075,6 @@ impl Component for ViewComp {
         true
     }
 
-    fn changed(&mut self, ctx: &Context<Self>, old_props: &Self::Properties) -> bool {
-        // the list of views only changes the empty state
-        if ctx.props().view == old_props.view {
-            return true;
-        }
-        // this aborts a running save or load of the layout editor too
-        self.async_pool = AsyncPool::new();
-        if self.layout_edit == LayoutEditState::Editing {
-            self.editing_state.write().push(EditingMessage::Cancel);
-        }
-        self.layout_edit = LayoutEditState::Idle;
-        self.load_guard = None;
-        self.render_args.subscriptions.write().clear();
-        // the old pool took a pending request with it
-        self.migrations_loading = false;
-        // they belong to the old view
-        self.render_args.migrations.write().clear();
-        self.load_finished_time = None;
-        self.status_refused = false;
-        self.view_guests.clear();
-        self.bulk_dialog = None;
-        self.shown_task = None;
-        let view = ctx.props().view.clone();
-        self.async_pool.send_future(ctx.link().clone(), async move {
-            Msg::ViewTemplateLoaded(load_template(view).await)
-        });
-        true
-    }
-
     fn view(&self, ctx: &yew::Context<Self>) -> yew::Html {
         let props = ctx.props();
         let link = ctx.link();
-- 
2.47.3





  parent reply	other threads:[~2026-11-30 12:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 12:52 [PATCH datacenter-manager/proxmox-yew-comp/yew-widget-toolkit v3 0/8] ui: make the default dashboard configurable and add "My Settings" dialog Dominik Csapak
2026-11-30 12:52 ` [PATCH yew-widget-toolkit v3 1/8] state: event: add helper to dispatch custom DOM events Dominik Csapak
2026-11-30 12:52 ` [PATCH yew-widget-toolkit v3 2/8] state: persistent state: allow listening for updates Dominik Csapak
2026-11-30 12:52 ` [PATCH proxmox-yew-comp v3 3/8] xtermjs: allow setting the noVNC scaling mode Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 4/8] ui: view selector: use a placeholder that can't conflict with a view Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 5/8] ui: add 'My Settings' dialog with xterm.js and noVNC settings Dominik Csapak
2026-11-30 12:52 ` Dominik Csapak [this message]
2026-11-30 12:52 ` [PATCH datacenter-manager v3 7/8] ui: make the default dashboard page configurable Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 8/8] docs: web ui: describe the 'My Settings' dialog Dominik Csapak

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=20261130125325.2392967-7-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-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