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 CSV support for the asset export, issue #5483 #5527

Closed
wants to merge 2 commits into from

Conversation

JahnabDutta
Copy link
Contributor

WHAT

Fixes the issue of not being able to export csv files. The main issue was that there was no parser which could convert the json string from the response body to a suitable format for csv. So, I add a function that parses the json data to csv format.

Proposed Changes

  • Fixes Add CSV support for the asset import/export #5483
  • Changed default dowload type to CSV. src/Components/Assets/AssetsList.tsx line 326.
  • Added function to flatten response body for csv conversion. src/Common/hooks/useExport.tsx line 11 to 43 (interface) and line 61 to 94 (function)
  • Added a parser function to parse the flattened json object. src/Components/useExport.tsx line 98 to 106.

demonstration

@coronasafe/care-fe-code-reviewers @coronasafe/code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

HOW

  • The function flattenObject in src/Common/hooks/useExport.tsx line 61 flattens the response body json data to a flat json.
  • Next, the function parseJSONtoCSV in src/Components/useExport.tsx line 98 parses the given json object and convertes it to a comma separated string.
  • We use parseJSONtoCSV as the default parser for exportFile function src/Components/useExport.tsx 151.

@JahnabDutta JahnabDutta requested a review from a team May 25, 2023 13:32
@JahnabDutta JahnabDutta requested a review from a team as a code owner May 25, 2023 13:32
@JahnabDutta JahnabDutta requested a review from gigincg May 25, 2023 13:32
@vercel
Copy link

vercel bot commented May 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
care-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 25, 2023 1:33pm

@netlify
Copy link

netlify bot commented May 25, 2023

Deploy Preview for care-egov-staging ready!

Name Link
🔨 Latest commit d13d87d
🔍 Latest deploy log https://app.netlify.com/sites/care-egov-staging/deploys/646f637138d57f00088c4d3f
😎 Deploy Preview https://deploy-preview-5527--care-egov-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@sonarcloud
Copy link

sonarcloud bot commented May 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

  1. This totally breaks other export functionalities in the platform as you are overriding the parse method and make it work only for assets.
  2. useExport is a generalized hook used in multiple places across the platform with different contexts. Avoid modifying it unless the intended behaviour of useExport is to be changed.
  3. Issue says to "Add CSV support". "Remove JSON support" was not mentioned anywhere.

@JahnabDutta also feel free close this PR and take up other good first issues as I didn't see @patelaryan7751 was already assigned to this. My bad.

@JahnabDutta
Copy link
Contributor Author

I see the issue with my code. Thanks. I'll check out other issues from the repo.

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.

Add CSV support for the asset import/export
3 participants