The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
adds basic pagination to foreign row selector
Alaister Younged91bf5882ce
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/ForeignRowSelector.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/ForeignRowSelector.tsxindex 067097067ac..7c55fa99acd 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/ForeignRowSelector.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/ForeignRowSelector.tsx@@ -14,8 +14,9 @@ import { IconLoader, SidePanel } from 'ui'import ActionBar from '../../ActionBar'import { RowField } from '../RowEditor.types'import { useEncryptedColumns } from './ForeignRowSelector.utils'-import SelectorTable from './SelectorTable'+import SelectorGrid from './SelectorGrid'import { useState } from 'react'+import Pagination from './Pagination'export interface ForeignRowSelectorProps {visible: boolean@@ -60,7 +61,10 @@ const ForeignRowSelector = ({const sorts = formatSortURLParams(params.sort ?? [])const filters = formatFilterURLParams(params.filter ?? [])- const { data, isLoading, isSuccess, isError } = useTableRowsQuery(+ const rowsPerPage = 100+ const [page, setPage] = useState(1)++ const { data, isLoading, isSuccess, isError, isRefetching } = useTableRowsQuery({queryKey: [schemaName, tableName],projectRef: project?.ref,@@ -68,8 +72,8 @@ const ForeignRowSelector = ({table: supaTable,sorts,filters,- // page: state.page,- // limit: state.rowsPerPage,+ page,+ limit: rowsPerPage,},{keepPreviousData: true,@@ -115,23 +119,43 @@ const ForeignRowSelector = ({{isSuccess && supaTable && (<div className="h-full flex flex-col">- <div className="flex items-center my-2 mx-3">- <RefreshButton table={supaTable} />- <FilterPopover- table={supaTable}- filters={params.filter ?? []}- setParams={setParams}+ <div className="flex items-center justify-between my-2 mx-3">+ <div className="flex items-center">+ <RefreshButton table={supaTable} />+ <FilterPopover+ table={supaTable}+ filters={params.filter ?? []}+ setParams={setParams}+ />+ <DndProvider backend={HTML5Backend}>+ <SortPopover+ table={supaTable}+ sorts={params.sort ?? []}+ setParams={setParams}+ />+ </DndProvider>+ </div>++ <Pagination+ page={page}+ setPage={setPage}+ rowsPerPage={rowsPerPage}+ currentPageRowsCount={data?.rows.length ?? 0}+ isLoading={isRefetching}/>- <DndProvider backend={HTML5Backend}>- <SortPopover table={supaTable} sorts={params.sort ?? []} setParams={setParams} />- </DndProvider></div>- <SelectorTable- table={supaTable}- rows={data?.rows ?? []}- onRowSelect={(row) => onSelect(row[columnName ?? ''])}- />+ {data.rows.length > 0 ? (+ <SelectorGrid+ table={supaTable}+ rows={data.rows}+ onRowSelect={(row) => onSelect(row[columnName ?? ''])}+ />+ ) : (+ <div className="flex h-full items-center justify-center border-b border-t border-scale-500">+ <span className="text-scale-1100 text-sm">No Rows Found</span>+ </div>+ )}</div>)}</div>diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/Pagination.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/Pagination.tsxnew file mode 100644index 00000000000..4e01b3063d4--- /dev/null+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/Pagination.tsx@@ -0,0 +1,53 @@+import { Button, IconArrowLeft, IconArrowRight, IconLoader } from 'ui'++export interface PaginationProps {+ page: number+ setPage: (setter: (prev: number) => number) => void+ rowsPerPage: number+ currentPageRowsCount?: number+ isLoading?: boolean+}++const Pagination = ({+ page,+ setPage,+ rowsPerPage,+ currentPageRowsCount = 0,+ isLoading = false,+}: PaginationProps) => {+ const onPreviousPage = () => {+ setPage((prev) => prev - 1)+ }++ const onNextPage = () => {+ setPage((prev) => prev + 1)+ }++ const hasRunOutOfRows = currentPageRowsCount < rowsPerPage++ return (+ <div className="flex items-center gap-2">+ {isLoading && <IconLoader size={14} className="animate-spin" />}++ <Button+ icon={<IconArrowLeft />}+ type="outline"+ disabled={page <= 1 || isLoading}+ onClick={onPreviousPage}+ title="Previous Page"+ style={{ padding: '3px 10px' }}+ />++ <Button+ icon={<IconArrowRight />}+ type="outline"+ disabled={hasRunOutOfRows || isLoading}+ onClick={onNextPage}+ title="Next Page"+ style={{ padding: '3px 10px' }}+ />+ </div>+ )+}++export default Paginationdiff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/SelectorTable.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/SelectorGrid.tsxsimilarity index 92%rename from studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/SelectorTable.tsxrename to studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/SelectorGrid.tsxindex 92d58b964ff..88022d5ec5b 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/SelectorTable.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/SelectorGrid.tsx@@ -3,7 +3,7 @@ import * as Tooltip from '@radix-ui/react-tooltip'import { SupaRow, SupaTable } from 'components/grid'import { IconKey } from 'ui'-export interface SelectorTableProps {+export interface SelectorGridProps {table: SupaTablerows: SupaRow[]onRowSelect: (row: SupaRow) => void@@ -41,7 +41,7 @@ const formatter = (column: string, row: any) => {)}-const SelectorTable = ({ table, rows, onRowSelect }: SelectorTableProps) => {+const SelectorGrid = ({ table, rows, onRowSelect }: SelectorGridProps) => {const columns: Column<SupaRow>[] = table.columns.map((column) => ({key: column.name,name: column.name,@@ -56,4 +56,4 @@ const SelectorTable = ({ table, rows, onRowSelect }: SelectorTableProps) => {)}-export default SelectorTable+export default SelectorGrid