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 5ECC21FF15C for ; Fri, 17 Oct 2025 11:36:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D6B76249F3; Fri, 17 Oct 2025 11:36:28 +0200 (CEST) Date: Fri, 17 Oct 2025 11:35:54 +0200 Message-Id: Cc: "pdm-devel" From: "Lukas Wagner" To: "Proxmox Datacenter Manager development discussion" Mime-Version: 1.0 X-Mailer: aerc 0.20.1-0-g2ecb8770224a References: <20251014143709.413690-1-s.sterz@proxmox.com> <20251014143709.413690-2-s.sterz@proxmox.com> In-Reply-To: <20251014143709.413690-2-s.sterz@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760693751222 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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/2] utils/tfa add recover/token panel: add copy_text_to_clipboard function 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" The 'utils' module is getting quite large by now with many different kinds of helpers, maybe it is time to actually start splitting these out into distinct modules? For instance, in this patch series, you could create a new 'clipboard' module, moving *both* functions there and then adding a 'pub use' in 'utils' for the old, deprecated function for compatibility? Apart from this and the minor nit below, consider this: Tested-by: Lukas Wagner Reviewed-by: Lukas Wagner On Tue Oct 14, 2025 at 4:37 PM CEST, Shannon Sterz wrote: > diff --git a/src/utils.rs b/src/utils.rs > index 3dfc696..f4db098 100644 > --- a/src/utils.rs > +++ b/src/utils.rs > @@ -2,6 +2,7 @@ use std::collections::HashMap; > use std::fmt::Display; > use std::sync::Mutex; > > +use pwt::convert_js_error; > use serde_json::Value; > use wasm_bindgen::JsCast; > use yew::prelude::*; > @@ -338,6 +339,9 @@ pub fn json_array_to_flat_string(list: &[Value]) -> String { > list.join(" ") > } > > +#[deprecated( > + note = "This relies on the deprecated `execCommand` method. Please use `utils::copy_text_to_clipboard` instead." > +)] > pub fn copy_to_clipboard(node_ref: &NodeRef) { > if let Some(el) = node_ref.cast::() { > let window = gloo_utils::window(); > @@ -356,6 +360,24 @@ pub fn copy_to_clipboard(node_ref: &NodeRef) { > } > } > Missing doc comments for a `pub` function. > +pub fn copy_text_to_clipboard(text: &str) { > + let text = text.to_owned(); > + > + wasm_bindgen_futures::spawn_local(async move { > + let future: wasm_bindgen_futures::JsFuture = gloo_utils::window() > + .navigator() > + .clipboard() > + .write_text(&text) > + .into(); > + > + let res = future.await.map_err(convert_js_error); > + > + if let Err(e) = res { > + log::error!("could not copy to clipboard: {e:#}"); > + } > + }); > +} > + > /// Set the browser window.location.href > pub fn set_location_href(href: &str) { > let window = gloo_utils::window(); _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel