mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 21:05:06 +03:00
## What kind of change does this PR introduce? UI update. ## What is the current behavior? The org’s /apps page is glaringly out of date compared to similar pages. It uses old page and layout components. ## What is the new behavior? - Refactored /apps to use latest [layout](https://supabase.com/design-system/docs/ui-patterns/layout) and [table](https://supabase.com/design-system/docs/components/table) components Unrelated minor changes snuck in: - Global `pnpm format` to properly format recurring annoyances elsewhere - Minor polish on org tiles (pictured) | Before | After | | --- | --- | | <img width="1728" height="997" alt="OAuth Apps Supabase-30B6CDAE-4954-40F8-886A-939797999AA6" src="https://github.com/user-attachments/assets/163c2787-f6ab-4a0b-80aa-af81260bdf9f" /> | <img width="1728" height="997" alt="OAuth Apps Supabase-7DD241E0-262A-4817-91B2-D2A299F8EB93" src="https://github.com/user-attachments/assets/29928305-9110-4256-8663-c3821e696587" /> | | <img width="1728" height="997" alt="OAuth Apps Supabase-9870816A-8022-479D-8011-236A813249AB" src="https://github.com/user-attachments/assets/32e41835-59bc-4d83-92eb-635b98c5f4a5" /> | <img width="1728" height="997" alt="OAuth Apps Supabase-21CFBC16-E850-44A6-BEFF-C4FBED8ACB43" src="https://github.com/user-attachments/assets/6999e2a0-ea17-44cb-99f2-42f985354589" /> | | <img width="1152" height="664" alt="Supabase-9DD87028-2D46-47D0-8546-240184E1711B" src="https://github.com/user-attachments/assets/2c7d8b2a-280f-48d6-9f78-19c519cf4654" /> | <img width="1152" height="664" alt="Supabase-F1C92F66-C602-4DC9-B3B4-AE3FB673276E" src="https://github.com/user-attachments/assets/0a24a98e-386f-4ada-b282-0a59b159bbab" /> | --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
121 lines
3.9 KiB
TypeScript
121 lines
3.9 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { Edit, MoreVertical, Trash } from 'lucide-react'
|
|
|
|
import CopyButton from 'components/ui/CopyButton'
|
|
import type { OAuthApp } from 'data/oauth/oauth-apps-query'
|
|
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
TableCell,
|
|
TableRow,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from 'ui'
|
|
import { TimestampInfo } from 'ui-patterns'
|
|
|
|
export interface OAuthAppRowProps {
|
|
app: OAuthApp
|
|
onSelectEdit: () => void
|
|
onSelectDelete: () => void
|
|
}
|
|
|
|
export const OAuthAppRow = ({ app, onSelectEdit, onSelectDelete }: OAuthAppRowProps) => {
|
|
const { can: canUpdateOAuthApps } = useAsyncCheckPermissions(
|
|
PermissionAction.UPDATE,
|
|
'approved_oauth_apps'
|
|
)
|
|
const { can: canDeleteOAuthApps } = useAsyncCheckPermissions(
|
|
PermissionAction.DELETE,
|
|
'approved_oauth_apps'
|
|
)
|
|
|
|
return (
|
|
<TableRow>
|
|
<TableCell className="w-[62px] min-w-[62px] max-w-[62px]">
|
|
<div
|
|
className="w-[30px] h-[30px] rounded-full bg-no-repeat bg-cover bg-center border border-control flex items-center justify-center text-xs"
|
|
style={{ backgroundImage: app.icon ? `url('${app.icon}')` : 'none' }}
|
|
>
|
|
{!!app.icon ? '' : `${app.name[0]}`}
|
|
</div>
|
|
</TableCell>
|
|
<TableCell>
|
|
<p title={app.name} className="truncate">
|
|
{app.name}
|
|
</p>
|
|
</TableCell>
|
|
<TableCell>
|
|
<div className="flex items-center gap-x-2">
|
|
<p className="text-xs font-mono truncate" title={app.client_id}>
|
|
{app.client_id}
|
|
</p>
|
|
<CopyButton type="default" iconOnly text={app.client_id ?? ''} className="px-1" />
|
|
</div>
|
|
</TableCell>
|
|
<TableCell>
|
|
<TimestampInfo
|
|
utcTimestamp={app.created_at ?? ''}
|
|
labelFormat="DD/MM/YYYY, HH:mm:ss"
|
|
className="text-sm"
|
|
/>
|
|
</TableCell>
|
|
<TableCell className="text-right">
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button type="default" icon={<MoreVertical />} className="px-1" />
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" side="bottom" className="w-32">
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<DropdownMenuItem
|
|
key="edit"
|
|
disabled={!canUpdateOAuthApps}
|
|
className="space-x-2 !pointer-events-auto"
|
|
onClick={() => {
|
|
if (canUpdateOAuthApps) onSelectEdit()
|
|
}}
|
|
>
|
|
<Edit size={16} />
|
|
<p>Edit app</p>
|
|
</DropdownMenuItem>
|
|
</TooltipTrigger>
|
|
{!canUpdateOAuthApps && (
|
|
<TooltipContent side="left">
|
|
You need additional permissions to edit apps
|
|
</TooltipContent>
|
|
)}
|
|
</Tooltip>
|
|
<DropdownMenuSeparator />
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<DropdownMenuItem
|
|
disabled={!canDeleteOAuthApps}
|
|
className="space-x-2 !pointer-events-auto"
|
|
key="delete"
|
|
onClick={() => {
|
|
if (canDeleteOAuthApps) onSelectDelete()
|
|
}}
|
|
>
|
|
<Trash size={16} />
|
|
<p>Delete app</p>
|
|
</DropdownMenuItem>
|
|
</TooltipTrigger>
|
|
{!canDeleteOAuthApps && (
|
|
<TooltipContent side="left">
|
|
You need additional permissions to delete apps
|
|
</TooltipContent>
|
|
)}
|
|
</Tooltip>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</TableCell>
|
|
</TableRow>
|
|
)
|
|
}
|