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 431B81FF15C for ; Fri, 17 Oct 2025 12:43:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 23B7226605; Fri, 17 Oct 2025 12:43:45 +0200 (CEST) Mime-Version: 1.0 Date: Fri, 17 Oct 2025 12:43:09 +0200 Message-Id: To: "Lukas Wagner" X-Mailer: aerc 0.20.0 References: <20251014143709.413690-1-s.sterz@proxmox.com> <20251014143709.413690-2-s.sterz@proxmox.com> In-Reply-To: From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760697786012 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 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [utils.rs, proxmox.com] 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 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 Fri Oct 17, 2025 at 11:35 AM CEST, Lukas Wagner wrote: > 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? not opposed to that, but we might want to think about how to do that a bit more in-depth. not sure how we want to split those up exactly. might be better handled as a separate clean-up series for yew-comp? > 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. > ah true, should be /// Copies `text` to the user's clipboard via the `Clipboard` API. >> +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 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel