Skip to content

feat: add JSON export to Studio selection menu - #1561

Open
SouhailKrs wants to merge 4 commits into
prisma:mainfrom
SouhailKrs:feat/add-json-row-export
Open

SouhailKrs wants to merge 4 commits into
prisma:mainfrom
SouhailKrs:feat/add-json-row-export

Conversation

@SouhailKrs

Copy link
Copy Markdown

Closes #1560

Summary

  • add copy json and save json to the Studio selection export menu
  • preserve JSON values as real JSON types instead of stringifying everything
  • export a single selected row as one object instead of a one-item array

Validation

  • pnpm typecheck
  • pnpm test -- ui/studio/views/table/selection-export.test.ts
  • validated in local demo

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: a01325f3-7b66-4940-a7a3-79b54df4e82c

📥 Commits

Reviewing files that changed from the base of the PR and between 9a0b461 and 89a70a8.

📒 Files selected for processing (2)
  • FEATURES.md
  • ui/studio/views/table/ActiveTableView.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Summary by CodeRabbit

  • New Features

    • Added JSON export options for selected data.
    • Copy selections as JSON to the clipboard or save them as .json files.
    • JSON exports preserve visible columns, current column order, and pinned-column layout.
    • Multi-row selections export as arrays; single-row selections export as objects.
    • Complex values are preserved, with safe handling for unsupported JSON values.
  • Documentation

    • Updated selection export documentation to include JSON support and formatting behavior.

Walkthrough

Studio table selection exports now support JSON for clipboard copying and file downloads. JSON output uses visible column IDs as object keys, preserves nested values, normalizes unsupported values such as bigint and undefined, and emits single objects or arrays based on row count. The export menu, filenames, MIME types, tests, feature documentation, and release changeset were updated accordingly.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 89a70

JSON exports from tables with back-relation columns can omit displayed relational data. The issue is localized but should be corrected before relying on exports for those tables.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #1560 requires Copy JSON and Save JSON to export selected rows as a JSON array of objects. The menu entries, keyed columns, nested values, .json filename, JSON MIME type, and header-toggle ind… Change JSON serialization to return an array for one selected row, as specified by #1560. Update the single-row unit and integration tests to expect a one-item array.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding JSON export to the Studio selection menu.
Description check ✅ Passed The description directly covers the JSON export menu options, native JSON value handling, single-row output, validation, and linked issue.
Out of Scope Changes check ✅ Passed The changes are limited to the Prisma Studio selection export implementation, its tests, release-note changeset, and feature documentation. These changes support the JSON export objective in #1560.
Full details: Linked Issues check

Explanation

Issue #1560 requires Copy JSON and Save JSON to export selected rows as a JSON array of objects. The menu entries, keyed columns, nested values, .json filename, JSON MIME type, and header-toggle independence are implemented and tested. However, serializeSelectionExportJson returns a single object when table.rows.length === 1, and the tests require that behavior. This does not meet the issue requirement for a one-row JSON array.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Comment @coderabbitai help to get the list of available commands.

@SouhailKrs SouhailKrs changed the title fear: Add JSON export to Studio selection menu feat: Add JSON export to Studio selection menu Jul 19, 2026
@SouhailKrs SouhailKrs changed the title feat: Add JSON export to Studio selection menu feat: add JSON export to Studio selection menu Jul 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ui/studio/views/table/selection-export.test.ts (1)

264-322: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Loosened assertions in the JSON download test suggest unreset mock state between tests.

The CSV test (Lines 281, 291) asserts mock.calls[0] and toHaveBeenCalledTimes(1) exactly, while the JSON test right after it uses mock.calls.at(-1) (Line 312) and toBeGreaterThanOrEqual(1) (Line 320). This asymmetry implies URL.createObjectURL/click spies aren't cleared between it blocks, so the JSON test's own call could be masked by accumulated calls from the prior test — toBeGreaterThanOrEqual(1) would still pass even if click weren't invoked in this test at all.

Add vi.restoreAllMocks()/vi.clearAllMocks() in a beforeEach/afterEach so both tests can use precise, order-independent assertions (toHaveBeenCalledTimes(1), mock.calls[0]).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/studio/views/table/selection-export.test.ts` around lines 264 - 322, Reset
the URL and anchor spies between tests in the selection export test suite using
an appropriate beforeEach or afterEach cleanup. Then tighten the JSON download
test to inspect its single call directly with mock.calls[0] and assert
createObjectURL and click were each called exactly once, matching the precise
assertions in the CSV test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@ui/studio/views/table/selection-export.test.ts`:
- Around line 264-322: Reset the URL and anchor spies between tests in the
selection export test suite using an appropriate beforeEach or afterEach
cleanup. Then tighten the JSON download test to inspect its single call directly
with mock.calls[0] and assert createObjectURL and click were each called exactly
once, matching the precise assertions in the CSV test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: aaf194e9-d7cc-4ee4-badb-0a6f6ec7907a

📥 Commits

Reviewing files that changed from the base of the PR and between 550f51d and e0ce064.

📒 Files selected for processing (6)
  • .changeset/pink-llamas-unite.md
  • FEATURES.md
  • ui/studio/views/table/ActiveTableView.filtering.test.tsx
  • ui/studio/views/table/ActiveTableView.tsx
  • ui/studio/views/table/selection-export.test.ts
  • ui/studio/views/table/selection-export.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "Copy JSON" / "Save JSON" option to row selection export menu in Prisma Studio

1 participant