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 281BC1FF137 for ; Tue, 31 Mar 2026 11:57:26 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7C8A8171DC; Tue, 31 Mar 2026 11:57:51 +0200 (CEST) From: Shan Shaji To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 2/3] ui: acl: list granular level permission paths for views Date: Tue, 31 Mar 2026 11:57:29 +0200 Message-ID: <20260331095730.75329-3-s.shaji@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260331095730.75329-1-s.shaji@proxmox.com> References: <20260331095730.75329-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: 1774951012419 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.135 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: ORU5F5WQ4RA5RHZQYY3F6NWX3RNODGPP X-Message-ID-Hash: ORU5F5WQ4RA5RHZQYY3F6NWX3RNODGPP 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 | 66 +++++++++++++++---- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/ui/src/configuration/permission_path_selector.rs b/ui/src/configuration/permission_path_selector.rs index 59bdabb..91d8072 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,68 @@ 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 + fn create(ctx: &Context) -> Self { + let base_items: Vec = PREDEFINED_PATHS + .iter() + .map(|i| AttrValue::from(*i)) + .collect(); + + let link = ctx.link().clone(); + let async_pool = AsyncPool::new(); + 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), + } + }); + Self { - items: Rc::new( - PREDEFINED_PATHS - .iter() - .map(|i| AttrValue::from(*i)) - .collect(), - ), + items: Rc::new(base_items), + _async_pool: async_pool, } } - 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 items = Rc::make_mut(&mut self.items); + items.extend(paths.into_iter().map(AttrValue::from)); + items.sort_by_key(|k| k.to_lowercase()); + true + } + Msg::PrefetchFailed => false, + } } fn view(&self, ctx: &Context) -> Html { -- 2.47.3