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 v2 5/6] ui: view selector: use a placeholder that can't conflict with a view
Date: Fri, 27 Nov 2026 18:09:26 +0100	[thread overview]
Message-ID: <20261127170941.4183880-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261127170941.4183880-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 | 11 +++++++++--
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/ui/src/configuration/views.rs b/ui/src/configuration/views.rs
index 955fbb20..91d2361f 100644
--- a/ui/src/configuration/views.rs
+++ b/ui/src/configuration/views.rs
@@ -24,7 +24,7 @@ use pwt::widget::{Button, ConfirmDialog, InputPanel, Toolbar};
 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,
@@ -38,7 +38,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 888a0e19..57088558 100644
--- a/ui/src/widget/mod.rs
+++ b/ui/src/widget/mod.rs
@@ -34,7 +34,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..9ea9a065 100644
--- a/ui/src/widget/view_selector.rs
+++ b/ui/src/widget/view_selector.rs
@@ -7,6 +7,13 @@ 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 a value that can't be used
+/// in the backend.
+// '#' is too short and uses a forbidden character.
+pub const DEFAULT_DASHBOARD_VALUE: &str = "#";
+
 #[widget(comp=ViewSelectorComp, @input)]
 #[derive(Clone, Properties, PartialEq)]
 #[builder]
@@ -32,7 +39,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 +50,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-27 17:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 17:09 [PATCH datacenter-manager/yew-widget-toolkit v2 0/6] ui: make the default dashboard configurable and add "My Settings" dialog Dominik Csapak
2026-11-27 17:09 ` [PATCH yew-widget-toolkit v2 1/6] state: event: add helpers for custom DOM events Dominik Csapak
2026-11-27 17:09 ` [PATCH yew-widget-toolkit v2 2/6] state: persistent state: allow listening for updates Dominik Csapak
2026-11-27 17:09 ` [PATCH datacenter-manager v2 3/6] ui: add 'My Settings' dialog with xterm.js and noVNC settings Dominik Csapak
2026-11-27 17:09 ` [PATCH datacenter-manager v2 4/6] ui: view configuration: fix dismissing of remove confirmation dialog Dominik Csapak
2026-11-27 17:09 ` Dominik Csapak [this message]
2026-11-27 17:09 ` [PATCH datacenter-manager v2 6/6] ui: make the default dashboard page configurable 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=20261127170941.4183880-6-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