public inbox for pdm-devel@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 v2 1/1] notes view: allow hiding the toolbar if editing isn't supported
Date: Thu, 23 Oct 2025 11:36:50 +0200	[thread overview]
Message-ID: <cb3c57c4-fbc3-47f2-8a74-1ab1106ac2a5@proxmox.com> (raw)
In-Reply-To: <20251022131126.358790-10-s.sterz@proxmox.com>

alternatively we could determine this from the 'on_submit' existence?
IMHO it does not make much sense if someone
sets the 'on_submit' call but disables editing, or vice versa

if there is some use case I can't see right now, consider this
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>

On 10/22/25 3:11 PM, Shannon Sterz wrote:
> Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
> ---
> alternatively we could also pass down the path and permissions for the
> the check and hook this component into the context itself. since we are
> talking about a single boolean check here, i though this approach
> provides less overhead and tried to keep it simple.
> 
>   src/notes_view.rs | 36 +++++++++++++++++++++++-------------
>   1 file changed, 23 insertions(+), 13 deletions(-)
> 
> diff --git a/src/notes_view.rs b/src/notes_view.rs
> index 315163e..9806d63 100644
> --- a/src/notes_view.rs
> +++ b/src/notes_view.rs
> @@ -6,6 +6,7 @@ use anyhow::Error;
>   use serde::{Deserialize, Serialize};
>   use serde_json::{json, Value};
> 
> +use yew::html::IntoPropValue;
>   use yew::virtual_dom::{VComp, VNode};
> 
>   use pwt::prelude::*;
> @@ -64,6 +65,10 @@ pub struct NotesView {
>       #[builder_cb(IntoSubmitCallback, into_submit_callback, NotesWithDigest)]
>       #[prop_or_default]
>       pub on_submit: Option<SubmitCallback<NotesWithDigest>>,
> +
> +    #[builder(IntoPropValue, into_prop_value)]
> +    #[prop_or(true)]
> +    pub allow_editing: bool,
>   }
> 
>   impl NotesView {
> @@ -163,20 +168,25 @@ impl LoadableComponent for ProxmoxNotesView {
>       }
>       fn toolbar(&self, ctx: &LoadableComponentContext<Self>) -> Option<Html> {
>           let props = ctx.props();
> -        let toolbar = Toolbar::new()
> -            .class("pwt-w-100")
> -            .class("pwt-overflow-hidden")
> -            .class("pwt-border-bottom")
> -            .with_child(
> -                Button::new(tr!("Edit"))
> -                    .disabled(props.on_submit.is_none())
> -                    .onclick(
> -                        ctx.link()
> -                            .change_view_callback(|_| Some(ViewState::EditNotes)),
> -                    ),
> -            );
> 
> -        Some(toolbar.into())
> +        if props.allow_editing {
> +            let toolbar = Toolbar::new()
> +                .class("pwt-w-100")
> +                .class("pwt-overflow-hidden")
> +                .class("pwt-border-bottom")
> +                .with_child(
> +                    Button::new(tr!("Edit"))
> +                        .disabled(props.on_submit.is_none())
> +                        .onclick(
> +                            ctx.link()
> +                                .change_view_callback(|_| Some(ViewState::EditNotes)),
> +                        ),
> +                );
> +
> +            return Some(toolbar.into());
> +        }
> +
> +        None
>       }
> 
>       fn main_view(&self, _ctx: &LoadableComponentContext<Self>) -> Html {
> --
> 2.47.3
> 
> 
> 
> _______________________________________________
> pdm-devel mailing list
> pdm-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
> 
> 



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


  reply	other threads:[~2025-10-23  9:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22 13:11 [pdm-devel] [PATCH datacenter-manager/proxmox/yew-comp v2 00/10] add support for checking acl permissions in (yew) front-ends Shannon Sterz
2025-10-22 13:11 ` [pdm-devel] [PATCH proxmox v2 1/4] access-control: add acl feature to only expose types and the AclTree Shannon Sterz
2025-10-23  9:24   ` Dominik Csapak
2025-10-23 11:32     ` Shannon Sterz
2025-10-22 13:11 ` [pdm-devel] [PATCH proxmox v2 2/4] access-control: move functions querying privileges to " Shannon Sterz
2025-10-22 13:11 ` [pdm-devel] [PATCH proxmox v2 3/4] access-control: derive Debug and PartialEq on AclTree and AclTreeNode Shannon Sterz
2025-10-22 13:11 ` [pdm-devel] [PATCH proxmox v2 4/4] access-control: allow reading all acls of the current authid Shannon Sterz
2025-10-23  9:31   ` Dominik Csapak
2025-10-23 11:32     ` Shannon Sterz
2025-10-22 13:11 ` [pdm-devel] [PATCH yew-comp v2 1/2] acl_context: add AclContext and AclContextProvider Shannon Sterz
2025-10-23 10:00   ` Dominik Csapak
2025-10-23 11:33     ` Shannon Sterz
2025-10-23 11:39       ` Dominik Csapak
2025-10-22 13:11 ` [pdm-devel] [PATCH yew-comp v2 2/2] http_helpers: reload LocalAclTree when logging in or refreshing a ticket Shannon Sterz
2025-10-22 13:11 ` [pdm-devel] [PATCH datacenter-manager v2 1/2] server/api-types: move AccessControlConfig to shared api types Shannon Sterz
2025-10-22 13:11 ` [pdm-devel] [PATCH datacenter-manager v2 2/2] ui: add an AclContext via the AclContextProvider to the main app ui Shannon Sterz
2025-10-22 13:11 ` [pdm-devel] [PATCH yew-comp v2 1/1] notes view: allow hiding the toolbar if editing isn't supported Shannon Sterz
2025-10-23  9:36   ` Dominik Csapak [this message]
2025-10-23 11:33     ` Shannon Sterz
2025-10-22 13:11 ` [pdm-devel] [PATCH datacenter-manager v2 1/1] ui: main menu: use the AclContext to hide the Notes if appropriate 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=cb3c57c4-fbc3-47f2-8a74-1ab1106ac2a5@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal