From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 4F0471FF0EA for ; Fri, 14 Aug 2026 15:45:53 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id BB4B0218F1; Fri, 14 Aug 2026 15:45:52 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 3/8] lib: api-types: add 'vmid' getter to ResourceView Date: Fri, 14 Aug 2026 15:43:59 +0200 Message-ID: <20260814134548.3446943-4-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260814134548.3446943-1-d.csapak@proxmox.com> References: <20260814134548.3446943-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.342 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 RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS 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: RUICZQG2ZV6XA6IZTLYE7FYFPXFVLUNU X-Message-ID-Hash: RUICZQG2ZV6XA6IZTLYE7FYFPXFVLUNU 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: This is useful for the UI to get the VMID independent of the guest type. Signed-off-by: Dominik Csapak --- lib/pdm-api-types/src/resource.rs | 18 ++++++++++++++++++ ui/src/lib.rs | 10 +++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs index 92d05cbc..18177dab 100644 --- a/lib/pdm-api-types/src/resource.rs +++ b/lib/pdm-api-types/src/resource.rs @@ -243,6 +243,24 @@ impl<'a> ResourceView<'a> { Some(node) } + /// Returns the VMID if the resource has one. Returns `None` for non guest resources. + pub fn vmid(&self) -> Option { + match self { + ResourceView::PveQemu(qemu) => Some(qemu.vmid), + ResourceView::PveLxc(lxc) => Some(lxc.vmid), + _ => None, + } + } + + /// Returns the guest type if the resource has one. Returns `None` for non guest resources. + pub fn guest_type(&self) -> Option { + match self { + ResourceView::PveQemu(_) => Some(GuestType::Qemu), + ResourceView::PveLxc(_) => Some(GuestType::Lxc), + _ => None, + } + } + pub fn resource_type(&self) -> ResourceType { match self { ResourceView::PveStorage(_) => ResourceType::PveStorage, diff --git a/ui/src/lib.rs b/ui/src/lib.rs index 6e89f044..d42ef42f 100644 --- a/ui/src/lib.rs +++ b/ui/src/lib.rs @@ -3,7 +3,7 @@ use gloo_utils::window; use js_sys::{Array, JsString, Object}; use pdm_api_types::remote_updates::RemoteUpdateSummary; use pdm_api_types::remotes::RemoteType; -use pdm_api_types::resource::{PveLxcResource, PveQemuResource}; +use pdm_api_types::resource::AsResourceView; use pdm_api_types::subscription::PdmSubscriptionInfo; use proxmox_deb_version::Version; use pwt::props::ContainerBuilder; @@ -190,11 +190,11 @@ pub(crate) fn navigate_to( if let Some(nav) = link.navigator() { let (prefix, id) = resource .and_then(|resource| { + if let Some(vmid) = resource.as_resource_view().vmid() { + return Some((true, format!("guest+{vmid}"))); + } + Some(match resource { - pdm_client::types::Resource::PveQemu(PveQemuResource { vmid, .. }) - | pdm_client::types::Resource::PveLxc(PveLxcResource { vmid, .. }) => { - (true, format!("guest+{vmid}")) - } pdm_client::types::Resource::PveNode(node) => { (true, format!("node+{}", node.node)) } -- 2.47.3