-
Notifications
You must be signed in to change notification settings - Fork 976
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
[Discover] feat: download CSV from discover page #9530
Conversation
Signed-off-by: Justin Kim <jungkm@amazon.com>
Signed-off-by: Justin Kim <jungkm@amazon.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9530 +/- ##
==========================================
+ Coverage 61.78% 61.82% +0.03%
==========================================
Files 3819 3825 +6
Lines 91937 92040 +103
Branches 14581 14599 +18
==========================================
+ Hits 56804 56902 +98
+ Misses 31469 31464 -5
- Partials 3664 3674 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/plugins/discover/public/application/view_components/utils/use_search.ts
Show resolved
Hide resolved
src/plugins/discover/public/application/components/download_csv/constants.ts
Show resolved
Hide resolved
src/plugins/discover/public/application/components/results_action_bar/results_action_bar.tsx
Show resolved
Hide resolved
src/plugins/discover/public/application/components/download_csv/use_download_csv.ts
Show resolved
Hide resolved
src/plugins/discover/public/application/components/download_csv/use_download_csv.ts
Show resolved
Hide resolved
src/plugins/discover/public/application/components/download_csv/download_csv.tsx
Outdated
Show resolved
Hide resolved
src/plugins/discover/public/application/components/download_csv/download_csv_callout.tsx
Outdated
Show resolved
Hide resolved
|
||
export const saveDataAsCsv = (csvData: string) => { | ||
const blob = new Blob([csvData], { type: 'text/csv;charset=utf-8' }); | ||
const fileName = `opensearch_export_${moment().format('YYYY-MM-DD')}`; |
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.
I think you are talking about the formatting of the filename? I'm a bit reluctant on that, but open for debate. But here's my rationale:
Because we are saving this to a file, we have to respect the allowed characters that a filename can have. So things like /
and such are not possible. So if we want to respect the user configured date format, I feel like we have to consider all these exceptions, and I didn't want to deal with it. Especially since its just a file name and they can rename it as they choose.
But open to suggestions!
if you were talking about something else, let me know!
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.
I see the quoteValues
and separator
setting being read from L100-L101
const csvData = unparse(
{ fields: displayedColumnNames, data: csvRowData },
{
quotes: uiSettings.get('csv:quoteValues', true),
delimiter: uiSettings.get('csv:separator', ','),
header: true,
}
);
Nice feature! Just one small comment: I see in the download_csv folders have a lot of files and it seems like some files like <download_csv_button.tsx> and <download_csv_callout.tsx> are fairly simple single component file without any extra logics, imo is it worth it to combine some of them to increase some readability and faster navigation? |
@abbyhu2000 hey! this is a contentious topic, but love to open up the debate. You are right,
I would argue that these should be separate for the following reason:
Due to the above, I would personally vote that we split it up where we can without over doing it. Of course it can be argued that I might be over doing it here, and it is up for debate, but for the above reasons I think keeping them separate makes more sense |
…h variable Signed-off-by: Justin Kim <jungkm@amazon.com>
Signed-off-by: Justin Kim <jungkm@amazon.com>
Signed-off-by: Justin Kim <jungkm@amazon.com>
Signed-off-by: Justin Kim <jungkm@amazon.com>
Signed-off-by: Justin Kim <jungkm@amazon.com>
Signed-off-by: Justin Kim <jungkm@amazon.com>
This reverts commit a4ab358.
Signed-off-by: Justin Kim <jungkm@amazon.com>
Description
Screenshot
downloadcsv.mp4
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration