From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 959341FF14F for ; Fri, 08 May 2026 17:57:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7946C1D62D; Fri, 8 May 2026 17:57:37 +0200 (CEST) From: Shannon Sterz To: yew-devel@lists.proxmox.com Subject: [PATCH yew-mobile-gui v2 21/21] resources page: map subscription level analogous to dashboard Date: Fri, 8 May 2026 17:57:22 +0200 Message-ID: <20260508155722.464564-22-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260508155722.464564-1-s.sterz@proxmox.com> References: <20260508155722.464564-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778255736947 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.115 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: DSPCEEX5ZXIEHM3V6M4JDGJGLEJLHJZM X-Message-ID-Hash: DSPCEEX5ZXIEHM3V6M4JDGJGLEJLHJZM X-MailFrom: s.sterz@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: Yew framework devel list at Proxmox List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: and unify the mapping logic. Signed-off-by: Shannon Sterz Tested-by: Shan Shaji --- Notes: i couldn't find a similar helper anyway in yew-comp yet, so i added this here for now. Thomas' recent series [1] added something like that, but that would only be available for pdm. maybe we should have something like this in yew-comp? [1]: https://lore.proxmox.com/pdm-devel/20260507082943.2749725-3-t.lamprecht@proxmox.com/ src/pages/mod.rs | 13 +++++++++++++ src/pages/page_dashboard.rs | 13 ++----------- src/pages/page_resources.rs | 8 +++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/pages/mod.rs b/src/pages/mod.rs index bc5ff97..3d945a0 100644 --- a/src/pages/mod.rs +++ b/src/pages/mod.rs @@ -45,3 +45,16 @@ pub use page_cluster_firewall::PageClusterFirewall; mod page_not_found; pub use page_not_found::PageNotFound; + +fn map_subscription(level: &Option) -> &str { + match level.as_deref() { + Some("") | None => "no subscription", + Some(level) => match level { + "c" => "Community", + "b" => "Basic", + "s" => "Standard", + "p" => "Premium", + _ => "-", + }, + } +} diff --git a/src/pages/page_dashboard.rs b/src/pages/page_dashboard.rs index 1e0243f..fe2f5b4 100644 --- a/src/pages/page_dashboard.rs +++ b/src/pages/page_dashboard.rs @@ -20,7 +20,7 @@ use proxmox_yew_comp::layout::list_tile::{icon_list_tile, list_tile_usage}; use proxmox_yew_comp::layout::render_loaded_data; use proxmox_yew_comp::{SubscriptionAlert, http_get}; -use crate::pages::ResourceFilter; +use crate::pages::{ResourceFilter, map_subscription}; use crate::widgets::TopNavBar; #[derive(Clone, PartialEq, Properties)] @@ -202,16 +202,7 @@ impl PvePageDashboard { let navigator = navigator.clone(); let item = &nodes[pos as usize]; let nodename = item.node.clone(); - let subtitle = match item.level.as_deref() { - Some("") | None => "no subscription", - Some(level) => match level { - "c" => "Community", - "b" => "Basic", - "s" => "Standard", - "p" => "Premium", - _ => "-", - }, - }; + let subtitle = map_subscription(&item.level); icon_list_tile( Fa::new("server").class( diff --git a/src/pages/page_resources.rs b/src/pages/page_resources.rs index 469bbf3..470a054 100644 --- a/src/pages/page_resources.rs +++ b/src/pages/page_resources.rs @@ -23,6 +23,8 @@ use proxmox_yew_comp::layout::render_loaded_data; use pve_api_types::{ClusterResource, ClusterResourceType}; +use crate::pages::map_subscription; + #[derive(Clone, PartialEq, Properties)] pub struct PageResources {} @@ -119,11 +121,7 @@ impl PvePageResources { Fa::new("server") .class((item.status.as_deref() == Some("online")).then_some("pwt-color-primary")), nodename.clone(), - match item.level.as_deref() { - Some("") | None => "no subscription", - Some(level) => level, - } - .to_string(), + map_subscription(&item.level), item.status.clone(), ) .interactive(true) -- 2.47.3