Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Bring changes from 14058 and resolve conflicts

Joshen Limde36c82e37df
diff --cc studio/components/grid/components/grid/Grid.tsx
index dd1ba17864c,4e937cce8d4..92538acc3bd
--- a/studio/components/grid/components/grid/Grid.tsx
+++ b/studio/components/grid/components/grid/Grid.tsx
@@@ -142,26 -163,60 +163,60 @@@ export const Grid = memo
rowClass={rowClass}
style={{ height: '100%' }}
noRowsFallback={
- <div
- style={{ height: `calc(100% - 35px)` }}
- className="flex flex-col items-center justify-center"
- >
- <p className="text-base">This table is empty</p>
- {onAddRow !== undefined && onImportData !== undefined && (
+ <>
+ {isLoading && (
+ <div className="p-2">
+ <GenericSkeletonLoader />
+ </div>
+ )}
+ {isError && (
+ <div className="p-2">
+ <AlertError error={error} subject="Failed to retrieve rows from table" />
+ </div>
+ )}
+ {isSuccess && (
<>
- <p className="text-sm text-light mt-1">Add some rows to get started.</p>
- <div className="flex items-center space-x-2 mt-4">
- {/* [Joshen] Leaving this as a placeholder */}
- {/* <Button type="outline">Generate random data</Button> */}
- {onAddRow !== undefined && onImportData !== undefined && (
- <Button type="default" onClick={onImportData}>
- Import data via CSV
- </Button>
- )}
- </div>
+ {(filters ?? []).length === 0 ? (
+ <div
+ style={{ height: `calc(100% - 35px)` }}
+ className="flex flex-col items-center justify-center"
+ >
+ <p className="text-sm text">This table is empty</p>
+ {onAddRow !== undefined && onImportData !== undefined && (
+ <>
+ <p className="text-sm text-light mt-1">
- Add or generate rows to get started.
++ Add rows to your table to get started.
+ </p>
+ <div className="flex items-center space-x-2 mt-4">
+ {/* [Joshen] Leaving this as a placeholder */}
+ {/* <Button type="outline">Generate random data</Button> */}
+ {onAddRow !== undefined && onImportData !== undefined && (
+ <Button type="default" onClick={onImportData}>
+ Import data via CSV
+ </Button>
+ )}
+ </div>
+ </>
+ )}
+ </div>
+ ) : (
+ <div
+ style={{ height: `calc(100% - 35px)` }}
+ className="flex flex-col items-center justify-center"
+ >
+ <p className="text-sm text-light">
+ The filters applied has returned no results from this table
+ </p>
+ <div className="flex items-center space-x-2 mt-4">
+ <Button type="default" onClick={() => removeAllFilters()}>
+ Remove all filters
+ </Button>
+ </div>
+ </div>
+ )}
</>
)}
- </div>
+ </>
}
/>
</div>
diff --cc studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
index 4da12554ad8,0e8e621b338..6f8dda6da38
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
@@@ -1,23 -1,22 +1,22 @@@
import type { PostgresColumn, PostgresTable } from '@supabase/postgres-meta'
import { QueryKey, useQueryClient } from '@tanstack/react-query'
- import { Dictionary } from 'components/grid'
- import { find, isEmpty, isUndefined, noop } from 'lodash'
+ import { isEmpty, isUndefined, noop } from 'lodash'
import { useState } from 'react'
+import { Modal } from 'ui'
+ import { Dictionary } from 'components/grid'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import ConfirmationModal from 'components/ui/ConfirmationModal'
import { entityTypeKeys } from 'data/entity-types/keys'
import { sqlKeys } from 'data/sql/keys'
import { useTableRowCreateMutation } from 'data/table-rows/table-row-create-mutation'
import { useTableRowUpdateMutation } from 'data/table-rows/table-row-update-mutation'
+ import { tableKeys } from 'data/tables/keys'
import { useStore, useUrlState } from 'hooks'
+ import { useTableEditorStateSnapshot } from 'state/table-editor'
-import { Modal } from 'ui'
import { ColumnEditor, RowEditor, SpreadsheetImport, TableEditor } from '.'
- import ForeignRowSelector, {
- ForeignRowSelectorProps,
- } from './RowEditor/ForeignRowSelector/ForeignRowSelector'
+ import ForeignRowSelector from './RowEditor/ForeignRowSelector/ForeignRowSelector'
import JsonEdit from './RowEditor/JsonEditor/JsonEditor'
- import { JsonEditValue } from './RowEditor/RowEditor.types'
import {
ColumnField,
CreateColumnPayload,
@@@ -27,21 -26,7 +26,8 @@@
import { ImportContent } from './TableEditor/TableEditor.types'
export interface SidePanelEditorProps {
+ editable?: boolean
- selectedSchema: string
selectedTable?: PostgresTable
- selectedRowToEdit?: Dictionary<any>
- selectedColumnToEdit?: PostgresColumn
- selectedTableToEdit?: PostgresTable
- selectedValueForJsonEdit?: JsonEditValue
- selectedForeignKeyToEdit?: {
- foreignKey: NonNullable<ForeignRowSelectorProps['foreignKey']>
- row: any
- column: any
- }
- sidePanelKey?: 'row' | 'column' | 'table' | 'json' | 'foreign-row-selector' | 'csv-import'
- isDuplicating?: boolean
- closePanel: () => void
onRowCreated?: (row: Dictionary<any>) => void
onRowUpdated?: (row: Dictionary<any>, idx: number) => void
@@@ -52,17 -37,7 +38,8 @@@
}
const SidePanelEditor = ({
+ editable = true,
- selectedSchema,
selectedTable,
- selectedRowToEdit,
- selectedColumnToEdit,
- selectedTableToEdit,
- selectedValueForJsonEdit,
- selectedForeignKeyToEdit,
- sidePanelKey,
- isDuplicating = false,
- closePanel,
onRowCreated = noop,
onRowUpdated = noop,
onTableCreated = noop,
@@@ -554,12 -553,11 +555,12 @@@
updateEditorDirty={() => setIsEdited(true)}
/>
<JsonEdit
- visible={sidePanelKey === 'json'}
- column={selectedValueForJsonEdit?.column ?? ''}
- jsonString={selectedValueForJsonEdit?.jsonString ?? ''}
+ visible={snap.sidePanel?.type === 'json'}
+ column={(snap.sidePanel?.type === 'json' && snap.sidePanel.jsonValue.column) || ''}
+ jsonString={(snap.sidePanel?.type === 'json' && snap.sidePanel.jsonValue.jsonString) || ''}
backButtonLabel="Cancel"
applyButtonLabel="Save changes"
+ readOnly={!editable}
closePanel={onClosePanel}
onSaveJSON={onSaveJSON}
/>
diff --cc studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
index 366d6caaf1e,a0f15ceb6fd..80052cc6ed3
--- a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
@@@ -409,18 -380,9 +379,10 @@@ const TableGridEditor = (
{(isViewSelected || isTableSelected) && <TableDefinition id={selectedTable?.id} />}
</SupabaseGrid>
- {!isUndefined(selectedSchema) && (
+ {snap.selectedSchemaName !== undefined && (
<SidePanelEditor
+ editable={!isReadOnly && canEditViaTableEditor}
- selectedSchema={selectedSchema}
- isDuplicating={isDuplicating}
selectedTable={selectedTable as PostgresTable}
- selectedRowToEdit={selectedRowToEdit}
- selectedColumnToEdit={selectedColumnToEdit}
- selectedTableToEdit={selectedTableToEdit}
- selectedValueForJsonEdit={selectedValueForJsonEdit}
- selectedForeignKeyToEdit={selectedForeignKeyToEdit}
- sidePanelKey={sidePanelKey}
onRowCreated={onRowCreated}
onRowUpdated={onRowUpdated}
onColumnSaved={onColumnSaved}