all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager 4/4] ui: dashboard: show special empty state when no remotes are configured
Date: Fri, 29 May 2026 08:53:28 +0200	[thread overview]
Message-ID: <20260529065506.222086-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260529065506.222086-1-d.csapak@proxmox.com>

In the default dashboard, it makes no sense to show the widget when we
don't have any remotes configured, as that cannot show any useful data.
(In contrast to views, this could show things based on the views
permissions/settings).

Show a 'no remotes configured' + the add remotes buttons below.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/dashboard/view.rs | 80 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 76 insertions(+), 4 deletions(-)

diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs
index 2f379d24..64480310 100644
--- a/ui/src/dashboard/view.rs
+++ b/ui/src/dashboard/view.rs
@@ -15,8 +15,8 @@ use pwt::prelude::*;
 use pwt::props::StorageLocation;
 use pwt::state::{PersistentState, SharedState};
 use pwt::widget::container::span;
+use pwt::widget::{Button, Fa, Panel, Row};
 use pwt::widget::{Column, Container, Progress, error_message, form::FormContext};
-use pwt::widget::{Fa, Panel, Row};
 
 use crate::dashboard::refresh_config_edit::{
     DEFAULT_MAX_AGE_S, DEFAULT_REFRESH_INTERVAL_S, FORCE_RELOAD_MAX_AGE_S, INITIAL_MAX_AGE_S,
@@ -31,8 +31,9 @@ use crate::dashboard::{
     create_task_summary_panel, create_top_entities_panel,
 };
 use crate::remotes::AddWizard;
+use crate::renderer::empty_state;
 use crate::widget::RedrawController;
-use crate::{LoadResult, pdm_client};
+use crate::{LoadResult, RemoteList, pdm_client};
 
 use pdm_api_types::remotes::RemoteType;
 use pdm_api_types::resource::ResourcesStatus;
@@ -100,6 +101,7 @@ pub enum Msg {
     LayoutUpdate(ViewLayout),
     UpdateResult(Result<(), Error>),
     ForceSubscriptionUpdate,
+    RemoteListUpdate(RemoteList),
 }
 
 struct ViewComp {
@@ -115,6 +117,9 @@ struct ViewComp {
     show_create_wizard: Option<RemoteType>,
     subscriptions_dialog: bool,
 
+    remote_list: Option<RemoteList>,
+    _remote_list_handle: Option<ContextHandle<RemoteList>>,
+
     editing_state: SharedState<Vec<EditingMessage>>,
     update_result: LoadResult<(), Error>,
 }
@@ -336,6 +341,7 @@ impl Component for ViewComp {
     type Properties = View;
 
     fn create(ctx: &yew::Context<Self>) -> Self {
+        let link = ctx.link();
         let view = ctx.props().view.clone();
         let refresh_id = match view.as_ref() {
             Some(view) => format!("view-{view}"),
@@ -344,8 +350,18 @@ impl Component for ViewComp {
         let refresh_config: PersistentState<RefreshConfig> =
             PersistentState::new(StorageLocation::local(refresh_config_id(&refresh_id)));
 
+        // only query the remotes if we're the default dashboard to show the warning
+        let (remote_list, _remote_list_handle) = if view.is_none() {
+            let (list, handle) = link
+                .context(link.callback(Msg::RemoteListUpdate))
+                .expect("no remote list context");
+            (Some(list), Some(handle))
+        } else {
+            (None, None)
+        };
+
         let async_pool = AsyncPool::new();
-        async_pool.send_future(ctx.link().clone(), async move {
+        async_pool.send_future(link.clone(), async move {
             Msg::ViewTemplateLoaded(load_template(view).await)
         });
 
@@ -363,6 +379,9 @@ impl Component for ViewComp {
             editing_state: SharedState::new(Vec::new()),
             update_result: LoadResult::new(),
 
+            remote_list,
+            _remote_list_handle,
+
             render_args: WidgetRenderArgs {
                 status: SharedState::new(LoadResult::new()),
                 top_entities: SharedState::new(LoadResult::new()),
@@ -414,7 +433,6 @@ impl Component for ViewComp {
                     self.reload(ctx);
                 }
             }
-
             Msg::ConfigWindow(show) => {
                 self.show_config_window = show;
             }
@@ -474,6 +492,18 @@ impl Component for ViewComp {
                     link.send_message(Msg::LoadingResult(LoadingResult::SubscriptionInfo(res)));
                 });
             }
+            Msg::RemoteListUpdate(remote_list) => {
+                let needs_reload = match &self.remote_list {
+                    Some(list) => list.is_empty() && !remote_list.is_empty(),
+                    _ => false,
+                };
+                self.remote_list = Some(remote_list);
+                if needs_reload {
+                    // reset loading time to trigger a fresh reload
+                    self.load_finished_time = None;
+                    self.reload(ctx);
+                }
+            }
         }
         true
     }
@@ -490,9 +520,51 @@ impl Component for ViewComp {
 
     fn view(&self, ctx: &yew::Context<Self>) -> yew::Html {
         let props = ctx.props();
+        let link = ctx.link();
         if !self.template.has_data() {
             return Progress::new().into();
         }
+
+        match self.remote_list.as_ref() {
+            Some(list) if list.is_empty() => {
+                return Column::new()
+                    .class(css::FlexFit)
+                    .class(css::AlignItems::Center)
+                    .class(css::JustifyContent::Center)
+                    .gap(2)
+                    .with_child(Container::new().with_child(empty_state(
+                        "server",
+                        tr!("No remotes configured yet"),
+                        tr!("Add a remote to see data here."),
+                    )))
+                    .with_child(
+                        Row::new()
+                            .gap(2)
+                            .with_child(
+                                Button::new("Add PVE Remote")
+                                    .class(css::ColorScheme::Primary)
+                                    .on_activate(
+                                        link.callback(|_| Msg::CreateWizard(Some(RemoteType::Pve))),
+                                    ),
+                            )
+                            .with_child(
+                                Button::new("Add PBS Remote")
+                                    .class(css::ColorScheme::Primary)
+                                    .on_activate(
+                                        link.callback(|_| Msg::CreateWizard(Some(RemoteType::Pbs))),
+                                    ),
+                            ),
+                    )
+                    .with_optional_child(self.show_create_wizard.map(|remote_type| {
+                        AddWizard::new(remote_type)
+                            .on_close(link.callback(|_| Msg::CreateWizard(None)))
+                            .on_submit(move |ctx| crate::remotes::create_remote(ctx, remote_type))
+                    }))
+                    .into();
+            }
+            _ => {}
+        }
+
         let mut view = Column::new().class(css::FlexFit).with_child(
             Container::new()
                 .padding(4)
-- 
2.47.3





      parent reply	other threads:[~2026-05-29  6:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29  6:53 [PATCH datacenter-manager 0/4] ui: dashboard improvements Dominik Csapak
2026-05-29  6:53 ` [PATCH datacenter-manager 1/4] ui: views: vertically center gauge charts Dominik Csapak
2026-05-29  6:53 ` [PATCH datacenter-manager 2/4] ui: renderer: cleanup import structure Dominik Csapak
2026-05-29  6:53 ` [PATCH datacenter-manager 3/4] ui: factor out the 'empty_state' render helper Dominik Csapak
2026-05-29 10:11   ` Thomas Lamprecht
2026-05-29  6:53 ` Dominik Csapak [this message]

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=20260529065506.222086-5-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 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