Fix export column labels, redownloadable exports, and duplicate webp images - #628
Merged
Conversation
…edup CSV/JSON exports (Promises, AI Extraction Export Rows) showed raw field names as column headers (tenantName, politicalEntityName, ...) instead of the labels already configured on each field. Added an export `before` hook (src/lib/exportColumnLabels.ts) that relabels each row's keys using the field's admin label before the file is written. Saved exports also had no way to be re-downloaded: the plugin's Exports collection denies update access to everyone by design (exports are immutable once generated), so Payload never mounts the edit-view Save/Download button on a saved doc — not merely disabled, entirely absent once you navigate away and back. Added ExportDownloadButton in the unconditionally-rendered `beforeDocumentControls` slot to serve the already-generated file directly, and forked the plugin's create-time button (ExportSaveButton) so it only regenerates when there's no saved file yet. Finally, fixed duplicate Media docs being created for .webp/.gif/.avif images synced from Airtable. Payload always re-encodes those three mimetypes through sharp before persisting them, even with no resize options configured, so the dedup checksum computed from the raw downloaded bytes never matched what was actually stored. computeMediaChecksum now detects those formats by magic bytes and replicates Payload's re-encode step before hashing, so the pre-check and stored checksums are computed over the same bytes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
|
@codex Review |
Addresses PR review feedback suggesting the AVIF magic-byte check should also inspect the ISO-BMFF compatible-brands list, not just the major brand. Verified against file-type@21.3.4 (the exact library Payload uses internally to set `file.mimetype`) — it also switches on the major brand alone and never reads compatible brands, so this must match it exactly to correctly predict whether Payload will reencode a given upload. Checking compatible brands would make this detector more accurate than file-type itself and reintroduce the checksum mismatch this change fixes, for a file whose major brand is a generic HEIF brand (e.g. "mif1") with "avif" only listed as a compatible brand. No behavior change — comment only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Tenant Name,Political Entity,Title, ...) instead of raw field names (tenantName,politicalEntity,title, ...), for both thePromisesandAI Extraction Export Rowscollections..webp/.gif/.avifformat.Details
Column labels —
src/lib/exportColumnLabels.tsadds an exportbeforehook that renames each exported row's keys from raw field names to their already-configured adminlabel, wired intopromisesandai-extraction-export-rowsinsrc/plugins/index.ts. (Note: an export of a collection with zero matching rows still shows raw field names in the header — the hook only runs when there's data to transform, and that's not something a plugin hook can override.)Redownloadable exports — root cause was more than "disabled once modified": the Exports collection's
access.updateis hardcoded to always deny, so Payload never renders the edit-view Save/Download button on a saved doc at all. AddedExportDownloadButtonin thebeforeDocumentControlsslot, which renders unconditionally and serves the already-generated file directly. Also forked the plugin's create-time button (ExportSaveButton) so it downloads the saved file instead of regenerating when nothing's changed.Webp dedup — Payload always re-encodes
webp/gif/avifuploads throughsharpbefore saving (even with no resize/format options configured), but the app's duplicate-detection checksum was computed from the raw downloaded bytes — two different byte streams that can never match.computeMediaChecksum(src/utils/files.ts) now detects those three formats by magic bytes and replicates Payload's exact re-encode step before hashing, so sync runs correctly recognize repeat images instead of re-uploading them every time. Applies to bothcreatePoliticalEntity.tsanddownloadDocuments.ts, which had the identical bug.Fixes # (issue)
Type of change
Screenshots
Checklist: