Skip to content

Commit 492568b

Browse files
ivasilovjoshenlim
andauthored
fix: Make the padlock red if the entity is insecure in the Table Editor (supabase#37604)
* Make the padlock red. * Update based on feedback in thread --------- Co-authored-by: Joshen Lim <[email protected]>
1 parent 0bd8925 commit 492568b

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

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

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import saveAs from 'file-saver'
2-
import { Clipboard, Copy, Download, Edit, Lock, MoreHorizontal, Trash, Unlock } from 'lucide-react'
2+
import { Clipboard, Copy, Download, Edit, Lock, MoreHorizontal, Trash } from 'lucide-react'
33
import Link from 'next/link'
44
import Papa from 'papaparse'
55
import { toast } from 'sonner'
@@ -29,6 +29,7 @@ import { formatSql } from 'lib/formatSql'
2929
import { useTableEditorStateSnapshot } from 'state/table-editor'
3030
import { createTabId, useTabsStateSnapshot } from 'state/tabs'
3131
import {
32+
Badge,
3233
cn,
3334
copyToClipboard,
3435
DropdownMenu,
@@ -251,28 +252,26 @@ const EntityListItem: ItemRenderer<Entity, EntityListItemProps> = ({
251252
</Tooltip>
252253
<div
253254
className={cn(
254-
'truncate',
255-
'overflow-hidden text-ellipsis whitespace-nowrap flex items-center gap-2 relative w-full',
255+
'truncate overflow-hidden text-ellipsis whitespace-nowrap flex items-center gap-2 relative w-full',
256256
isActive && 'text-foreground'
257257
)}
258258
>
259259
<span
260260
className={cn(
261261
isActive ? 'text-foreground' : 'text-foreground-light group-hover:text-foreground',
262-
'text-sm',
263-
'transition',
264-
'truncate'
262+
'text-sm transition truncate'
265263
)}
266264
>
267265
{entity.name}
268266
</span>
269-
<EntityTooltipTrigger
270-
entity={entity}
271-
isActive={isActive}
272-
tableHasLints={tableHasLints}
273-
viewHasLints={viewHasLints}
274-
materializedViewHasLints={materializedViewHasLints}
275-
/>
267+
<div>
268+
<EntityTooltipTrigger
269+
entity={entity}
270+
tableHasLints={tableHasLints}
271+
viewHasLints={viewHasLints}
272+
materializedViewHasLints={materializedViewHasLints}
273+
/>
274+
</div>
276275
</div>
277276

278277
{canEdit && (
@@ -425,37 +424,36 @@ const EntityListItem: ItemRenderer<Entity, EntityListItemProps> = ({
425424

426425
const EntityTooltipTrigger = ({
427426
entity,
428-
isActive,
429427
tableHasLints,
430428
viewHasLints,
431429
materializedViewHasLints,
432430
}: {
433431
entity: Entity
434-
isActive: boolean
435432
tableHasLints: boolean
436433
viewHasLints: boolean
437434
materializedViewHasLints: boolean
438435
}) => {
439436
let tooltipContent = ''
437+
const accessWarning = 'Data is publicly accessible via API'
440438

441439
switch (entity.type) {
442440
case ENTITY_TYPE.TABLE:
443441
if (tableHasLints) {
444-
tooltipContent = 'RLS disabled'
442+
tooltipContent = `${accessWarning} as RLS is disabled`
445443
}
446444
break
447445
case ENTITY_TYPE.VIEW:
448446
if (viewHasLints) {
449-
tooltipContent = 'Security definer view'
447+
tooltipContent = `${accessWarning} as this is a Security definer view`
450448
}
451449
break
452450
case ENTITY_TYPE.MATERIALIZED_VIEW:
453451
if (materializedViewHasLints) {
454-
tooltipContent = 'Security definer view'
452+
tooltipContent = `${accessWarning} Security definer view`
455453
}
456454
break
457455
case ENTITY_TYPE.FOREIGN_TABLE:
458-
tooltipContent = 'RLS is not enforced on foreign tables'
456+
tooltipContent = `${accessWarning} as RLS via is not enforced on foreign tables`
459457
break
460458
default:
461459
break
@@ -465,13 +463,9 @@ const EntityTooltipTrigger = ({
465463
return (
466464
<Tooltip disableHoverableContent={true}>
467465
<TooltipTrigger className="min-w-4">
468-
<Unlock
469-
size={14}
470-
strokeWidth={2}
471-
className={cn('min-w-4', isActive ? 'text-warning-600' : 'text-warning-500')}
472-
/>
466+
<Badge variant="destructive">Unrestricted</Badge>
473467
</TooltipTrigger>
474-
<TooltipContent side="bottom">
468+
<TooltipContent side="bottom" className="max-w-44 text-center">
475469
<span>{tooltipContent}</span>
476470
</TooltipContent>
477471
</Tooltip>

0 commit comments

Comments
 (0)