New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add copy app token button in web gui #561
Conversation
ui/src/client/Clients.tsx
Outdated
const copyToClipboard = async (text: string) => { | ||
try { | ||
await navigator.clipboard.writeText(text); | ||
console.info("Copied to clipboard:", text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip! I'm trying to add an additional action to ClientStore to implement it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can directly inject the SnackManager into the Clients component by adding it to the inject function:
export default inject('clientStore', 'snackManager')(Clients);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to do it that way? I have already implemented it with an import.
Okay. I added a Copy to Clipboard button to "Applications" and "Plugins" too. I have personally tested the button and it works in "Clients" and "Applications". I tried to install a plugin to test it there too but unfortunately I was not able to do it. This PR is still not ready to be merged due to e2e tests on "Applications" and "Plugins" failing. |
Hi. I finally realized the embarrassing thing that was making the test fail. All tests are passing now and the button is working as it should. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zlendy I left some comments. To summarize, I think that a better implementation would be create a component for the copy button and inject snack manager into it. This way, it wouldn't be necessary to change SnackManager and component's stores. To help, I created a PR into your fork. Let me know If you have more questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've moved the method into the ToggleVisibility component and renamed it to CopyableSecret. It fits there pretty well, because you normally want to copy all secrets, and it also requires fewer changes inside the codebase.
This pull request implements #447.