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 929C51FF13B for ; Wed, 25 Mar 2026 16:36:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 157A51F12C; Wed, 25 Mar 2026 16:36:38 +0100 (CET) From: Shan Shaji To: pdm-devel@lists.proxmox.com Subject: [RFC PATCH datacenter-manager 2/3] ui: acl: list granular level permission paths for views Date: Wed, 25 Mar 2026 16:35:34 +0100 Message-ID: <20260325153535.286380-3-s.shaji@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260325153535.286380-1-s.shaji@proxmox.com> References: <20260325153535.286380-1-s.shaji@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774452916424 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.125 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: KJG7LNWCSCEQJ6B7Q3RM2GBG3ZHLEKAW X-Message-ID-Hash: KJG7LNWCSCEQJ6B7Q3RM2GBG3ZHLEKAW X-MailFrom: s.shaji@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: Previously, users were unable to assign permissions to individual views. Resolved this by loading the views list and extending permission paths to include specific view routes. Signed-off-by: Shan Shaji --- .../configuration/permission_path_selector.rs | 80 +++++++++++++++---- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/ui/src/configuration/permission_path_selector.rs b/ui/src/configuration/permission_path_selector.rs index 59bdabb..a0fec86 100644 --- a/ui/src/configuration/permission_path_selector.rs +++ b/ui/src/configuration/permission_path_selector.rs @@ -1,12 +1,15 @@ use std::rc::Rc; +use anyhow::Error; use yew::html::IntoPropValue; -use pwt::prelude::*; use pwt::widget::form::Combobox; +use pwt::{prelude::*, AsyncPool}; use pwt_macros::{builder, widget}; +use crate::pdm_client; + static PREDEFINED_PATHS: &[&str] = &[ "/", "/access", @@ -44,33 +47,78 @@ impl PermissionPathSelector { } } -enum Msg {} +enum Msg { + Prefetched(Vec), + PrefetchFailed, +} struct PdmPermissionPathSelector { items: Rc>, + async_pool: AsyncPool, } -impl PdmPermissionPathSelector {} +impl PdmPermissionPathSelector { + async fn get_view_paths() -> Result, Error> { + let views = pdm_client().list_views().await?; + let paths: Vec = views + .iter() + .map(|cfg| format!("/view/{}", cfg.id)) + .collect(); + Ok(paths) + } + + async fn get_paths() -> Result, Error> { + let paths = Self::get_view_paths().await?; + Ok(paths) + } +} impl Component for PdmPermissionPathSelector { type Message = Msg; type Properties = PermissionPathSelector; - fn create(_ctx: &Context) -> Self { - // TODO: fetch resources & remotes from the backend to improve the pre-defined selection of - // acl paths - Self { - items: Rc::new( - PREDEFINED_PATHS - .iter() - .map(|i| AttrValue::from(*i)) - .collect(), - ), - } + fn create(ctx: &Context) -> Self { + let base_items: Vec = PREDEFINED_PATHS + .iter() + .map(|i| AttrValue::from(*i)) + .collect(); + + let this = Self { + items: Rc::new(base_items), + async_pool: AsyncPool::new(), + }; + + let link = ctx.link().clone(); + this.async_pool.spawn(async move { + let paths = Self::get_paths().await; + match paths { + Ok(paths) => { + link.send_message(Msg::Prefetched(paths)); + } + Err(_) => { + link.send_message(Msg::PrefetchFailed); + } + } + }); + + this } - fn update(&mut self, _ctx: &Context, _msg: Self::Message) -> bool { - false + fn update(&mut self, _ctx: &Context, msg: Self::Message) -> bool { + match msg { + Msg::Prefetched(paths) => { + let mut items: Vec = Vec::with_capacity(self.items.len() + paths.len()); + + items.extend(self.items.iter().map(|item| item.to_string())); + items.extend(paths.into_iter()); + items.sort_by(|a, b| a.to_lowercase().cmp(&b.to_lowercase())); + + self.items = Rc::new(items.into_iter().map(AttrValue::from).collect()); + + true + } + Msg::PrefetchFailed => false, + } } fn view(&self, ctx: &Context) -> Html { -- 2.47.3