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

ui: glimmerize download button component #18292

Merged
merged 8 commits into from
Dec 9, 2022

Conversation

hellobontempo
Copy link
Contributor

@hellobontempo hellobontempo commented Dec 9, 2022

Glimmerizes the DownloadButton component and removes ToolbarDownloadButton

This PR also removes checking for window.navigator.msSaveOrOpenBlob added by #4376 because IE and Edge didn't like the File constructor. Edge added support for File API in 2020 so we no longer need this conditional! 🎉

(P.s. we no longer support IE)


class sample button
class="toolbar-link" Screen Shot 2022-12-09 at 2 34 15 PM
class="button is-ghost" Screen Sh1552022-12-09 at 2 35 16 PM

Copy link
Contributor

@zofskeez zofskeez left a comment

Choose a reason for hiding this comment

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

Nice work thanks for this! ✨ I left a few comments for consideration but nothing blocking.

ui/lib/core/addon/components/download-button.hbs Outdated Show resolved Hide resolved
extension: 'txt',
stringify: false,
});
// TODO refactor and call service instead
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this be the DownloadCsvService?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep! Chelsea is refactoring the service now to be more general. I'll then update this action to use the service when I use this component to implement downloading a generated PKI key

Comment on lines 56 to 66
@action
handleDownload() {
const { document, URL } = window;
const downloadElement = document.createElement('a');
downloadElement.download = this.filename;
downloadElement.href = URL.createObjectURL(this.content);
document.body.appendChild(downloadElement);
downloadElement.click();
URL.revokeObjectURL(downloadElement.href);
downloadElement.remove();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Quite a bit of code was refactored in this component beyond glimmerizing but it looks more straightforward and I pulled down the branch and downloads work as expected so it looks good to me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for testing locally! 🎉

@zofskeez
Copy link
Contributor

zofskeez commented Dec 9, 2022

One follow up, it might be nice to have some test coverage for this component.

@hellobontempo hellobontempo enabled auto-merge (squash) December 9, 2022 23:07
@hellobontempo hellobontempo merged commit cff1918 into main Dec 9, 2022
@hellobontempo
Copy link
Contributor Author

One follow up, it might be nice to have some test coverage for this component.

Yes! I started writing tests and then decided to wait until utilizing the service. If the service doesn't have enough test coverage then I'll fill that out.

@hellobontempo hellobontempo deleted the ui/glimmerize-download-button branch December 9, 2022 23:26
AnPucel pushed a commit that referenced this pull request Jan 14, 2023
* initial glimmerization, delete toolbar-download-button component

* remove extra line

* cleanup component file

* add data getter

* delete toolbar download button component

* add jsdoc to component

* move class att directly to component, remove arg

* remove content getter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants