From: Shannon Sterz <s.sterz@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH yew-comp 2/3] auth_view: enable editing of default realms
Date: Thu, 18 Jun 2026 12:21:25 +0200 [thread overview]
Message-ID: <20260618102126.177217-3-s.sterz@proxmox.com> (raw)
In-Reply-To: <20260618102126.177217-1-s.sterz@proxmox.com>
so users can set custom comments and mark them as default realm if
required.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
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;
use proxmox_client::ApiResponseData;
-use pwt::widget::form::{Checkbox, FormContext, TristateBoolean};
+use pwt::widget::form::{Checkbox, DisplayField, Field, FormContext, TristateBoolean};
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, Toolbar};
use pwt_macros::builder;
+use crate::form::delete_empty_values;
use crate::{
AuthEditLDAP, AuthEditOpenID, EditWindow, LoadableComponent, LoadableComponentContext,
LoadableComponentMaster, LoadableComponentScope, LoadableComponentScopeExt,
@@ -37,6 +38,12 @@ pub struct AuthView {
/// The base url for
pub base_url: AttrValue,
+ /// 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()))]
+ #[builder(IntoPropValue, into_prop_value)]
+ pub edit_default_realms_base_url: Option<AttrValue>,
+
/// 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),
}
@@ -164,6 +172,33 @@ async fn load_realm(url: impl Into<String>) -> Result<ApiResponseData<Value>, Er
Ok(response)
}
+fn edit_default_realm(realm: AttrValue, url: AttrValue) -> EditWindow {
+ let url = format!("{url}/{realm}");
+ 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::new().name("default"))
+ .with_large_field(tr!("Comment"), Field::new().name("comment"))
+ .into()
+ }
+ })
+ .on_submit(move |form_ctx: FormContext| {
+ let url = url.clone();
+ async move {
+ let data = form_ctx.get_submit_data();
+ let data = delete_empty_values(&data, &["comment"], true);
+ crate::http_put(&url, Some(data)).await
+ }
+ })
+}
+
impl ProxmoxAuthView {
fn get_selected_record(&self) -> Option<BasicRealmInfo> {
let selected_key = self.selection.selected_key();
@@ -254,6 +289,11 @@ impl LoadableComponent for ProxmoxAuthView {
"ad" if props.ad_base_url.is_some() => {
Some(ViewState::EditAd(info.realm.into()))
}
+ "pam" | "pbs" | "pdm" | "pve"
+ if props.edit_default_realms_base_url.is_some() =>
+ {
+ Some(ViewState::EditDefaultRealm(info.realm.into()))
+ }
_ => return true,
};
@@ -285,7 +325,7 @@ impl LoadableComponent for ProxmoxAuthView {
if let Some(auth_info) = crate::utils::get_auth_domain_info(&realm_info.ty) {
sync_disabled = !auth_info.sync;
remove_disabled = !auth_info.add;
- edit_disabled = !auth_info.add;
+ edit_disabled = !auth_info.edit;
}
}
@@ -408,6 +448,14 @@ impl LoadableComponent for ProxmoxAuthView {
.on_close(ctx.link().change_view_callback(|_| None))
.into(),
),
+ ViewState::EditDefaultRealm(realm) => Some(
+ edit_default_realm(
+ realm.clone(),
+ props.edit_default_realms_base_url.clone().unwrap(),
+ )
+ .on_done(ctx.link().change_view_callback(|_| None))
+ .into(),
+ ),
ViewState::Sync(realm) => {
let link = ctx.link().clone();
let url = format!(
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index c007286..25fd414 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -172,7 +172,7 @@ pub fn get_auth_domain_info(ty: &str) -> Option<AuthDomainInfo> {
ty: ty.to_string(),
//description: tr!("Linux PAM"),
add: false,
- edit: false,
+ edit: true,
tfa: true,
pwchange: false,
sync: false,
@@ -184,7 +184,7 @@ pub fn get_auth_domain_info(ty: &str) -> Option<AuthDomainInfo> {
ty: ty.to_string(),
//description: tr!("Proxmox VE authentication server"),
add: false,
- edit: false,
+ edit: true,
tfa: true,
pwchange: true,
sync: false,
--
2.47.3
next prev parent reply other threads:[~2026-06-18 10:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 10:21 [PATCH datacenter-manager/yew-comp 0/3] Allow Editing of Default Realms in PDM Shannon Sterz
2026-06-18 10:21 ` [PATCH datacenter-manager 1/3] server: api: access: add endpoints for configuring pdm and pam realms Shannon Sterz
2026-06-18 10:21 ` Shannon Sterz [this message]
2026-06-18 10:21 ` [PATCH yew-comp 3/3] auth_view: clarify the documentation of pre-existing properties Shannon Sterz
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=20260618102126.177217-3-s.sterz@proxmox.com \
--to=s.sterz@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.