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 27E3C1FF165 for ; Thu, 23 Oct 2025 11:36:27 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EC7A34F62; Thu, 23 Oct 2025 11:36:53 +0200 (CEST) Message-ID: Date: Thu, 23 Oct 2025 11:36:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta To: Proxmox Datacenter Manager development discussion , Shannon Sterz References: <20251022131126.358790-1-s.sterz@proxmox.com> <20251022131126.358790-10-s.sterz@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <20251022131126.358790-10-s.sterz@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761212202080 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" 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 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