feat(admin): add code export modal for collections (#825)#831
Merged
Conversation
Added a modal for exporting collection code, including a button to trigger the modal and functionality to copy export options to the clipboard.
- Render export button + modal only on edit (need a name to fetch) - Use currentColor on export icon (was invisible on light-mode button) - JSON-stringify the embedded collection name to avoid breaking the script on quotes - Escape display_name in the modal HTML - Prefer navigator.clipboard.writeText with execCommand fallback - Drop id from the exported snake→camel result so it satisfies CollectionConfig - encodeURIComponent the collection name in the fetch URL - Wrap script in IIFE to avoid leaking helpers to window Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Internal mirror of #825 by @furelid so CI can run without the fork-authorization gate. Once green and any review fixes are stacked on top, this can be merged in place of #825.
Summary
Adds an Export button to the admin collection edit form that opens a modal showing the collection's configuration as a
CollectionConfigTypeScript snippet, with copy-to-clipboard.Changes
packages/core/src/templates/pages/admin-collections-form.template.ts— Export button, modal markup, fetch + JSON-render + copy logic, snake→camel key normalization.Provenance
Cherry-picked from
furelid:feature/collection-export@e4e2e48. Original PR: #825.Review notes / known follow-ups
data.isEdit || data.id.stroke="#000000"on a black button — invisible in light mode; should usecurrentColor.let collectionName = '${data.name || ''}'is unsafe interpolation into JS context; preferJSON.stringify.document.execCommand('copy');navigator.clipboard.writeText()is the modern path.normalizeCollectionObjectleaves fields (id,lastSyncedAt, etc.) that aren't onCollectionConfig, sosatisfies CollectionConfigwill TS-error when pasted.🤖 Generated with Claude Code