Skip to content
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

Merged
merged 1 commit into from May 9, 2023
Merged

Conversation

Zlendy
Copy link
Contributor

@Zlendy Zlendy commented Apr 26, 2023

This pull request implements #447.

@Zlendy Zlendy requested a review from a team as a code owner April 26, 2023 21:09
const copyToClipboard = async (text: string) => {
try {
await navigator.clipboard.writeText(text);
console.info("Copied to clipboard:", text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the notifications, Instead of using cosole.info and console.error I suggest you to make use of SnackReporter to make it look like the example below:
image

Copy link
Contributor Author

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!

Copy link
Member

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);

Copy link
Contributor Author

@Zlendy Zlendy Apr 28, 2023

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.

@Zlendy
Copy link
Contributor Author

Zlendy commented Apr 29, 2023

Okay. I added a Copy to Clipboard button to "Applications" and "Plugins" too.

image
image

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.

@Zlendy
Copy link
Contributor Author

Zlendy commented Apr 30, 2023

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.

Copy link
Contributor

@mateuscelio mateuscelio left a 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.

ui/src/application/Applications.tsx Outdated Show resolved Hide resolved
ui/src/snack/SnackManager.ts Outdated Show resolved Hide resolved
@Zlendy Zlendy requested a review from mateuscelio May 9, 2023 18:13
Copy link
Member

@jmattheis jmattheis left a 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.

@jmattheis jmattheis merged commit 62a1c99 into gotify:master May 9, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants