From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 1A51B1FF0B7 for ; Mon, 30 Nov 2026 13:53:30 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A29CC21666; Mon, 30 Nov 2026 13:53:29 +0100 (CET) From: Dominik Csapak 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 Message-ID: <20261130125325.2392967-5-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130125325.2392967-1-d.csapak@proxmox.com> References: <20261130125325.2392967-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.249 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: Q4ZPZ4VWSCLJOY7T6JYJ3N42TGFVA3DT X-Message-ID-Hash: Q4ZPZ4VWSCLJOY7T6JYJ3N42TGFVA3DT X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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) -> 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