From: "Lukas Wagner" <l.wagner@proxmox.com>
To: "Proxmox Datacenter Manager development discussion"
<pdm-devel@lists.proxmox.com>
Cc: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com>
Subject: Re: [pdm-devel] [PATCH yew-comp v2 1/2] utils/tfa add recover/token panel: add copy_text_to_clipboard function
Date: Fri, 17 Oct 2025 11:35:54 +0200 [thread overview]
Message-ID: <DDKHUGK6XDGD.RBRJBJQFAZY@proxmox.com> (raw)
In-Reply-To: <20251014143709.413690-2-s.sterz@proxmox.com>
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 <l.wagner@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
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::<web_sys::HtmlInputElement>() {
> 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
next prev parent reply other threads:[~2025-10-17 9:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 14:37 [pdm-devel] [PATCH datacenter-manager/yew-comp v2 0/5] add better token support for pdm Shannon Sterz
2025-10-14 14:37 ` [pdm-devel] [PATCH yew-comp v2 1/2] utils/tfa add recover/token panel: add copy_text_to_clipboard function Shannon Sterz
2025-10-17 9:35 ` Lukas Wagner [this message]
2025-10-17 10:43 ` Shannon Sterz
2025-10-14 14:37 ` [pdm-devel] [PATCH yew-comp v2 2/2] token panel: improve token secret dialog layout and hide password Shannon Sterz
2025-10-17 9:36 ` Lukas Wagner
2025-10-17 10:04 ` Shannon Sterz
2025-10-17 11:03 ` Lukas Wagner
2025-10-14 14:37 ` [pdm-devel] [PATCH datacenter-manager v2 1/3] ui: add a token panel and a token acl edit menu in the permissions panel Shannon Sterz
2025-10-17 9:36 ` Lukas Wagner
2025-10-14 14:37 ` [pdm-devel] [PATCH datacenter-manager v2 2/3] server: access: use token endpoints from proxmox-access-control Shannon Sterz
2025-10-17 9:36 ` Lukas Wagner
2025-10-14 14:37 ` [pdm-devel] [PATCH datacenter-manager v2 3/3] server: clean up acl tree entries and api tokens when deleting users Shannon Sterz
2025-10-17 9:36 ` Lukas Wagner
2025-10-17 12:48 ` [pdm-devel] Superseded: Re: [PATCH datacenter-manager/yew-comp v2 0/5] add better token support for pdm Shannon Sterz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DDKHUGK6XDGD.RBRJBJQFAZY@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pdm-devel-bounces@lists.proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox