all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Lukas Wagner" <l.wagner@proxmox.com>
Cc: Proxmox Datacenter Manager development discussion
	<pdm-devel@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 12:43:09 +0200	[thread overview]
Message-ID: <DDKJ9Y4G3JEF.22VXQ9DXWFJEQ@proxmox.com> (raw)
In-Reply-To: <DDKHUGK6XDGD.RBRJBJQFAZY@proxmox.com>

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 <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.
>

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


  reply	other threads:[~2025-10-17 10:43 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
2025-10-17 10:43     ` Shannon Sterz [this message]
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=DDKJ9Y4G3JEF.22VXQ9DXWFJEQ@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=l.wagner@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal