all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager] ui: dashboard: allow add PBS remotes via dashboard
Date: Fri, 26 Sep 2025 13:45:35 +0200	[thread overview]
Message-ID: <20250926114535.413361-1-c.ebner@proxmox.com> (raw)

Extend the current add button to a dropdown menu so it is possible to
add PVE as well as PBS remotes.

Instead of using a boolean to show/hide the wizard, set the remote type
as option, not showing the wizard if none is set, otherwise showing the
wizard for the corresponding type.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 ui/src/dashboard/mod.rs | 50 +++++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 19 deletions(-)

diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
index 27c0944..f54c509 100644
--- a/ui/src/dashboard/mod.rs
+++ b/ui/src/dashboard/mod.rs
@@ -19,12 +19,14 @@ use pwt::{
     widget::{
         error_message,
         form::{DisplayField, FormContext, Number},
-        Button, Column, Container, Fa, InputPanel, Panel, Row,
+        menu::{Menu, MenuButton, MenuItem},
+        Column, Container, Fa, InputPanel, Panel, Row,
     },
     AsyncPool,
 };
 
 use pdm_api_types::{
+    remotes::RemoteType,
     resource::{NodeStatusCount, ResourcesStatus},
     TaskStatistics,
 };
@@ -116,7 +118,7 @@ pub enum LoadingResult {
 pub enum Msg {
     LoadingFinished(LoadingResult),
     RemoteListChanged(RemoteList),
-    CreateWizard(bool),
+    CreateWizard(Option<RemoteType>),
     Reload,
     ForceReload,
     UpdateConfig(DashboardConfig),
@@ -139,7 +141,7 @@ pub struct PdmDashboard {
     loading: bool,
     load_finished_time: Option<f64>,
     remote_list: RemoteList,
-    show_wizard: bool,
+    show_wizard: Option<RemoteType>,
     show_config_window: bool,
     _context_listener: ContextHandle<RemoteList>,
     async_pool: AsyncPool,
@@ -415,7 +417,7 @@ impl Component for PdmDashboard {
             loading: true,
             load_finished_time: None,
             remote_list,
-            show_wizard: false,
+            show_wizard: None,
             show_config_window: false,
             _context_listener,
             async_pool,
@@ -471,8 +473,8 @@ impl Component for PdmDashboard {
                 self.remote_list = remote_list;
                 changed
             }
-            Msg::CreateWizard(show) => {
-                self.show_wizard = show;
+            Msg::CreateWizard(remote_type) => {
+                self.show_wizard = remote_type;
                 true
             }
             Msg::Reload => {
@@ -541,9 +543,23 @@ impl Component for PdmDashboard {
                             .width(300)
                             .min_height(175)
                             .with_tool(
-                                Button::new(tr!("Add"))
-                                    .icon_class("fa fa-plus-circle")
-                                    .on_activate(ctx.link().callback(|_| Msg::CreateWizard(true))),
+                                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())),
                     )
@@ -665,18 +681,14 @@ impl Component for PdmDashboard {
         Panel::new()
             .class(FlexFit)
             .with_child(content)
-            // FIXME: make pbs also addable?
             .with_optional_child(
-                self.show_wizard.then_some(
-                    AddWizard::new(pdm_api_types::remotes::RemoteType::Pve)
-                        .on_close(ctx.link().callback(|_| Msg::CreateWizard(false)))
+                self.show_wizard.map(|remote_type| {
+                    AddWizard::new(remote_type)
+                        .on_close(ctx.link().callback(|_| Msg::CreateWizard(None)))
                         .on_submit(move |ctx| {
-                            crate::remotes::create_remote(
-                                ctx,
-                                pdm_api_types::remotes::RemoteType::Pve,
-                            )
-                        }),
-                ),
+                            crate::remotes::create_remote(ctx, remote_type)
+                        })
+                }),
             )
             .with_optional_child(
                 self.show_config_window.then_some(
-- 
2.47.3



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


             reply	other threads:[~2025-09-26 11:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26 11:45 Christian Ebner [this message]
2025-09-26 13:59 ` [pdm-devel] applied: " Thomas Lamprecht

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=20250926114535.413361-1-c.ebner@proxmox.com \
    --to=c.ebner@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal