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: [pdm-devel] [PATCH datacenter-manager v2 03/16] ui: dashboard: refactor remote panel creation into its own module
Date: Thu, 23 Oct 2025 10:28:07 +0200	[thread overview]
Message-ID: <20251023083253.1038119-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20251023083253.1038119-1-d.csapak@proxmox.com>

so we can more easily reuse them outside the dashboard struct.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/dashboard/mod.rs          | 39 ++++++++-------------------
 ui/src/dashboard/remote_panel.rs | 46 ++++++++++++++++++++++++--------
 2 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
index 2e170443..2fe4d7fa 100644
--- a/ui/src/dashboard/mod.rs
+++ b/ui/src/dashboard/mod.rs
@@ -19,7 +19,6 @@ use pwt::{
     widget::{
         error_message,
         form::{DisplayField, FormContext, Number},
-        menu::{Menu, MenuButton, MenuItem},
         Column, Container, Fa, InputPanel, Panel, Row,
     },
     AsyncPool,
@@ -41,7 +40,7 @@ mod node_panel;
 pub use node_panel::create_node_panel;
 
 mod remote_panel;
-use remote_panel::RemotePanel;
+pub use remote_panel::create_remote_panel;
 
 mod guest_panel;
 pub use guest_panel::create_guest_panel;
@@ -422,32 +421,16 @@ impl Component for PdmDashboard {
                     .class(FlexWrap::Wrap)
                     .padding_top(0)
                     .with_child(
-                        Panel::new()
-                            .title(create_title_with_icon("server", tr!("Remotes")))
-                            .flex(1.0)
-                            //.border(true)
-                            .width(300)
-                            .min_height(175)
-                            .with_tool(
-                                MenuButton::new(tr!("Add")).show_arrow(true).menu(
-                                    Menu::new()
-                                        .with_item(
-                                            MenuItem::new("Proxmox VE")
-                                                .icon_class("fa fa-building")
-                                                .on_select(ctx.link().callback(|_| {
-                                                    Msg::CreateWizard(Some(RemoteType::Pve))
-                                                })),
-                                        )
-                                        .with_item(
-                                            MenuItem::new("Proxmox Backup Server")
-                                                .icon_class("fa fa-floppy-o")
-                                                .on_select(ctx.link().callback(|_| {
-                                                    Msg::CreateWizard(Some(RemoteType::Pbs))
-                                                })),
-                                        ),
-                                ),
-                            )
-                            .with_child(RemotePanel::new(self.status.clone())),
+                        create_remote_panel(
+                            self.status.clone(),
+                            ctx.link()
+                                .callback(|_| Msg::CreateWizard(Some(RemoteType::Pve))),
+                            ctx.link()
+                                .callback(|_| Msg::CreateWizard(Some(RemoteType::Pbs))),
+                        )
+                        .flex(1.0)
+                        .width(300)
+                        .min_height(175),
                     )
                     .with_child(
                         create_node_panel(Some(RemoteType::Pve), self.status.clone())
diff --git a/ui/src/dashboard/remote_panel.rs b/ui/src/dashboard/remote_panel.rs
index 75f772fb..27eebac2 100644
--- a/ui/src/dashboard/remote_panel.rs
+++ b/ui/src/dashboard/remote_panel.rs
@@ -1,21 +1,19 @@
 use std::rc::Rc;
 
+use yew::html::IntoEventCallback;
+use yew::virtual_dom::{VComp, VNode};
+
 use pdm_search::{Search, SearchTerm};
 use proxmox_yew_comp::Status;
-use pwt::{
-    css,
-    prelude::*,
-    props::{ContainerBuilder, WidgetBuilder},
-    widget::{Column, Container, Fa},
-};
-use yew::{
-    virtual_dom::{VComp, VNode},
-    Component, Properties,
-};
+use pwt::css;
+use pwt::prelude::*;
+use pwt::props::{ContainerBuilder, WidgetBuilder};
+use pwt::widget::menu::{Menu, MenuButton, MenuEvent, MenuItem};
+use pwt::widget::{Column, Container, Fa, Panel};
 
 use pdm_api_types::resource::ResourcesStatus;
 
-use crate::search_provider::get_search_provider;
+use crate::{dashboard::create_title_with_icon, search_provider::get_search_provider};
 
 #[derive(Properties, PartialEq)]
 /// A panel for showing the overall remotes status
@@ -116,3 +114,29 @@ fn create_search_term(failure: bool) -> Search {
         Search::with_terms(vec![SearchTerm::new("remote").category(Some("type"))])
     }
 }
+
+pub fn create_remote_panel(
+    status: Option<ResourcesStatus>,
+    on_pve_wizard: impl IntoEventCallback<MenuEvent>,
+    on_pbs_wizard: impl IntoEventCallback<MenuEvent>,
+) -> Panel {
+    Panel::new()
+        .title(create_title_with_icon("server", tr!("Remotes")))
+        .border(true)
+        .with_tool(
+            MenuButton::new(tr!("Add")).show_arrow(true).menu(
+                Menu::new()
+                    .with_item(
+                        MenuItem::new("Proxmox VE")
+                            .icon_class("fa fa-building")
+                            .on_select(on_pve_wizard),
+                    )
+                    .with_item(
+                        MenuItem::new("Proxmox Backup Server")
+                            .icon_class("fa fa-floppy-o")
+                            .on_select(on_pbs_wizard),
+                    ),
+            ),
+        )
+        .with_child(RemotePanel::new(status))
+}
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  parent reply	other threads:[~2025-10-23  8:32 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23  8:28 [pdm-devel] [PATCH datacenter-manager v2 00/16] prepare ui for customizable views Dominik Csapak
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 01/16] ui: dashboard: refactor guest panel creation to its own module Dominik Csapak
2025-10-23 11:19   ` Shannon Sterz
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 02/16] ui: dashboard: refactor creating the node panel into " Dominik Csapak
2025-10-23 11:19   ` Shannon Sterz
2025-10-23  8:28 ` Dominik Csapak [this message]
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 04/16] ui: dashboard: remote panel: make wizard menu optional Dominik Csapak
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 05/16] ui: dashboard: refactor sdn panel creation into its own module Dominik Csapak
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 06/16] ui: dashboard: refactor task summary panel creation to " Dominik Csapak
2025-10-23 11:19   ` Shannon Sterz
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 07/16] ui: dashboard: task summary: disable virtual scrolling Dominik Csapak
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 08/16] ui: dashboard: refactor subscription panel creation to its own module Dominik Csapak
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 09/16] ui: dashboard: refactor top entities " Dominik Csapak
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 10/16] ui: dashboard: refactor DashboardConfig editing/constants to their module Dominik Csapak
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 11/16] ui: dashboard: factor out task parameter calculation Dominik Csapak
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 12/16] ui: dashboard: remove unused remote list Dominik Csapak
2025-10-23  8:28 ` [pdm-devel] [PATCH datacenter-manager v2 13/16] ui: dashboard: status row: make loading less jarring Dominik Csapak
2025-10-23 11:19   ` Shannon Sterz
2025-10-23  8:28 ` [pdm-devel] [RFC PATCH datacenter-manager v2 14/16] ui: introduce `LoadResult` helper type Dominik Csapak
2025-10-23 11:19   ` Shannon Sterz
2025-10-23  8:28 ` [pdm-devel] [RFC PATCH datacenter-manager v2 15/16] ui: dashboard: implement 'View' Dominik Csapak
2025-10-23 11:19   ` Shannon Sterz
2025-10-23 11:44     ` Dominik Csapak
2025-10-23 11:48       ` Dominik Csapak
2025-10-24 10:17         ` Shannon Sterz
2025-10-23  8:28 ` [pdm-devel] [RFC PATCH datacenter-manager v2 16/16] ui: dashboard: use 'View' instead of the Dashboard Dominik Csapak
2025-10-23 11:19   ` Shannon Sterz
2025-10-23 11:20 ` [pdm-devel] [PATCH datacenter-manager v2 00/16] prepare ui for customizable views Shannon Sterz

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=20251023083253.1038119-4-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