Preview first record of a collection#4619
Conversation
- Extract shared JsonViewer component (Monaco + copy button) from DataclipViewer - Add CollectionPreviewViewer with string truncation for long values - Wire up preview button and modal in CollectionsComponent showing the first item - Register CollectionPreviewViewer as an esbuild entry point - Add LiveView and frontend tests
…splay
Collection values are stored as raw strings in the DB. When wrapped in
the download format ([{key, value, created, updated}]), JSON values get
double-encoded into unreadable escaped strings. This recursively parses
value fields that contain valid JSON so truncateStrings can walk into
the real structure. Also reorders keys so key appears first.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4619 +/- ##
==========================================
+ Coverage 89.51% 89.61% +0.09%
==========================================
Files 444 444
Lines 21505 21558 +53
==========================================
+ Hits 19250 19319 +69
+ Misses 2255 2239 -16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Security ReviewClaude hit the max-turns limit or encountered an error before posting findings. See the workflow run for details. |
|
This might need an update after #4613 |
- Gate preview on Bodyguard Collections policy (access_collection) via can_access_collection/2, consistent with the REST controller - Pass current_user into CollectionsComponent so the policy can be evaluated - Apply the same can_access_collection guard to edit and delete actions - Extract MAX_PARSE_DEPTH constant in CollectionPreviewViewer - Add tests: all project members can preview, cross-project preview/edit/delete are blocked
…eview-collections
midigofrank
left a comment
There was a problem hiding this comment.
Nicely done @lmac-1 . I have capped the MAX_DEPTH of the parseValues function to 5, this way we don't need to worry about ungodly depths.
|
Thanks @midigofrank for your help with this one 🙏🏻 |
Description
This PR adds a collection preview modal to project settings. Each collection row gets an eye icon button that opens a modal showing the first record as formatted JSON, so users can quickly check what's in a collection without downloading it.
Built on @midigofrank's initial implementation in 4528-frank-preview-collections, with changes on top.
Closes #4528
Validation steps
Additional notes for the reviewer
AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code)
(e.g.,
:owner,:admin,:editor,:viewer)