From d03f43626add6517c32640d7694a98e8a0300fa8 Mon Sep 17 00:00:00 2001
From: easonysliu
Date: Tue, 17 Mar 2026 20:43:57 +0800
Subject: [PATCH] fix: hide CSV import on empty table when table is not
editable
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
---
apps/studio/components/grid/components/grid/Grid.tsx | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/apps/studio/components/grid/components/grid/Grid.tsx b/apps/studio/components/grid/components/grid/Grid.tsx
index 048b0c8ccae..db60767b588 100644
--- a/apps/studio/components/grid/components/grid/Grid.tsx
+++ b/apps/studio/components/grid/components/grid/Grid.tsx
@@ -97,8 +97,10 @@ export const Grid = memo(
const { mutate: sendEvent } = useSendEventMutation()
+ const isEditable = snap.editable
+
const { isDraggedOver, onDragOver, onFileDrop } = useCsvFileDrop({
- enabled: isTableEmpty && !isForeignTable,
+ enabled: isTableEmpty && !isForeignTable && isEditable,
onFileDropped: (file) => tableEditorSnap.onImportData(valtioRef(file)),
onTelemetryEvent: (eventName) => {
sendEvent({
@@ -278,7 +280,7 @@ export const Grid = memo(
started.
- ) : (
+ ) : isEditable ? (
- )}
+ ) : null}
) : (