all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager 5/8] ui: renderer: use ResourceView for rendering
Date: Fri, 14 Aug 2026 15:44:01 +0200	[thread overview]
Message-ID: <20260814134548.3446943-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260814134548.3446943-1-d.csapak@proxmox.com>

A `Resource` can be converted to the `ResourceView` and the data
returned is identical, so there is no need to change any current caller,
but it's now possible to call it with a `PveResource` too.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/renderer.rs | 52 +++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/ui/src/renderer.rs b/ui/src/renderer.rs
index be3a94b4..0eecc889 100644
--- a/ui/src/renderer.rs
+++ b/ui/src/renderer.rs
@@ -6,43 +6,43 @@ use pwt::widget::{Column, Container, Fa, Row};
 
 use proxmox_human_byte::HumanByte;
 
-use pdm_client::types::Resource;
+use pdm_api_types::resource::{AsResourceView, ResourceView};
 
 use crate::pve;
 
-pub fn render_resource_name(resource: &Resource, vmid_first: bool) -> String {
-    match resource {
-        Resource::PveStorage(storage) => storage.storage.clone(),
-        Resource::PveQemu(qemu) => pve::utils::render_qemu_name(qemu, vmid_first),
-        Resource::PveLxc(lxc) => pve::utils::render_lxc_name(lxc, vmid_first),
-        Resource::PveNode(node) => node.node.clone(),
-        Resource::PveNetwork(network) => network.name().to_string(),
-        Resource::PbsNode(node) => node.name.clone(),
-        Resource::PbsDatastore(store) => store.name.clone(),
+pub fn render_resource_name(resource: impl AsResourceView, vmid_first: bool) -> String {
+    match resource.as_resource_view() {
+        ResourceView::PveStorage(storage) => storage.storage.clone(),
+        ResourceView::PveQemu(qemu) => pve::utils::render_qemu_name(qemu, vmid_first),
+        ResourceView::PveLxc(lxc) => pve::utils::render_lxc_name(lxc, vmid_first),
+        ResourceView::PveNode(node) => node.node.clone(),
+        ResourceView::PveNetwork(network) => network.name().to_string(),
+        ResourceView::PbsNode(node) => node.name.clone(),
+        ResourceView::PbsDatastore(store) => store.name.clone(),
     }
 }
 
-pub fn render_resource_icon(resource: &Resource) -> Fa {
-    let class = match resource {
-        Resource::PveStorage(_) => "database",
-        Resource::PveQemu(_) => "desktop",
-        Resource::PveLxc(_) => "cube",
-        Resource::PveNode(_) => "building",
-        Resource::PveNetwork(_) => "fa-sdn",
-        Resource::PbsNode(_) => "building-o",
-        Resource::PbsDatastore(_) => "floppy-o",
+pub fn render_resource_icon(resource: impl AsResourceView) -> Fa {
+    let class = match resource.as_resource_view() {
+        ResourceView::PveStorage(_) => "database",
+        ResourceView::PveQemu(_) => "desktop",
+        ResourceView::PveLxc(_) => "cube",
+        ResourceView::PveNode(_) => "building",
+        ResourceView::PveNetwork(_) => "fa-sdn",
+        ResourceView::PbsNode(_) => "building-o",
+        ResourceView::PbsDatastore(_) => "floppy-o",
     };
 
     Fa::new(class)
 }
 
-pub fn render_status_icon(resource: &Resource) -> Container {
-    match resource {
-        Resource::PveStorage(store) => pve::utils::render_storage_status_icon(store),
-        Resource::PveQemu(qemu) => pve::utils::render_qemu_status_icon(qemu),
-        Resource::PveLxc(lxc) => pve::utils::render_lxc_status_icon(lxc),
-        Resource::PveNode(node) => pve::utils::render_node_status_icon(node),
-        Resource::PveNetwork(network) => pve::utils::render_sdn_status_icon(network),
+pub fn render_status_icon(resource: impl AsResourceView) -> Container {
+    match resource.as_resource_view() {
+        ResourceView::PveStorage(store) => pve::utils::render_storage_status_icon(store),
+        ResourceView::PveQemu(qemu) => pve::utils::render_qemu_status_icon(qemu),
+        ResourceView::PveLxc(lxc) => pve::utils::render_lxc_status_icon(lxc),
+        ResourceView::PveNode(node) => pve::utils::render_node_status_icon(node),
+        ResourceView::PveNetwork(network) => pve::utils::render_sdn_status_icon(network),
         // FIXME: implement remaining types
         _ => Container::new().with_child(render_resource_icon(resource)),
     }
-- 
2.47.3





  parent reply	other threads:[~2026-08-14 13:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 13:43 [PATCH datacenter-manager 0/8] refactor and partially fix #7371 Dominik Csapak
2026-08-14 13:43 ` [PATCH datacenter-manager 1/8] lib: add new ResourceView type and move accessors there Dominik Csapak
2026-08-14 13:43 ` [PATCH datacenter-manager 2/8] lib: api types: resource: add 'node' helper to ResourceView Dominik Csapak
2026-08-14 13:43 ` [PATCH datacenter-manager 3/8] lib: api-types: add 'vmid' getter " Dominik Csapak
2026-08-14 13:44 ` [PATCH datacenter-manager 4/8] ui: pve: factor out the pve-manager version extraction Dominik Csapak
2026-08-14 13:44 ` Dominik Csapak [this message]
2026-08-14 13:44 ` [PATCH datacenter-manager 6/8] ui: pve: tree: reuse `PveResource` for `PveTreeNode` Dominik Csapak
2026-08-14 13:44 ` [PATCH datacenter-manager 7/8] ui: pve: show ha maintenance mode for nodes Dominik Csapak
2026-08-14 13:44 ` [PATCH datacenter-manager 8/8] ui: pve: node selector: show maintenance badge with node name Dominik Csapak

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=20260814134548.3446943-6-d.csapak@proxmox.com \
    --to=d.csapak@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal