kthcloud / console

kthcloud web console
https://cloud.cbh.kth.se
MIT License
3 stars 3 forks source link

Add copy user ID button to profile, closes #281 #286

Closed Phillezi closed 1 month ago

Phillezi commented 1 month ago

Hi!

I added a button to copy user ID in the profile page, like described in #281 It adds a snackbar entry message if it succeeds or fails.

For example if user is null it will say: image

or if

navigator.clipboard.writeText(user.id);

throws an error, it will show this message (error message is the message of the error thrown): Screenshot from 2024-05-22 01-11-51

Here's how it looks (in glorious GIF quality):

English

Screencast-from-2024-05-22-00-42-24

Swedish

Screencast-from-2024-05-22-00-42-40

Lmk if I should change anything :)

pierrelefevre commented 1 month ago

Nice! We do have a copy button component but since this is a bit isolated it should be fine :)

Phillezi commented 1 month ago

Nice! We do have a copy button component but since this is a bit isolated it should be fine :)

Oh, I saw it now, should i change to use that component instead?

pierrelefevre commented 1 month ago

If you want to, sure! Would be a bit cleaner code 🚀

Phillezi commented 1 month ago

Hi again!

I changed it now so that it uses the existing CopyButton component, I modified the CopyButton component so that it can be used with text intput (next to the icon) with the optional parameter textContent (it will only show if the variant is specified to not be icon too).

I also added that check-mark that I had before to this component, so it changes for 2s after you click it to show a check mark instead of the copy icon.

Heres how it looks:

Screencast-from-2024-05-22-12-40-27

On the existing copy ssh key Screencast-from-2024-05-22-12-40-44

pierrelefevre commented 1 month ago

Nice! Love the check mark in the existing places too 👍🏻 Thanks for the PR