Skip to content

fix: hide CSV import on empty table when table is not editable#2534

Open
everettbu wants to merge 1 commit into
masterfrom
fix/csv-import-empty-table-editable-check
Open

fix: hide CSV import on empty table when table is not editable#2534
everettbu wants to merge 1 commit into
masterfrom
fix/csv-import-empty-table-editable-check

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of supabase/supabase#43857
Original author: mango766


I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When a table is empty, the Table Editor shows an "Import data from CSV" button and accepts CSV drag-and-drop regardless of whether the table is actually editable. This means users can import data into:

  • Protected schema tables (e.g. auth.instances, auth.users)
  • Views and materialized views
  • Tables the user doesn't have permission to edit

The Header component already correctly checks snap.editable before showing the import button, but the empty-table view in Grid.tsx is missing this check.

Related: #41358

What is the new behavior?

The empty table view now checks snap.editable before:

  1. Showing the "Import data from CSV" button
  2. Enabling CSV drag-and-drop via useCsvFileDrop

For non-editable tables, the empty state just shows "This table is empty" without the import option — consistent with how the Header already hides the Insert dropdown for non-editable tables.

Additional context

This is a minimal fix (2 lines of logic changed) that reuses the same snap.editable flag the Header already relies on. There was a previous attempt at this (#41362) but it went stale — this approach is simpler and follows the existing pattern in the codebase.

The empty table state in Grid.tsx was showing the "Import data from CSV"
button and accepting drag-and-drop for all non-foreign-table entities,
regardless of whether the table is actually editable. This allowed users
to import CSV data into protected schema tables (e.g. auth.instances),
views, materialized views, and tables where the user lacks edit
permissions.

The Header component already correctly gates the import option behind
`snap.editable`, but the empty table view in Grid.tsx was missing
this check.

Fixes #41358
@github-actions

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  157 passed
skipped  5 skipped

Details

stats  162 tests across 20 suites
duration  4 minutes, 8 seconds
commit  d03f436

Skipped tests

Features › assistant.spec.ts › AI Assistant › Can send a message to the assistant and receive a response
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

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.

1 participant