From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 43CB91FF0B4 for ; Fri, 27 Nov 2026 18:09:54 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 52F68217BE; Fri, 27 Nov 2026 18:09:49 +0100 (CET) From: Dominik Csapak 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 Message-ID: <20261127170941.4183880-6-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127170941.4183880-1-d.csapak@proxmox.com> References: <20261127170941.4183880-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.248 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: VTMAM4QLPXHCGB6GSM4IM5F3XNMCL72C X-Message-ID-Hash: VTMAM4QLPXHCGB6GSM4IM5F3XNMCL72C 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 | 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) -> 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