public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager v3 01/12] api types: subscription level: render full names
Date: Fri, 15 May 2026 09:43:11 +0200	[thread overview]
Message-ID: <20260515074623.766766-2-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20260515074623.766766-1-t.lamprecht@proxmox.com>

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
Display caller, the dashboard helper, is dropped alongside the
change. 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.

Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---

No changes since v2 (besides picking up Lukas R-b)

 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 ca23b8e5..f0eb525b 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<Self, Self::Err> {
         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 b0a96eb6..fdb9e9e1 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





  reply	other threads:[~2026-05-15  7:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15  7:43 [PATCH datacenter-manager v3 00/12] subscription key pool registry Thomas Lamprecht
2026-05-15  7:43 ` Thomas Lamprecht [this message]
2026-05-15  7:43 ` [PATCH datacenter-manager v3 02/12] pdm-client: add wait_for_local_task helper Thomas Lamprecht
2026-05-15 15:21   ` Wolfgang Bumiller
2026-05-15  7:43 ` [PATCH datacenter-manager v3 03/12] subscription: pool: add data model and config layer Thomas Lamprecht
2026-05-15 15:21   ` Wolfgang Bumiller
2026-05-15  7:43 ` [PATCH datacenter-manager v3 04/12] subscription: api: add key pool and node status endpoints Thomas Lamprecht
2026-05-15 15:21   ` Wolfgang Bumiller
2026-05-15  7:43 ` [PATCH datacenter-manager v3 05/12] ui: registry: add view with key pool and node status Thomas Lamprecht
2026-05-15  7:43 ` [PATCH datacenter-manager v3 06/12] cli: client: add subscription key pool management subcommands Thomas Lamprecht
2026-05-15  7:43 ` [PATCH datacenter-manager v3 07/12] docs: add subscription registry chapter Thomas Lamprecht
2026-05-15  7:43 ` [PATCH datacenter-manager v3 08/12] subscription: add Clear Key action and per-node revert Thomas Lamprecht
2026-05-15  7:43 ` [PATCH datacenter-manager v3 09/12] subscription: add Adopt Key action for foreign live subscriptions Thomas Lamprecht
2026-05-15  7:43 ` [PATCH datacenter-manager v3 10/12] subscription: add Adopt All bulk action Thomas Lamprecht
2026-05-15  7:43 ` [PATCH datacenter-manager v3 11/12] subscription: add Check Subscription action Thomas Lamprecht
2026-05-15  7:43 ` [RFC PATCH datacenter-manager v3 12/12] ui: registry: add Add-and-Assign wizard from Assign Key dialog Thomas Lamprecht

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=20260515074623.766766-2-t.lamprecht@proxmox.com \
    --to=t.lamprecht@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