[pdm-devel] [PATCH datacenter-manager v3 13/21] ui: dashboard: pbs datastores panel: refactor creation into own module

Dominik Csapak d.csapak at proxmox.com
Fri Oct 31 13:43:56 CET 2025


so we can use it more easily outside the `Dashboard` struct.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 ui/src/dashboard/mod.rs                  | 26 +++++----------------
 ui/src/dashboard/pbs_datastores_panel.rs | 29 ++++++++++++++++--------
 2 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
index 51341737..ee40405b 100644
--- a/ui/src/dashboard/mod.rs
+++ b/ui/src/dashboard/mod.rs
@@ -47,14 +47,13 @@ use status_row::DashboardStatusRow;
 mod filtered_tasks;
 
 mod pbs_datastores_panel;
-use pbs_datastores_panel::PbsDatastoresPanel;
+pub use pbs_datastores_panel::create_pbs_datastores_panel;
 
 mod tasks;
 use tasks::{create_task_summary_panel, get_task_options};
 
 pub mod types;
 
-
 mod refresh_config_edit;
 pub use refresh_config_edit::{
     create_refresh_config_edit_window, refresh_config_id, RefreshConfig,
@@ -118,23 +117,6 @@ pub struct PdmDashboard {
 }
 
 impl PdmDashboard {
-    fn create_pbs_datastores_panel(&self) -> Panel {
-        let pbs_datastores = self
-            .status
-            .as_ref()
-            .map(|status| status.pbs_datastores.clone());
-
-        Panel::new()
-            .flex(1.0)
-            .width(300)
-            .title(create_title_with_icon(
-                "database",
-                tr!("Backup Server Datastores"),
-            ))
-            .border(true)
-            .with_child(PbsDatastoresPanel::new(pbs_datastores))
-    }
-
     fn reload(&mut self, ctx: &yew::Context<Self>) {
         let max_age = if self.loaded_once {
             self.config.max_age.unwrap_or(DEFAULT_MAX_AGE_S)
@@ -364,7 +346,11 @@ impl Component for PdmDashboard {
                             .flex(1.0)
                             .width(300),
                     )
-                    .with_child(self.create_pbs_datastores_panel())
+                    .with_child(
+                        create_pbs_datastores_panel(self.status.clone())
+                            .flex(1.0)
+                            .width(300),
+                    )
                     .with_child(
                         create_subscription_panel()
                             .flex(1.0)
diff --git a/ui/src/dashboard/pbs_datastores_panel.rs b/ui/src/dashboard/pbs_datastores_panel.rs
index a06acf7f..6542ac00 100644
--- a/ui/src/dashboard/pbs_datastores_panel.rs
+++ b/ui/src/dashboard/pbs_datastores_panel.rs
@@ -1,18 +1,15 @@
 use std::rc::Rc;
 
-use pdm_api_types::resource::{PbsDatastoreStatusCount, ResourceType};
+use yew::virtual_dom::{VComp, VNode};
+
+use pdm_api_types::resource::{PbsDatastoreStatusCount, ResourceType, ResourcesStatus};
 use pdm_search::{Search, SearchTerm};
 use proxmox_yew_comp::Status;
-use pwt::{
-    css::{self, TextAlign},
-    prelude::*,
-    widget::{Container, Fa, List, ListTile},
-};
-use yew::{
-    virtual_dom::{VComp, VNode},
-    Properties,
-};
+use pwt::css::{self, TextAlign};
+use pwt::prelude::*;
+use pwt::widget::{Container, Fa, List, ListTile, Panel};
 
+use crate::dashboard::create_title_with_icon;
 use crate::search_provider::get_search_provider;
 
 use super::loading_column;
@@ -157,3 +154,15 @@ fn create_pbs_datastores_status_search_term(search_term: Option<(&str, &str)>) -
     }
     Search::with_terms(terms)
 }
+
+pub fn create_pbs_datastores_panel(status: Option<ResourcesStatus>) -> Panel {
+    let pbs_datastores = status.map(|status| status.pbs_datastores.clone());
+
+    Panel::new()
+        .title(create_title_with_icon(
+            "database",
+            tr!("Backup Server Datastores"),
+        ))
+        .border(true)
+        .with_child(PbsDatastoresPanel::new(pbs_datastores))
+}
-- 
2.47.3





More information about the pdm-devel mailing list