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 30E0A1FF165 for ; Thu, 23 Oct 2025 13:33:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A1CF58603; Thu, 23 Oct 2025 13:33:48 +0200 (CEST) Mime-Version: 1.0 Date: Thu, 23 Oct 2025 13:33:16 +0200 Message-Id: To: "Dominik Csapak" X-Mailer: aerc 0.20.0 References: <20251022131126.358790-1-s.sterz@proxmox.com> <20251022131126.358790-10-s.sterz@proxmox.com> In-Reply-To: From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761219187985 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.057 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 Subject: Re: [pdm-devel] [PATCH yew-comp v2 1/1] notes view: allow hiding the toolbar if editing isn't supported X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Cc: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" On Thu Oct 23, 2025 at 11:36 AM CEST, Dominik Csapak wrote: > 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 sure we can do that to, these last two patches were mainly inteded to show how the context can be used. can adapt this in a v2. > > On 10/22/25 3:11 PM, Shannon Sterz wrote: >> Signed-off-by: Shannon Sterz >> --- >> 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>, >> + >> + #[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) -> Option { >> 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) -> 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