Skip to content

Commit bf8641a

Browse files
authored
chore(studio): clearer foreign tables (supabase#40411)
* clean up admonition * legible foreign entity type on light mode * entity icon instances with tooltip
1 parent dbbae98 commit bf8641a

File tree

5 files changed

+36
-56
lines changed

5 files changed

+36
-56
lines changed

apps/studio/components/interfaces/Database/ProtectedSchemaWarning.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
DialogSectionSeparator,
1111
DialogTitle,
1212
DialogTrigger,
13-
cn,
1413
} from 'ui'
1514

1615
import { INTERNAL_SCHEMAS, useIsProtectedSchema } from 'hooks/useProtectedSchemas'
@@ -71,20 +70,17 @@ export const ProtectedSchemaWarning = ({
7170

7271
return (
7372
<Admonition
74-
showIcon={false}
73+
showIcon={size === 'sm' ? false : true}
7574
type="note"
7675
title={
7776
size === 'sm' ? `Viewing protected schema` : `Viewing ${entity} from a protected schema`
7877
}
79-
className={cn(
80-
'[&>div>p]:prose [&>div>p]:max-w-full [&>div>p]:!leading-normal',
81-
size === 'sm' ? '[&>div>p]:text-xs' : '[&>div>p]:text-sm'
82-
)}
78+
className="[&_p]:!m-0"
8379
>
8480
{reason === 'fdw' && fdwType === 'iceberg' ? (
8581
<p>
86-
The <code className="text-xs">{schema}</code> schema is used by Supabase to connect to
87-
analytics buckets and is read-only through the dashboard.
82+
The <code className="text-code-inline">{schema}</code> schema is used by Supabase to
83+
connect to analytics buckets and is read-only through the dashboard.
8884
</p>
8985
) : reason === 'fdw' && fdwType === 's3_vectors' ? (
9086
<p>
@@ -94,8 +90,8 @@ export const ProtectedSchemaWarning = ({
9490
) : (
9591
<>
9692
<p className="mb-2">
97-
The <code className="text-xs">{schema}</code> schema is managed by Supabase and is
98-
read-only through the dashboard.
93+
The <code className="text-code-inline">{schema}</code> schema is managed by Supabase and
94+
is read-only through the dashboard.
9995
</p>
10096
<Dialog open={showModal} onOpenChange={setShowModal}>
10197
<DialogTrigger asChild>

apps/studio/components/interfaces/Database/Tables/TableList.tsx

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
MoreVertical,
1212
Plus,
1313
Search,
14-
Table2,
1514
Trash,
1615
X,
1716
} from 'lucide-react'
@@ -24,6 +23,7 @@ import { LOAD_TAB_FROM_CACHE_PARAM } from 'components/grid/SupabaseGrid.utils'
2423
import AlertError from 'components/ui/AlertError'
2524
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
2625
import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip'
26+
import { EntityTypeIcon } from 'components/ui/EntityTypeIcon'
2727
import SchemaSelector from 'components/ui/SchemaSelector'
2828
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
2929
import { useDatabasePublicationsQuery } from 'data/database-publications/database-publications-query'
@@ -60,7 +60,6 @@ import {
6060
Tooltip,
6161
TooltipContent,
6262
TooltipTrigger,
63-
cn,
6463
} from 'ui'
6564
import { ProtectedSchemaWarning } from '../ProtectedSchemaWarning'
6665
import { formatAllEntities } from './Tables.utils'
@@ -206,11 +205,14 @@ export const TableList = ({
206205
isSuccessTables && isSuccessViews && isSuccessMaterializedViews && isSuccessForeignTables
207206

208207
const formatTooltipText = (entityType: string) => {
209-
return Object.entries(ENTITY_TYPE)
210-
.find(([, value]) => value === entityType)?.[0]
211-
?.toLowerCase()
212-
?.split('_')
213-
?.join(' ')
208+
const text =
209+
Object.entries(ENTITY_TYPE)
210+
.find(([, value]) => value === entityType)?.[0]
211+
?.toLowerCase()
212+
?.split('_')
213+
?.join(' ') || ''
214+
// Return sentence case (capitalize first letter only)
215+
return text.charAt(0).toUpperCase() + text.slice(1)
214216
}
215217

216218
return (
@@ -383,40 +385,14 @@ export const TableList = ({
383385
<TableRow key={x.id}>
384386
<TableCell className="!pl-5 !pr-1">
385387
<Tooltip>
386-
<TooltipTrigger asChild>
387-
{x.type === ENTITY_TYPE.TABLE ? (
388-
<Table2
389-
size={15}
390-
strokeWidth={1.5}
391-
className="text-foreground-lighter"
392-
/>
393-
) : x.type === ENTITY_TYPE.VIEW ? (
394-
<Eye
395-
size={15}
396-
strokeWidth={1.5}
397-
className="text-foreground-lighter"
398-
/>
399-
) : (
400-
<div
401-
className={cn(
402-
'flex items-center justify-center text-xs h-4 w-4 rounded-[2px] font-bold',
403-
x.type === ENTITY_TYPE.FOREIGN_TABLE &&
404-
'text-yellow-900 bg-yellow-500',
405-
x.type === ENTITY_TYPE.MATERIALIZED_VIEW &&
406-
'text-purple-1000 bg-purple-500'
407-
// [Alaister]: tables endpoint doesn't distinguish between tables and partitioned tables
408-
// once we update the endpoint to include partitioned tables, we can uncomment this
409-
// x.type === ENTITY_TYPE.PARTITIONED_TABLE &&
410-
// 'text-foreground-light bg-border-stronger'
411-
)}
412-
>
413-
{Object.entries(ENTITY_TYPE)
414-
.find(([, value]) => value === x.type)?.[0]?.[0]
415-
?.toUpperCase()}
416-
</div>
417-
)}
388+
<TooltipTrigger className="cursor-default">
389+
{/* [Alaister]: EntityTypeIcon supports PARTITIONED_TABLE, but formatAllEntities
390+
doesn't distinguish between tables and partitioned tables yet.
391+
Once the endpoint/formatAllEntities is updated to include partitioned tables,
392+
EntityTypeIcon will automatically style them correctly. */}
393+
<EntityTypeIcon type={x.type} />
418394
</TooltipTrigger>
419-
<TooltipContent side="bottom" className="capitalize">
395+
<TooltipContent side="bottom">
420396
{formatTooltipText(x.type)}
421397
</TooltipContent>
422398
</Tooltip>

apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,14 @@ const EntityListItem = ({
122122
).hasLint
123123

124124
const formatTooltipText = (entityType: string) => {
125-
return Object.entries(ENTITY_TYPE)
126-
.find(([, value]) => value === entityType)?.[0]
127-
?.toLowerCase()
128-
?.split('_')
129-
?.join(' ')
125+
const text =
126+
Object.entries(ENTITY_TYPE)
127+
.find(([, value]) => value === entityType)?.[0]
128+
?.toLowerCase()
129+
?.split('_')
130+
?.join(' ') || ''
131+
// Return sentence case (capitalize first letter only)
132+
return text.charAt(0).toUpperCase() + text.slice(1)
130133
}
131134

132135
const exportTableAsCSV = async () => {

apps/studio/components/ui/EntityTypeIcon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export const EntityTypeIcon = ({
6767
<div
6868
className={cn(
6969
'flex items-center justify-center text-xs h-4 w-4 rounded-[2px] font-bold',
70-
type === ENTITY_TYPE.FOREIGN_TABLE && 'text-yellow-900 bg-yellow-500',
70+
type === ENTITY_TYPE.FOREIGN_TABLE &&
71+
'text-warning-600/80 dark:text-yellow-900 bg-yellow-500',
7172
type === ENTITY_TYPE.MATERIALIZED_VIEW && 'text-purple-1000 bg-purple-500',
7273
type === ENTITY_TYPE.PARTITIONED_TABLE && 'text-foreground-light bg-border-stronger'
7374
)}

apps/studio/styles/typography.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,8 @@
7878
.text-link-table-cell {
7979
@apply truncate cursor-pointer underline underline-offset-4 decoration-foreground-muted/50 hover:decoration-foreground-lighter/80 transition-colors duration-100;
8080
}
81+
82+
.text-code-inline {
83+
@apply break-all text-xs tracking-tight bg-surface-200 border border-muted rounded-md px-1 py-0.5 text-foreground font-medium;
84+
}
8185
}

0 commit comments

Comments
 (0)