From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 956631FF179 for ; Wed, 12 Nov 2025 17:18:55 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BA59195C6; Wed, 12 Nov 2025 17:19:35 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Wed, 12 Nov 2025 17:11:48 +0100 Message-ID: <20251112161900.75032-14-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251112161900.75032-1-d.csapak@proxmox.com> References: <20251112161900.75032-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 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 datacenter-manager 13/18] ui: add view list context 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" This wraps SharedState so that we can trigger a reload of the views in 'main' from a component below without having to pass through a callback. Signed-off-by: Dominik Csapak --- ui/src/lib.rs | 3 +++ ui/src/view_list_context.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 ui/src/view_list_context.rs diff --git a/ui/src/lib.rs b/ui/src/lib.rs index bdf890a9..1ddb7f36 100644 --- a/ui/src/lib.rs +++ b/ui/src/lib.rs @@ -45,6 +45,9 @@ pub use load_result::LoadResult; mod tasks; pub use tasks::register_pve_tasks; +mod view_list_context; +pub use view_list_context::ViewListContext; + pub fn pdm_client() -> pdm_client::PdmClient> { pdm_client::PdmClient(proxmox_yew_comp::CLIENT.with(|c| std::rc::Rc::clone(&c.borrow()))) } diff --git a/ui/src/view_list_context.rs b/ui/src/view_list_context.rs new file mode 100644 index 00000000..c0e4a36e --- /dev/null +++ b/ui/src/view_list_context.rs @@ -0,0 +1,31 @@ +use pwt::state::{SharedState, SharedStateObserver}; +use yew::Callback; + +#[derive(PartialEq, Clone)] +/// Provides a context for updating and listening to changes of the list of views +pub struct ViewListContext { + state: SharedState, +} + +impl ViewListContext { + /// Create a new context + pub fn new() -> Self { + Self { + state: SharedState::new(0), + } + } + + /// Add a listener to the view list context + pub fn add_listener( + &self, + cb: impl Into>>, + ) -> SharedStateObserver { + self.state.add_listener(cb) + } + + /// Triggers an update of the view list for the main menu + pub fn update_views(&self) { + let mut state = self.state.write(); + **state = state.saturating_add(1); + } +} -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel