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 BBEA41FF183 for ; Wed, 22 Oct 2025 15:11:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 91E4F18915; Wed, 22 Oct 2025 15:11:33 +0200 (CEST) From: Shannon Sterz To: pdm-devel@lists.proxmox.com Date: Wed, 22 Oct 2025 15:11:25 +0200 Message-ID: <20251022131126.358790-10-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251022131126.358790-1-s.sterz@proxmox.com> References: <20251022131126.358790-1-s.sterz@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761138682219 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.056 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: [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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" 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