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: [PATCH datacenter-manager v3 4/8] ui: view selector: use a placeholder that can't conflict with a view
Date: Mon, 30 Nov 2026 13:52:38 +0100	[thread overview]
Message-ID: <20261130125325.2392967-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261130125325.2392967-1-d.csapak@proxmox.com>

since a view could be named '__dashboard__' too. Use '#' instead,
which is not a valid view ID, and expose it as a constant, so that the
code creating the view can use it too.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/configuration/views.rs  |  4 ++--
 ui/src/widget/mod.rs           |  2 +-
 ui/src/widget/view_selector.rs | 10 ++++++++--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/ui/src/configuration/views.rs b/ui/src/configuration/views.rs
index fca40490..26e4852b 100644
--- a/ui/src/configuration/views.rs
+++ b/ui/src/configuration/views.rs
@@ -26,7 +26,7 @@ use pwt::widget::{Button, ConfirmDialog, InputPanel, Toolbar, Tooltip};
 use pdm_api_types::views::{ViewConfig, ViewLayout, ViewTemplate};
 
 use crate::ViewListContext;
-use crate::widget::{ViewFilterSelector, ViewSelector};
+use crate::widget::{DEFAULT_DASHBOARD_VALUE, ViewFilterSelector, ViewSelector};
 
 async fn create_view(
     base_url: AttrValue,
@@ -40,7 +40,7 @@ async fn create_view(
             description: String::new(),
             layout: ViewLayout::Rows { rows: Vec::new() },
         })?),
-        "__dashboard__" => None,
+        DEFAULT_DASHBOARD_VALUE => None,
         layout => {
             let store = store.read();
             if let Some(config) = store.lookup_record(&Key::from(layout)) {
diff --git a/ui/src/widget/mod.rs b/ui/src/widget/mod.rs
index 24f5b9e8..353be148 100644
--- a/ui/src/widget/mod.rs
+++ b/ui/src/widget/mod.rs
@@ -37,7 +37,7 @@ pub use remote_selector::RemoteSelector;
 mod remote_endpoint_selector;
 
 mod view_selector;
-pub use view_selector::ViewSelector;
+pub use view_selector::{DEFAULT_DASHBOARD_VALUE, ViewSelector};
 
 mod view_filter_selector;
 pub use view_filter_selector::ViewFilterSelector;
diff --git a/ui/src/widget/view_selector.rs b/ui/src/widget/view_selector.rs
index b48ef4f7..c95fbba1 100644
--- a/ui/src/widget/view_selector.rs
+++ b/ui/src/widget/view_selector.rs
@@ -7,6 +7,12 @@ use pwt_macros::{builder, widget};
 
 use pdm_api_types::views::ViewConfig;
 
+/// A placeholder value to represent the default dashboard.
+///
+/// To not conflict with a real view, this is not a valid view ID: '#' is shorter than the minimum
+/// length of two and not an allowed character in it.
+pub const DEFAULT_DASHBOARD_VALUE: &str = "#";
+
 #[widget(comp=ViewSelectorComp, @input)]
 #[derive(Clone, Properties, PartialEq)]
 #[builder]
@@ -32,7 +38,7 @@ impl Component for ViewSelectorComp {
     }
 
     fn view(&self, ctx: &Context<Self>) -> Html {
-        let mut list = vec!["__dashboard__".into()];
+        let mut list = vec![DEFAULT_DASHBOARD_VALUE.into()];
         let store = &ctx.props().store;
         for item in store.read().data().iter() {
             list.push(item.id.clone().into());
@@ -43,7 +49,7 @@ impl Component for ViewSelectorComp {
             .on_change(|_| {})
             .render_value({
                 move |value: &AttrValue| {
-                    if value == "__dashboard__" {
+                    if value == DEFAULT_DASHBOARD_VALUE {
                         html! {{tr!("Dashboard")}}
                     } else {
                         html! {{value}}
-- 
2.47.3





  parent reply	other threads:[~2026-11-30 12:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 12:52 [PATCH datacenter-manager/proxmox-yew-comp/yew-widget-toolkit v3 0/8] ui: make the default dashboard configurable and add "My Settings" dialog Dominik Csapak
2026-11-30 12:52 ` [PATCH yew-widget-toolkit v3 1/8] state: event: add helper to dispatch custom DOM events Dominik Csapak
2026-11-30 12:52 ` [PATCH yew-widget-toolkit v3 2/8] state: persistent state: allow listening for updates Dominik Csapak
2026-11-30 12:52 ` [PATCH proxmox-yew-comp v3 3/8] xtermjs: allow setting the noVNC scaling mode Dominik Csapak
2026-11-30 12:52 ` Dominik Csapak [this message]
2026-11-30 12:52 ` [PATCH datacenter-manager v3 5/8] ui: add 'My Settings' dialog with xterm.js and noVNC settings Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 6/8] ui: views: use the view name as key of the component Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 7/8] ui: make the default dashboard page configurable Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 8/8] docs: web ui: describe the 'My Settings' dialog Dominik Csapak

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=20261130125325.2392967-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 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