Skip to content

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

Standardise UI in database tables page

Joshen Lim7e5b704ec3c4
diff --git a/studio/components/interfaces/Database/Tables/TableList.tsx b/studio/components/interfaces/Database/Tables/TableList.tsx
index 25afa0a600d..31b8079ffa3 100644
--- a/studio/components/interfaces/Database/Tables/TableList.tsx
+++ b/studio/components/interfaces/Database/Tables/TableList.tsx
@@ -161,8 +161,6 @@ const TableList = ({
<ShimmeringLoader className="w-3/4" />
<ShimmeringLoader className="w-1/2" />
</div>
- ) : tables.length === 0 ? (
- <NoSearchResults />
) : (
<div className="my-4 w-full">
<Table
@@ -182,102 +180,127 @@ const TableList = ({
</Table.th>,
<Table.th key="buttons"></Table.th>,
]}
- body={tables.map((x: any, i: any) => (
- <Table.tr key={x.id}>
- <Table.td>
- <p title={x.name}>{x.name}</p>
- </Table.td>
- <Table.td className="hidden max-w-sm truncate lg:table-cell break-all whitespace-normal">
- {x.comment !== null ? (
- <p title={x.comment}>{x.comment}</p>
- ) : (
- <p className="text-scale-800">No description</p>
- )}
- </Table.td>
- <Table.td className="hidden xl:table-cell">
- <code className="text-sm">{x.live_rows_estimate ?? x.live_row_count}</code>
- </Table.td>
- <Table.td className="hidden xl:table-cell">
- <code className="text-sm">{x.size}</code>
- </Table.td>
- <Table.td className="hidden xl:table-cell text-center">
- {(realtimePublication?.tables ?? []).find((table: any) => table.id === x.id) && (
- <div className="flex justify-center">
- <IconCheck strokeWidth={2} />
- </div>
- )}
- </Table.td>
- <Table.td>
- <div className="flex justify-end gap-2">
- <Button
- type="default"
- iconRight={<IconColumns />}
- className="whitespace-nowrap hover:border-gray-500"
- style={{ paddingTop: 3, paddingBottom: 3 }}
- onClick={() => onOpenTable(x)}
- >
- {x.columns?.length} columns
- </Button>
+ body={
+ <>
+ {tables.length === 0 && filterString.length === 0 && (
+ <Table.tr key={selectedSchema}>
+ <Table.td colSpan={6}>
+ <p className="text-sm text-scale-1200">No tables created yet</p>
+ <p className="text-sm text-light">
+ There are no tables found in the schema "{selectedSchema}"
+ </p>
+ </Table.td>
+ </Table.tr>
+ )}
+ {tables.length === 0 && filterString.length > 0 && (
+ <Table.tr key={selectedSchema}>
+ <Table.td colSpan={6}>
+ <p className="text-sm text-scale-1200">No results found</p>
+ <p className="text-sm text-light">
+ Your search for "{filterString}" did not return any results
+ </p>
+ </Table.td>
+ </Table.tr>
+ )}
+ {tables.length > 0 &&
+ tables.map((x: any, i: any) => (
+ <Table.tr key={x.id}>
+ <Table.td>
+ <p title={x.name}>{x.name}</p>
+ </Table.td>
+ <Table.td className="hidden max-w-sm truncate lg:table-cell break-all whitespace-normal">
+ {x.comment !== null ? (
+ <p title={x.comment}>{x.comment}</p>
+ ) : (
+ <p className="text-scale-800">No description</p>
+ )}
+ </Table.td>
+ <Table.td className="hidden xl:table-cell">
+ <code className="text-sm">{x.live_rows_estimate ?? x.live_row_count}</code>
+ </Table.td>
+ <Table.td className="hidden xl:table-cell">
+ <code className="text-sm">{x.size}</code>
+ </Table.td>
+ <Table.td className="hidden xl:table-cell text-center">
+ {(realtimePublication?.tables ?? []).find(
+ (table: any) => table.id === x.id
+ ) && (
+ <div className="flex justify-center">
+ <IconCheck strokeWidth={2} />
+ </div>
+ )}
+ </Table.td>
+ <Table.td>
+ <div className="flex justify-end gap-2">
+ <Button
+ type="default"
+ iconRight={<IconColumns />}
+ className="whitespace-nowrap hover:border-gray-500"
+ style={{ paddingTop: 3, paddingBottom: 3 }}
+ onClick={() => onOpenTable(x)}
+ >
+ {x.columns?.length} columns
+ </Button>
- <Tooltip.Root delayDuration={0}>
- <Tooltip.Trigger>
- <Button
- type="text"
- icon={<IconEdit3 />}
- style={{ padding: 5 }}
- disabled={!canUpdateTables || isLocked}
- onClick={() => onEditTable(x)}
- />
- </Tooltip.Trigger>
- {!canUpdateTables && (
- <Tooltip.Portal>
- <Tooltip.Content side="bottom">
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'rounded bg-scale-100 py-1 px-2 leading-none shadow',
- 'border border-scale-200',
- ].join(' ')}
- >
- <span className="text-xs text-scale-1200">
- You need additional permissions to edit tables
- </span>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- )}
- </Tooltip.Root>
+ <Tooltip.Root delayDuration={0}>
+ <Tooltip.Trigger>
+ <Button
+ type="text"
+ icon={<IconEdit3 />}
+ style={{ padding: 5 }}
+ disabled={!canUpdateTables || isLocked}
+ onClick={() => onEditTable(x)}
+ />
+ </Tooltip.Trigger>
+ {!canUpdateTables && (
+ <Tooltip.Portal>
+ <Tooltip.Content side="bottom">
+ <Tooltip.Arrow className="radix-tooltip-arrow" />
+ <div
+ className={[
+ 'rounded bg-scale-100 py-1 px-2 leading-none shadow',
+ 'border border-scale-200',
+ ].join(' ')}
+ >
+ <span className="text-xs text-scale-1200">
+ You need additional permissions to edit tables
+ </span>
+ </div>
+ </Tooltip.Content>
+ </Tooltip.Portal>
+ )}
+ </Tooltip.Root>
- <Tooltip.Root delayDuration={0}>
- <Tooltip.Trigger>
- <Button
- type="text"
- icon={<IconTrash />}
- style={{ padding: 5 }}
- disabled={!canUpdateTables || isLocked}
- onClick={() => onDeleteTable(x)}
- />
- </Tooltip.Trigger>
- {!canUpdateTables && (
- <Tooltip.Portal>
- <Tooltip.Content side="bottom">
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'rounded bg-scale-100 py-1 px-2 leading-none shadow',
- 'border border-scale-200',
- ].join(' ')}
- >
- <span className="text-xs text-scale-1200">
- You need additional permissions to delete tables
- </span>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- )}
- </Tooltip.Root>
+ <Tooltip.Root delayDuration={0}>
+ <Tooltip.Trigger>
+ <Button
+ type="text"
+ icon={<IconTrash />}
+ style={{ padding: 5 }}
+ disabled={!canUpdateTables || isLocked}
+ onClick={() => onDeleteTable(x)}
+ />
+ </Tooltip.Trigger>
+ {!canUpdateTables && (
+ <Tooltip.Portal>
+ <Tooltip.Content side="bottom">
+ <Tooltip.Arrow className="radix-tooltip-arrow" />
+ <div
+ className={[
+ 'rounded bg-scale-100 py-1 px-2 leading-none shadow',
+ 'border border-scale-200',
+ ].join(' ')}
+ >
+ <span className="text-xs text-scale-1200">
+ You need additional permissions to delete tables
+ </span>
+ </div>
+ </Tooltip.Content>
+ </Tooltip.Portal>
+ )}
+ </Tooltip.Root>
- {/* <Button
+ {/* <Button
type="text"
icon={<IconEdit3 />}
style={{ padding: 5 }}
@@ -291,10 +314,12 @@ const TableList = ({
disabled={isLocked}
onClick={() => onDeleteTable(x)}
/> */}
- </div>
- </Table.td>
- </Table.tr>
- ))}
+ </div>
+ </Table.td>
+ </Table.tr>
+ ))}
+ </>
+ }
/>
</div>
)}