Skip to content

feat(plugin-import-export): preview displays CSV and JSON data accurately #12948

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

PatrikKozak
Copy link
Contributor

@PatrikKozak PatrikKozak commented Jun 26, 2025

What

This PR updates the import-export plugin's <Preview /> component to render table columns and rows using the same logic as the CSV export.

Key changes:

  • Adds a new /api/preview-data custom REST endpoint that:
    • Accepts filters (fields, where, sort, draft, limit)
    • Uses getCustomFieldFunctions and flattenObject to transform documents
    • Returns deeply flattened rows identical to the CSV export
  • Refactors the component to:
    • POST preview config to the new endpoint instead of querying the collection directly
    • Match column ordering and flattening logic with the createExport function
  • Ensures consistency across CSV downloads and in-admin previews
    -Adds JSON preview

This ensures preview results now exactly match exported CSV content, including support for custom field transformers and polymorphic fields.

@PatrikKozak PatrikKozak changed the title fix(plugin-import-export): preview column rendering to match CSV export structure feat(plugin-import-export): preview column rendering to match CSV export structure Jun 26, 2025
Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

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

This needs to hit a new endpoint so that the table data can include changes from toCSV function calls.

@DanRibbens DanRibbens changed the title feat(plugin-import-export): preview column rendering to match CSV export structure feat(plugin-import-export): preview displays CSV and JSON data accurately Jun 26, 2025
@DanRibbens DanRibbens enabled auto-merge (squash) June 26, 2025 22:06
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