From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A6CDC1FF17E for ; Thu, 27 Nov 2025 15:04:48 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 24FFE4DD6; Thu, 27 Nov 2025 15:05:08 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Thu, 27 Nov 2025 15:03:45 +0100 Message-ID: <20251127140451.3131469-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251127140451.3131469-1-d.csapak@proxmox.com> References: <20251127140451.3131469-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH datacenter-manager 1/4] ui: dashboard: subscriptions: refactor subscriptions show logic X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" Instead of creating the dialog in the click callback and passing it around, just to clone it again in the view. Simply set a boolean flag and create the dialog in the view method if needed. This is more in line with what we do with most dialogs and saves us a few headaches later (since the dialog will be rendered on every `view` call instead of just once). Signed-off-by: Dominik Csapak --- ui/src/dashboard/view.rs | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index 65697d38..2adcee53 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -3,7 +3,6 @@ use std::rc::Rc; use anyhow::Error; use futures::join; use js_sys::Date; -use pwt::widget::Dialog; use serde_json::{json, Value}; use yew::virtual_dom::{VComp, VNode}; @@ -93,7 +92,7 @@ pub enum Msg { Reload(bool), // force ConfigWindow(bool), // show UpdateConfig(RefreshConfig), - ShowSubscriptionsDialog(Option), + ShowSubscriptionsDialog(bool), LayoutUpdate(ViewLayout), UpdateResult(Result<(), Error>), } @@ -109,7 +108,7 @@ struct ViewComp { load_finished_time: Option, show_config_window: bool, show_create_wizard: Option, - subscriptions_dialog: Option, + subscriptions_dialog: bool, editing_state: SharedState>, update_result: LoadResult<(), Error>, @@ -151,13 +150,8 @@ fn render_widget( WidgetType::PbsDatastores => create_pbs_datastores_panel(status), WidgetType::Subscription => create_subscription_panel( subscriptions.clone(), - link.clone().callback(move |_| { - let dialog = create_subscriptions_dialog( - subscriptions.clone(), - link.callback(|_| Msg::ShowSubscriptionsDialog(None)), - ); - Msg::ShowSubscriptionsDialog(dialog) - }), + link.clone() + .callback(move |_| Msg::ShowSubscriptionsDialog(true)), ), WidgetType::Sdn => create_sdn_panel(status), WidgetType::Leaderboard { leaderboard_type } => { @@ -337,7 +331,7 @@ impl Component for ViewComp { loading: true, show_config_window: false, show_create_wizard: None, - subscriptions_dialog: None, + subscriptions_dialog: false, editing_state: SharedState::new(Vec::new()), update_result: LoadResult::new(), @@ -480,13 +474,8 @@ impl Component for ViewComp { .with_child( create_subscription_panel( subs.clone(), - link.clone().callback(move |_| { - let on_dialog_close = - link.callback(|_| Msg::ShowSubscriptionsDialog(None)); - let dialog = - create_subscriptions_dialog(subs.clone(), on_dialog_close); - Msg::ShowSubscriptionsDialog(dialog) - }), + link.clone() + .callback(move |_| Msg::ShowSubscriptionsDialog(true)), ) .flex(1.0), ), @@ -558,7 +547,14 @@ impl Component for ViewComp { .on_submit(move |ctx| crate::remotes::create_remote(ctx, remote_type)) })); - view.add_optional_child(self.subscriptions_dialog.clone()); + view.add_optional_child(if self.subscriptions_dialog { + create_subscriptions_dialog( + self.render_args.subscriptions.clone(), + ctx.link().callback(|_| Msg::ShowSubscriptionsDialog(false)), + ) + } else { + None + }); let view_context = ViewContext { name: props.view.clone(), -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel