From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 825591FF0B7 for ; Mon, 30 Nov 2026 13:53:52 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 326722171C; Mon, 30 Nov 2026 13:53:48 +0100 (CET) From: Dominik Csapak 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 Message-ID: <20261130125325.2392967-7-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130125325.2392967-1-d.csapak@proxmox.com> References: <20261130125325.2392967-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.247 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: VBO4NBDQC443H4B4H6R2CINNQWE3LLQS X-Message-ID-Hash: VBO4NBDQC443H4B4H6R2CINNQWE3LLQS X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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 for VNode { fn from(val: View) -> Self { - let comp = VComp::new::(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::(Rc::new(val), key); VNode::from(comp) } } @@ -1073,35 +1075,6 @@ impl Component for ViewComp { true } - fn changed(&mut self, ctx: &Context, 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) -> yew::Html { let props = ctx.props(); let link = ctx.link(); -- 2.47.3