Skip to content

fix: expose JSON viewer in read-only context menus - #781

Merged
debba merged 6 commits into
TabularisDB:mainfrom
igorzelaya-io:fix-readonly-json-context-menu
Sep 22, 2026
Merged

debba merged 6 commits into
TabularisDB:mainfrom
igorzelaya-io:fix-readonly-json-context-menu

Conversation

@igorzelaya-io

Copy link
Copy Markdown
Contributor

Summary

  • allow the existing cell context menu to open for tableless read-only result grids
  • expose Open in JSON Editor for JSON columns outside the editable-only action group
  • keep mutation actions such as Set NULL, paste, row editing, duplication, and deletion hidden in read-only grids
  • add regression coverage that opens a query-result JSON cell from the context menu and verifies the viewer is read-only

Context

This is a focused follow-up to item 2 in @debba's review on #763, where the JSON viewer context-menu action was noted as unavailable for read-only query results. It continues the work for #654 while remaining independent of #763 and based directly on main.

Review note: #763 (review)

Validation

  • DataGrid suite: 41 passed
  • Full frontend suite: 271 files / 4,417 tests passed
  • TypeScript typecheck: passed
  • ESLint: passed
  • GitNexus staged impact check: medium risk, limited to the expected DataGrid/result-view flows

@kilo-code-bot

kilo-code-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Kilo Code Review could not run — your account is out of credits.

Add credits or switch to a free model to enable reviews on this change.

@debba

debba commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Can you resolve merge conflicts? @igorzelaya-io

# Conflicts:
#	tests/components/ui/DataGrid.test.tsx

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the follow-up. Checked it out locally: DataGrid suite 45 passing, typecheck and eslint clean. The change works for materialized-view browse and read-only drivers, but it does not reach the query-result case from the #763 note:

  1. A query tab whose statement has no extractable table (JOIN, expression, SELECT '{"a":1}'::jsonb AS payload) renders with tableName={null} and readonly={false} on a writable driver, so if (!tableName && !readonlyProp) return still suppresses the menu entirely.
  2. Stacked results (ResultEntryContent) and notebook cells (SqlCellResult) pass readonly but no columnMetadata, so isJsonColumn(colDataType) is always false there and the item never appears. Double-click works because isJsonCellTarget also detects JSON by value.

The new test passes because it combines tableName={null}, readonly and jsonb metadata, a shape no caller currently produces.

Suggestion: drop the early return, derive isReadonlyGrid = !!readonlyProp || !tableName (the edit guards already treat tableless grids as non-editable) and use it for the three mutation groups, and build the JSON item with isJsonCellTarget(colDataType, contextMenu.row[contextMenu.colIndex]). I prototyped this locally: the existing suite plus two tests rendering the real caller shapes (readonly without metadata, and tableless without readonly) pass, and mutation items stay hidden. The test could then render without columnMetadata to match the real callers.

@igorzelaya-io

Copy link
Copy Markdown
Contributor Author

Implemented the requested follow-up and merged the latest upstream main into the branch.

Changes:

  • removed the early return so tableless query-result grids can open their context menu
  • derived read-only behavior from either the readonly prop or a missing table name, keeping mutation actions hidden in both cases
  • switched the JSON action to isJsonCellTarget so structured values work even when result components do not provide column metadata
  • replaced the synthetic test setup with two real shapes: a metadata-less read-only result and a writable-driver query result with no table

Validation after merging current main:

  • DataGrid suite: 46/46 passed
  • full frontend suite: 4,827/4,827 passed across 314 files
  • pnpm typecheck: passed
  • pnpm lint: passed

Latest head: 0fbc9e3

@debba
debba merged commit a954980 into TabularisDB:main Sep 22, 2026
2 checks passed
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.

2 participants