Commit Graph

30 Commits

Author SHA1 Message Date
Danny White e540f9089f fix(studio): restore Safari table editor cell copy and context menu (#45353)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Bug fix.

## What is the current behavior?

- Safari Table Editor cells fail to copy from a focused cell with `⌘C`.
- Safari right-click can show the browser menu instead of the custom
cell menu.
- Copy can leave RDG's copied-cell fill behind.

## What is the new behavior?

- Reuses the existing shared `copyToClipboard(value, onSuccess)`
pattern, with the Safari clipboard fix inside that util.
- Handles selected-cell `⌘C` in the RDG keydown path, preventing
browser/RDG defaults and showing the success toast only after copy.
- Replaces the row-level synthetic context-menu shim with RDG's
`onCellContextMenu`, so we prevent Safari's browser menu at the source
and select/focus the target cell.
- Keeps the selected-cell outline while the controlled menu is open.

## Additional context

- `RowRenderer` was only supporting the old context-menu shim; removing
it is part of moving to RDG's cell event path.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **New Features**
* Context menu now provides feedback with toast notifications when
copying cells or rows.
* Selected cells retain their visual styling when context menu is open.

* **Bug Fixes**
  * Improved keyboard shortcut handling for copy functionality.
  * Enhanced clipboard error handling with user-friendly error messages.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ali Waseem <waseema393@gmail.com>
2026-05-04 11:34:28 +10:00
Gildas Garcia 1c228ad18c Chore dnd kit supabase grid columns sort (#44654)
## Problem

We currently have 3 different libraries for drag & drop, two of which
are not actively maintained anymore.

## Solution

Migrate all usage of the two unmaintained libraries to DndKit.
This PR focuses on using DndKit instead of `react-dnd` for column
reordering in the table editor

## Screencast


https://github.com/user-attachments/assets/54fb36f4-5671-42e2-9698-2ae928a69f55

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Column drag-and-drop rebuilt with a live drag preview and improved
pointer/keyboard handling

* **Improvements**
* More reliable column reordering with refined move/freeze/unfreeze
behavior and stable index recomputation
* Standardized column type/format display and simplified grid rendering

* **Accessibility**
  * Added accessible labeling for column actions controls

* **Tests**
* End-to-end locator updated to target the column actions button
deterministically
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-08 16:09:18 +02:00
Charis 4a0bb36ca8 style: require sorted imports in studio/components (#44408)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-04-01 10:22:37 +02:00
Joshen Lim a1abc2d00f Refactor table editor logic for handling null and undefined values (#44331)
## Context

Resolves https://github.com/supabase/supabase/issues/43548

There's currently an issue with the Table Editor where if you have, for
example, a nullable `text` column with a default value, inserting a new
row and selecting "Set to NULL" doesn't do anything, and saving will
insert the row with the default value
<img width="700" height="258" alt="image"
src="https://github.com/user-attachments/assets/6a284ebb-c346-40a6-9a30-793118844084"
/>

This stems from a legacy logic in the Table Editor whereby we treat
`null` values as "no input" - which is incorrect as `null` values are
also valid values. So the PR here changes a few things to resolve this
properly:

## Changes involved
Main fix: 
- `undefined` will be the "no input" value instead, and it'll be the
default value when generating the row object for inserting a new row
- `NULL` or even empty string like `''` will be treated as they are
(valid inputs)

Secondary adjustments:
- (Queue operations) Queueing an insert with no value but default value
is NULL, will show the placeholder as `DEFAULT` instead of `NULL` for
better accuracy in representation
<img width="892" height="96" alt="image"
src="https://github.com/user-attachments/assets/02cf86bf-c17b-4e25-9a8f-17960b1d2575"
/>
- Added a `Set to Default` CTA here, but will only show up if adding a
new row or updating a queued insert row operation, which will set the
value of the input field back to `undefined` for PG to handle it as the
default value
<img width="734" height="208" alt="image"
src="https://github.com/user-attachments/assets/23887c0c-533e-4494-acbe-61309ff5d7c5"
/>


## To test
Verify within the Table Editor (along with queue operation feature
preview)
- For inserting a new row, setting value to NULL and setting value to
Default works
- For updating a row, setting value to NULL works
2026-03-30 23:33:53 +08:00
Ali Waseem 2b419fcb1a fix: revert changes when the value is the same as old (#44196)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Revert changes when the value is the same as the old value

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-03-26 14:39:37 +08:00
Ali Waseem e5a99b4833 fix: annoying and confusing bugs with queue operations in table editor (#44137)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

- Index mismatch on ADD then DELETE/EDIT:
formatGridDataWithOperationValues was searching the original rows array
for DELETE_ROW and EDIT_CELL_CONTENT operations, then using those
indices on the modified formattedRows array (which had been shifted by
ADD_ROW's unshift). Both now search formattedRows directly.
- Cross-table operation leaking: The entire operation queue was passed
to formatGridDataWithOperationValues without filtering by the current
table, causing pending ADD_ROW and DELETE_ROW operations from one table
to appear in other tables. Operations are now filtered by tableId before
rendering.
2026-03-25 20:20:41 +08:00
Ali Waseem 917a686fee chore: refactor queue operations with write operations into a single hook (#44097)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Since queue operations is a feature users can opt-out of, we need to
make it cleaner to toggle between queuing vs straight edits. To do this,
refactor all the operations into a single hook and reference it in
places where we mutate the rows.

## Testing
- Test edit cells, rows, and deletes for non queue operations
- Test edit cells, rows, and deletes for queue operations, also double
check modifying the same rows that are not yet added

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-03-24 14:11:22 +00:00
Joshen Lim 4b5038ef9e Refactor queue operations to not mutate the query client to simplify implementation (#43964)
## Context

If you've got a queued operation on a table, then switch tables, the
dashboard stalls for a few seconds before finally rendering the selected
table.

This was caused by an infinite loop in a useEffect calling
`reapplyOptimisticUpdates` due to `dataUpdatedAt` being in the
dependency array (which comes from react query)

Removing `dataUpdatedAt` would resolve the issue, but then it won't
solve the following comment in the code:
`// This ensures pending changes remain visible when switching tabs or
after data refresh`

## Changes involved

Opting to refactor the logic for rendering data in the Grid instead
- Avoid manipulating the data directly from the query client
  - Manual changes to the query client are hard to track when debugging
- Ideally the data in the query client are exactly what is coming from
the API
- Instead just compute the row data if there's operations applied, and
render that in the grid
  ```
  const baseRows = data?.rows ?? EMPTY_ARR
const rows = formatGridDataWithOperationValues({ operations, rows:
baseRows })
  ```
- Simplifies operations logic + data in react query remains as the
source of truth
- This also improves perceived performance, as previously we'd need to
invalidate the query client if we're removing any operation.
- A lot more apparent with the undo operation introduced
[here](https://github.com/supabase/supabase/pull/43957)
- Whereas now, we'll just revert back to whatever's in the query client
(and still do the invalidation behind the scenes) so things feel faster
2026-03-19 23:05:38 +08:00
Ivan Vasilov 9fa96977be chore: Minor prettier fixes (#43849)
This PR fixes some prettier issues:
- Bump and unify all prettier versions to 3.7.3 across teh whole repo
- Bump the SQL prettier plugin
- When running `test:prettier`, check `mdx` files also
- Run the new prettier format on all files

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-03-17 11:17:42 +01:00
Ivan Vasilov 75644f8396 chore: Bump react-data-grid to fix a Sentry issue (#42934)
This pull request updates the `react-data-grid` dependency and refactors
code throughout the codebase to use the new import structure and updated
APIs. The changes improve compatibility with the latest version of
`react-data-grid`, simplify imports, and update row selection logic to
match new hook signatures. Additionally, some code is reorganized to use
absolute imports for internal components.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-02-20 14:10:13 +01:00
Joshen Lim 0962bccdff Remove default freeze on PK column in table editor (#42636)
## Context

Just removes the default column freeze behaviour on primary key columns
in the table editor. Behaviour should still persist if freezing
manually.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Updates**
  * Grid columns are no longer frozen based on primary key designation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-10 11:49:18 +08:00
Ali Waseem 1696262088 Feat: Insert and delete rows for batch operations on table editor (#42288)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Completion of batch edits on the table editor

## Demo


https://github.com/user-attachments/assets/ab5a7112-3dcc-456a-a5fc-1c9a99fccf34







<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Queued add/edit/delete operations with optimistic UI, conflict
resolution, and queue-based flows
  * Side-panel items showing queued add/delete row previews

* **UI**
* Pending-add placeholders plus a visible "DEFAULT" marker in grid cells
* Visual row states: green for pending adds, red with strike-through for
pending deletes
* Queue-based deletes can bypass confirmation when queue mode is enabled

* **Tests**
* Expanded tests covering queue conflict resolution and queue utilities
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <a@alaisteryoung.com>
2026-02-04 11:15:55 -07:00
Ali Waseem ea1b95d29b feature: batch and save operations for cell content updates (#42120)
* added initial queue operations and feature flag

* updated types

* added dirty state tracking on columns

* updated queue operations

* updated operation types and queue

* updated spacing

* removed on cancel

* updated to support saving

* updated to include eye details

* updated spacing for orders

* updated to support shortcuts

* added feature preview

* updated to unify queue methods

* added key generation

* used unique keys rather than random uuid

* updated based on code review

* operation key

* updated handle cancel

* updated remove operation button

* updated views for toast

* updated logic to support optimistic updates

* updated types

* code cleanup: remove LLM slop

* updated PR bug

* updated preview for logout

* updated based on code review

* removed use effect as it was causing problems

* fixed toast mounting away from sql editor

* removed toast for dedicated action bar

* cleaned up logic

* updated queue operations

* renamed method

* updated name for types

* updated comment

* fixed code rabbit solution

* added check for changed column

* added tests
2026-01-28 06:54:30 -07:00
Ali Waseem 78e0f19d6a fix: add description of column on header name (#42082)
* fix: add description of column on header name

* Simplify

* Attempt to fix test

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-01-23 07:23:07 -07:00
Joshen Lim 27d9b44526 Consolidate copy to clipboard (#36353)
* Consolidate copy to clipboard

* Fix

* Fix some extra clipboard events.

* Fix the tests. Fix a small issue with the copy button.

* Fix

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2025-06-13 13:08:08 +02:00
Alaister Young 8fd6c9276d chore: remove react-tracked part 2 (#34153)
* chore: remove react-tracked part 1

* move out table specific state to own store

* chore: remove react-tracked part 2

* remove unused type

* ensure table is properly updated on changes

* remove all filters save in local storage

* Tiny fixes

* fix sort / filters applying issue + feedback

* fix entity links

* remove unnecessary style

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-03-24 21:11:11 +08:00
Joshen Lim f64b747e24 Support bytea data type in table editor (#33312)
* Support bytea data type in table editor

* Fix rendering bytea in reference record peek

* More fixes
2025-02-05 16:49:21 +08:00
Joshen Lim 97d83e7aa9 Update grid cell editor for date and timestamp type fields (#31121)
* Update grid cell editor for date and timestamp type fields

* Forgot to commit this

* Add basic validation

* Remove console log

* Add placeholder

* Add Set to NOW action

* Pass isNullable to the DatetimeEditor.

* Fix the TooltipTrigger to deduplicate classes. Fix the TimestampInfo to use TooltipTrigger as child.

* Fix the height of the spans to match.

* Fix

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2024-12-18 12:55:53 +08:00
Joshen Lim 1fdba0ec58 Chore/composite foreign key fixes (#28585)
* Fix inability to update composite foreign key values in RowEditor

* Fix unable to view referencing record in table editor if FK column is also PK

* Update apps/studio/state/table-editor.tsx

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>

---------

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
2024-08-14 16:19:53 +08:00
Alaister Young 70da0f1d1d chore: cleanup packages (#27770)
* chore: cleanup packages

- Avoid circular imports
- Export API-types as types
- pg-format without depending on Node internal Buffer (not browser-compatible)
- Avoid importing from barrel files in ui dir

* chore: avoid barrel file imports in studio (#27771)

* chore: avoid barrel file imports

- Removes some unused imports
- Avoids barrel file import for faster builds + less memory

* add eslint rule

* type fixes

* delete layouts barrel

* delete components/grid barrel file

* delete components/grid/utils barrel file

* delete components/grid/components/common barrel file

* delete components/grid/components/editor barrel file

* delete components/grid/components/formatter barrel file

* delete components/grid/components/grid barrel file

* delete components/grid/components/header/filter barrel file

* remote components/grid/store barrel file

* remove components/interfaces/Auth/Policies barrel file

* delete components/interfaces/Settings/Logs barrel file

* delete components/ui/CodeEditor barrel file

* delete components/ui/Forms barrel file

* delete components/ui/Shimmers barrel file

* delete data/analytics barrel file

* delete hooks barrel file

* cleanup lib/common/fetch barrel file

* final * barral files cleanup

* global react-data-grid styles

* remove console.log

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>

* fix build

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
2024-07-04 14:48:10 +08:00
Joshen Lim f094813b3e Add some sentry filters (#27588)
* Add some sentry filters

* Add some sentry filters

* Add ? in copyCellValue
2024-06-27 19:39:39 +08:00
Joshen Lim 0a0f2260f9 Chore/gracefully handle large text or json in table editor (#26792)
* Support rendering large text/jsons in grid

* Support rendering large json in side panel, and large text in grid

* Support rendering large text in side panel

* Fix

* Update comment

* Fix the editValue type for json fields.

* Fix

* Update blur value

* Fix

* Feex

* Padding bump

* Small refactor

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
Co-authored-by: Terry Sutton <saltcod@gmail.com>
2024-05-29 17:10:07 +08:00
Kevin Grüneberg f9a55935f5 chore: use type imports for types/interfaces (#21738) 2024-03-04 20:48:22 +08:00
Kevin Grüneberg f7e60bf324 chore: upgrade prettier/eslint + autofix (#20785) 2024-01-30 10:54:02 +08:00
Joshen Lim fca9b3bff8 Feat/support expanding text cells into a sidepanel editor (#20727)
* Do up logic for callback for opening side panel

* Add TextEditor side panel and fix some quirky bugs with JSONEditor too

* Add Markdown Preview in TextEditor

* Fix bad cs

* Fix border css
2024-01-25 17:47:36 +07:00
Joshen Lim 73c134ceb4 Table editor cell enum dropdown, dont show null option if column is not nullable (#20474)
Table editor cell enum dropdown, dont show null option if column is not nullabl
2024-01-16 22:56:39 +08:00
Ivan Vasilov ef651aa9ba chore: Migrate ColumnsStore (#20032)
* Add react-query mutations for columns APIs.

* Use the new delete column mutation.

* Remove the column store and replace all its methods with mutations from react-query.

* Fix type errors.

* Move some the meta store methods to be pure functions in sidepanel.utils.

* Move the createColumn and updateColumn out of the metaStore.

* Some refactors and fixes

* Shift query invalidation when deleting column to mutation file instead of component file

* reorder some code for my sanity

* remove some @ts-ignores

* remove more @ts-ignores

* Update apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts

* Fix ForeignKeyFormatter crashing client

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: Alaister Young <a@alaisteryoung.com>
Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
2024-01-10 15:20:18 +08:00
Kevin Grüneberg d12332ea5a chore: xmas cleanup (#19938) 2024-01-04 17:27:49 +01:00
Joshen Lim f47a7385ab Assign keys to each side panel editor on the table editor to ensure that input fields have the latest data (#19264)
* Assign keys to each side panel editor on the table editor to ensure that input fields have the latest data

* move rowsPerPage to valtio + more cleanup

* remove sidepanel row optimistic updates

* Change prop for listbox in input field from default value to value

---------

Co-authored-by: Alaister Young <a@alaisteryoung.com>
2023-11-28 21:24:37 +11:00
Ivan Vasilov 436bdb10ae chore: Move the studio app to apps/studio (#18915)
* Move all studio files from /studio to /apps/studio.

* Move studio specific prettier ignores.

* Fix the ui references from studio.

* Fix the css imports.

* Fix all package.json issues.

* Fix the prettier setup for the studio app.

* Add .turbo folder to prettierignore.

* Fix the github workflows.
2023-11-15 12:38:55 +01:00