From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id BB66B1FF179 for ; Wed, 26 Nov 2025 16:19:11 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B3D1510435; Wed, 26 Nov 2025 16:19:10 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Wed, 26 Nov 2025 16:18:18 +0100 Message-ID: <20251126151833.3637080-26-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251126151833.3637080-1-d.csapak@proxmox.com> References: <20251126151833.3637080-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 v5 25/26] ui: dashboard view: refactor widget rendering arguments into struct 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" This way, adding a new parameter is easier and we don't have to write them all out twice. Signed-off-by: Dominik Csapak --- ui/src/dashboard/view.rs | 57 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index e6a86bc9..6b3baf3a 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -100,12 +100,7 @@ pub enum Msg { struct ViewComp { template: LoadResult, - // various api call results - status: SharedState>, - top_entities: SharedState>, - statistics: SharedState>, - subscriptions: SharedState, Error>>, - + render_args: WidgetRenderArgs, refresh_config: PersistentState, async_pool: AsyncPool, @@ -119,15 +114,27 @@ struct ViewComp { update_result: LoadResult<(), Error>, } -fn render_widget( - link: yew::html::Scope, - item: &RowWidget, +#[derive(Clone)] +struct WidgetRenderArgs { status: SharedState>, subscriptions: SharedState, Error>>, top_entities: SharedState>, statistics: SharedState>, +} + +fn render_widget( + link: yew::html::Scope, + item: &RowWidget, + render_args: WidgetRenderArgs, refresh_config: RefreshConfig, ) -> Html { + let WidgetRenderArgs { + status, + subscriptions, + top_entities, + statistics, + } = render_args; + let mut widget = match &item.r#type { WidgetType::Nodes { remote_type } => create_node_panel(*remote_type, status), WidgetType::Guests { guest_type } => { @@ -321,11 +328,6 @@ impl Component for ViewComp { template: LoadResult::new(), async_pool, - status: SharedState::new(LoadResult::new()), - top_entities: SharedState::new(LoadResult::new()), - statistics: SharedState::new(LoadResult::new()), - subscriptions: SharedState::new(LoadResult::new()), - refresh_config, load_finished_time: None, loading: true, @@ -335,6 +337,13 @@ impl Component for ViewComp { editing_state: SharedState::new(Vec::new()), update_result: LoadResult::new(), + + render_args: WidgetRenderArgs { + status: SharedState::new(LoadResult::new()), + top_entities: SharedState::new(LoadResult::new()), + statistics: SharedState::new(LoadResult::new()), + subscriptions: SharedState::new(LoadResult::new()), + }, } } @@ -345,15 +354,15 @@ impl Component for ViewComp { self.reload(ctx); } Msg::LoadingResult(loading_result) => match loading_result { - LoadingResult::Resources(status) => self.status.write().update(status), + LoadingResult::Resources(status) => self.render_args.status.write().update(status), LoadingResult::TopEntities(top_entities) => { - self.top_entities.write().update(top_entities) + self.render_args.top_entities.write().update(top_entities) } LoadingResult::TaskStatistics(task_statistics) => { - self.statistics.write().update(task_statistics) + self.render_args.statistics.write().update(task_statistics) } LoadingResult::SubscriptionInfo(subscriptions) => { - self.subscriptions.write().update(subscriptions); + self.render_args.subscriptions.write().update(subscriptions); } LoadingResult::All => { self.loading = false; @@ -455,7 +464,7 @@ impl Component for ViewComp { ); if !has_sub_panel(self.template.data.as_ref()) { - let subs = self.subscriptions.clone(); + let subs = self.render_args.subscriptions.clone(); let link = ctx.link().clone(); view.add_child( Row::new() @@ -483,19 +492,13 @@ impl Component for ViewComp { view.add_child( RowView::new(rows.clone(), { let link = ctx.link().clone(); - let status = self.status.clone(); - let subscriptions = self.subscriptions.clone(); - let top_entities = self.top_entities.clone(); - let statistics = self.statistics.clone(); + let args = self.render_args.clone(); let refresh_config = self.refresh_config.clone(); move |widget: &RowWidget| { render_widget( link.clone(), widget, - status.clone(), - subscriptions.clone(), - top_entities.clone(), - statistics.clone(), + args.clone(), refresh_config.clone(), ) } -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel