From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 87C621FF13F for ; Thu, 07 May 2026 10:30:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 96B65E888; Thu, 7 May 2026 10:30:05 +0200 (CEST) From: Thomas Lamprecht To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v2 2/8] api types: subscription level: render full names Date: Thu, 7 May 2026 10:26:43 +0200 Message-ID: <20260507082943.2749725-3-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260507082943.2749725-1-t.lamprecht@proxmox.com> References: <20260507082943.2749725-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778142489453 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.003 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: FGQ5OE3RA7ZDA765OCJ5QLUZAYACKE4E X-Message-ID-Hash: FGQ5OE3RA7ZDA765OCJ5QLUZAYACKE4E X-MailFrom: t.lamprecht@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: The Display impl produced single-letter codes ("c", "b", "s", "p"), forcing the dashboard to keep a private letter-to-name helper just to render labels. Switching Display to the full names is safe: FromStr is extended to accept the names alongside the legacy single-letter codes, so any previously serialised value still parses, and the only in-tree caller of Display on this enum is the dashboard helper that this commit drops. The level strings reported by the PVE/PBS API land in unrelated String fields and are not touched. Add Debug to the derives, required for assert_eq! over the level in the upcoming key-pool tests. Signed-off-by: Thomas Lamprecht --- lib/pdm-api-types/src/subscription.rs | 24 ++++++++++++------------ ui/src/dashboard/subscriptions_list.rs | 18 ++---------------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/lib/pdm-api-types/src/subscription.rs b/lib/pdm-api-types/src/subscription.rs index ca23b8e..f0eb525 100644 --- a/lib/pdm-api-types/src/subscription.rs +++ b/lib/pdm-api-types/src/subscription.rs @@ -8,7 +8,7 @@ use proxmox_subscription::{SubscriptionInfo, SubscriptionStatus}; #[api] // order is important here, since we use that for determining if a node has a valid subscription -#[derive(Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Default, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] /// Describes the level of subscription pub enum SubscriptionLevel { #[default] @@ -50,11 +50,11 @@ impl FromStr for SubscriptionLevel { fn from_str(s: &str) -> Result { Ok(match s { - "p" => SubscriptionLevel::Premium, - "s" => SubscriptionLevel::Standard, - "b" => SubscriptionLevel::Basic, - "c" => SubscriptionLevel::Community, - "" => SubscriptionLevel::None, + "p" | "premium" | "Premium" => SubscriptionLevel::Premium, + "s" | "standard" | "Standard" => SubscriptionLevel::Standard, + "b" | "basic" | "Basic" => SubscriptionLevel::Basic, + "c" | "community" | "Community" => SubscriptionLevel::Community, + "" | "none" | "None" => SubscriptionLevel::None, _ => SubscriptionLevel::Unknown, }) } @@ -63,12 +63,12 @@ impl FromStr for SubscriptionLevel { impl std::fmt::Display for SubscriptionLevel { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(match self { - SubscriptionLevel::None => "", - SubscriptionLevel::Unknown => "unknown", - SubscriptionLevel::Community => "c", - SubscriptionLevel::Basic => "b", - SubscriptionLevel::Standard => "s", - SubscriptionLevel::Premium => "p", + SubscriptionLevel::None => "None", + SubscriptionLevel::Unknown => "Unknown", + SubscriptionLevel::Community => "Community", + SubscriptionLevel::Basic => "Basic", + SubscriptionLevel::Standard => "Standard", + SubscriptionLevel::Premium => "Premium", }) } } diff --git a/ui/src/dashboard/subscriptions_list.rs b/ui/src/dashboard/subscriptions_list.rs index b0a96eb..fdb9e9e 100644 --- a/ui/src/dashboard/subscriptions_list.rs +++ b/ui/src/dashboard/subscriptions_list.rs @@ -204,17 +204,6 @@ fn columns( .with_child(Container::from_tag("span").with_child(text)) } - fn render_subscription_level(level: SubscriptionLevel) -> &'static str { - match level { - SubscriptionLevel::None => "None", - SubscriptionLevel::Basic => "Basic", - SubscriptionLevel::Community => "Community", - SubscriptionLevel::Premium => "Premium", - SubscriptionLevel::Standard => "Standard", - SubscriptionLevel::Unknown => "Unknown", - } - } - let subscription_column = DataTableColumn::new(tr!("Subscription")) .render(|entry: &SubscriptionTreeEntry| match entry { SubscriptionTreeEntry::Node(node) => { @@ -222,16 +211,13 @@ fn columns( let (sub_state, text) = match node.level { SubscriptionLevel::None => (RemoteSubscriptionState::None, None), SubscriptionLevel::Unknown => (RemoteSubscriptionState::Unknown, None), - other => ( - RemoteSubscriptionState::Active, - Some(render_subscription_level(other)), - ), + other => (RemoteSubscriptionState::Active, Some(other.to_string())), }; render_subscription_state(&sub_state) .with_optional_child(text) .into() } else { - render_subscription_level(node.level).into() + node.level.to_string().into() } } SubscriptionTreeEntry::Remote(remote) => { -- 2.47.3