all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Proxmox Datacenter Manager development discussion
	<pdm-devel@lists.proxmox.com>,
	Shannon Sterz <s.sterz@proxmox.com>
Subject: Re: [pdm-devel] [PATCH yew-comp 1/1] user panel: add a parameter to set the current product's realm
Date: Fri, 16 Jan 2026 09:30:57 +0100	[thread overview]
Message-ID: <ee0a729a-afd8-49eb-acc5-3971f053c399@proxmox.com> (raw)
In-Reply-To: <20260112122420.228501-2-s.sterz@proxmox.com>

LGTM

Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>

On 1/12/26 1:24 PM, Shannon Sterz wrote:
> so that password and confirm password fields can be ommitted
> appropriatelly when adding users and the "change password" button is
> disabled appropriatelly.
> 
> Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
> ---
>   src/user_panel.rs | 33 ++++++++++++++++++++++++++-------
>   1 file changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/src/user_panel.rs b/src/user_panel.rs
> index c6d0b56..547fdfe 100644
> --- a/src/user_panel.rs
> +++ b/src/user_panel.rs
> @@ -4,7 +4,9 @@ use std::rc::Rc;
>   
>   use anyhow::Error;
>   use proxmox_client::ApiResponseData;
> +use pwt_macros::builder;
>   use serde_json::Value;
> +use yew::html::IntoPropValue;
>   
>   use proxmox_access_control::types::UserWithTokens;
>   use proxmox_auth_api::types::Username;
> @@ -89,7 +91,13 @@ async fn update_user(form_ctx: FormContext) -> Result<(), Error> {
>   }
>   
>   #[derive(PartialEq, Properties)]
> -pub struct UserPanel {}
> +#[builder]
> +pub struct UserPanel {
> +    /// The realm of the current product. For example: "pdm"
> +    #[builder(IntoPropValue, into_prop_value)]
> +    #[prop_or_default]
> +    product_realm: Option<AttrValue>,
> +}
>   
>   impl Default for UserPanel {
>       fn default() -> Self {
> @@ -99,7 +107,7 @@ impl Default for UserPanel {
>   
>   impl UserPanel {
>       pub fn new() -> Self {
> -        Self {}
> +        yew::props!(Self {})
>       }
>   }
>   
> @@ -119,6 +127,7 @@ pub struct ProxmoxUserPanel {
>       state: LoadableComponentState<ViewState>,
>       store: Store<UserWithTokens>,
>       selection: Selection,
> +    product_realm: Option<AttrValue>,
>   }
>   
>   pwt::impl_deref_mut_property!(ProxmoxUserPanel, state, LoadableComponentState<ViewState>);
> @@ -154,6 +163,7 @@ impl LoadableComponent for ProxmoxUserPanel {
>               state: LoadableComponentState::new(),
>               store,
>               selection,
> +            product_realm: ctx.props().product_realm.clone(),
>           }
>       }
>   
> @@ -180,7 +190,11 @@ impl LoadableComponent for ProxmoxUserPanel {
>           let no_selection = self.selection.is_empty();
>           let disable_change_password = self
>               .get_selected_user()
> -            .map(|user| user.user.userid.realm().as_str() == "pam")
> +            .and_then(|user| {
> +                self.product_realm
> +                    .as_ref()
> +                    .map(|p| p != user.user.userid.realm().as_str())
> +            })
>               .unwrap_or(no_selection);
>   
>           let toolbar = Toolbar::new()
> @@ -279,8 +293,9 @@ impl ProxmoxUserPanel {
>       }
>   
>       fn create_add_dialog(&self, ctx: &LoadableComponentContext<Self>) -> Html {
> +        let product_realm = self.product_realm.clone();
>           EditWindow::new(tr!("Add") + ": " + &tr!("User"))
> -            .renderer(add_user_input_panel)
> +            .renderer(move |form_ctx| add_user_input_panel(form_ctx, &product_realm))
>               .on_submit(create_user)
>               .on_done(ctx.link().change_view_callback(|_| None))
>               .on_change(check_confirm_password)
> @@ -484,8 +499,12 @@ fn password_change_input_panel(_form_ctx: &FormContext) -> Html {
>           .into()
>   }
>   
> -fn add_user_input_panel(form_ctx: &FormContext) -> Html {
> -    let is_pam = form_ctx.read().get_field_text("realm") == "pam";
> +fn add_user_input_panel(form_ctx: &FormContext, product_realm: &Option<AttrValue>) -> Html {
> +    let realm = form_ctx.read().get_field_text("realm");
> +    let is_product_realm = product_realm
> +        .as_deref()
> +        .map(|p| p == realm)
> +        .unwrap_or_default();
>   
>       let mut panel = InputPanel::new()
>           .padding(4)
> @@ -506,7 +525,7 @@ fn add_user_input_panel(form_ctx: &FormContext) -> Html {
>                   .submit(false),
>           );
>   
> -    if !is_pam {
> +    if is_product_realm {
>           panel = panel
>               .with_field(
>                   tr!("Password"),



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  reply	other threads:[~2026-01-16  8:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 12:24 [pdm-devel] [PATCH datacenter-manager/yew-comp 0/4] fix adding users manually for openid/ldap/ad realms Shannon Sterz
2026-01-12 12:24 ` [pdm-devel] [PATCH yew-comp 1/1] user panel: add a parameter to set the current product's realm Shannon Sterz
2026-01-16  8:30   ` Dominik Csapak [this message]
2026-01-16  9:01   ` [pdm-devel] applied: " Dietmar Maurer
2026-01-12 12:24 ` [pdm-devel] [PATCH datacenter-manager 1/3] fix #7182: server: auth: add dummy openid authenticator Shannon Sterz
2026-01-12 12:24 ` [pdm-devel] [PATCH datacenter-manager 2/3] ui: run cargo fmt Shannon Sterz
2026-01-12 12:24 ` [pdm-devel] [PATCH datacenter-manager 3/3] ui: set prodcut realm so that the add user dialogs are rendered properly Shannon Sterz
2026-01-14 12:35   ` 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=ee0a729a-afd8-49eb-acc5-3971f053c399@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    --cc=s.sterz@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal