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 6E6BC1FF13A for ; Wed, 24 Jun 2026 16:27:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A094B19F24; Wed, 24 Jun 2026 16:27:42 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 24 Jun 2026 16:27:38 +0200 Message-Id: From: "Shan Shaji" To: "Shannon Sterz" , Subject: Re: [PATCH yew-comp 2/3] auth_view: enable editing of default realms X-Mailer: aerc 0.20.0 References: <20260618102126.177217-1-s.sterz@proxmox.com> <20260618102126.177217-3-s.sterz@proxmox.com> In-Reply-To: <20260618102126.177217-3-s.sterz@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1782311255225 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.147 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: 7QGBMPOELUXDOXTNERWVZNAAD7FGZ32N X-Message-ID-Hash: 7QGBMPOELUXDOXTNERWVZNAAD7FGZ32N 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: On Thu Jun 18, 2026 at 12:21 PM CEST, Shannon Sterz wrote: > so users can set custom comments and mark them as default realm if > required. > > Signed-off-by: Shannon Sterz > --- > src/auth_view.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++-- > src/utils/mod.rs | 4 ++-- > 2 files changed, 52 insertions(+), 4 deletions(-) > > diff --git a/src/auth_view.rs b/src/auth_view.rs > index 9a06979..8be682a 100644 > --- a/src/auth_view.rs > +++ b/src/auth_view.rs > @@ -5,7 +5,7 @@ use std::rc::Rc; > use anyhow::Error; > =20 > use proxmox_client::ApiResponseData; > -use pwt::widget::form::{Checkbox, FormContext, TristateBoolean}; > +use pwt::widget::form::{Checkbox, DisplayField, Field, FormContext, Tris= tateBoolean}; > use serde_json::Value; > use yew::html::IntoPropValue; > use yew::virtual_dom::{VComp, VNode}; > @@ -19,6 +19,7 @@ use pwt::widget::{Button, Container, Fa, InputPanel, To= olbar}; > =20 > use pwt_macros::builder; > =20 > +use crate::form::delete_empty_values; > use crate::{ > AuthEditLDAP, AuthEditOpenID, EditWindow, LoadableComponent, Loadabl= eComponentContext, > LoadableComponentMaster, LoadableComponentScope, LoadableComponentSc= opeExt, > @@ -37,6 +38,12 @@ pub struct AuthView { > /// The base url for > pub base_url: AttrValue, > =20 > + /// The base URL to edit the default realms (pam, pve, pdm, pbs etc.= ). Specify `None` if > + /// editing the default realms is not supported. > + #[prop_or(Some("/config/access/".into()))] small nit: Do we need the forward slash here at the end, since a forward slash is added later while creating the request url? > + #[builder(IntoPropValue, into_prop_value)] > + pub edit_default_realms_base_url: Option, > + > /// Allow to add/edit OpenID entries > #[builder(IntoPropValue, into_prop_value)] > #[prop_or_default] > @@ -73,6 +80,7 @@ pub enum ViewState { > EditOpenID(AttrValue), > EditLDAP(AttrValue), > EditAd(AttrValue), > + EditDefaultRealm(AttrValue), > Sync(BasicRealmInfo), > } > =20 > @@ -164,6 +172,33 @@ async fn load_realm(url: impl Into) -> Resul= t, Er > Ok(response) > } > =20 > +fn edit_default_realm(realm: AttrValue, url: AttrValue) -> EditWindow { > + let url =3D format!("{url}/{realm}"); I meant here.=20 > + EditWindow::new(tr!("Edit: {realm}", realm)) > + .loader(url.clone()) > + .renderer({ > + move |_form_ctx: &FormContext| { > + InputPanel::new() > + .padding(4) > + .with_field( > + tr!("Realm"), > + DisplayField::new().name("realm").submit(false), > + ) > + .with_right_field(tr!("Default Realm"), Checkbox::ne= w().name("default")) > + .with_large_field(tr!("Comment"), Field::new().name(= "comment")) > + .into() > + } > + }) > + .on_submit(move |form_ctx: FormContext| { > + let url =3D url.clone(); > + async move { > + let data =3D form_ctx.get_submit_data(); > + let data =3D delete_empty_values(&data, &["comment"], tr= ue); > + crate::http_put(&url, Some(data)).await > + } > + }) > +} > + > impl ProxmoxAuthView { > fn get_selected_record(&self) -> Option { > let selected_key =3D self.selection.selected_key(); > @@ -254,6 +289,11 @@ impl LoadableComponent for ProxmoxAuthView { > "ad" if props.ad_base_url.is_some() =3D> { > Some(ViewState::EditAd(info.realm.into())) > } > + "pam" | "pbs" | "pdm" | "pve" > + if props.edit_default_realms_base_url.is_some() = =3D> > + { > + Some(ViewState::EditDefaultRealm(info.realm.into= ())) > + } > _ =3D> return true, > }; > =20 > @@ -285,7 +325,7 @@ impl LoadableComponent for ProxmoxAuthView { > if let Some(auth_info) =3D crate::utils::get_auth_domain_inf= o(&realm_info.ty) { > sync_disabled =3D !auth_info.sync; > remove_disabled =3D !auth_info.add; > - edit_disabled =3D !auth_info.add; > + edit_disabled =3D !auth_info.edit; > } > } > =20 [...]