The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
import { EditIcon, MoreVerticalIcon, TrashIcon } from 'lucide-react'
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
TableCell,
TableRow,
Tooltip,
TooltipContent,
TooltipTrigger,
} from 'ui'
import { TimestampInfo } from 'ui-patterns/TimestampInfo'
import CopyButton from '@/components/ui/CopyButton'
import type { OAuthApp } from '@/data/oauth/oauth-apps-query'
import { FGA_PERMISSIONS, useAsyncCheckPermissionsV2 } from '@/hooks/misc/useCheckPermissionsV2'
export interface OAuthAppRowProps {
app: OAuthApp
onSelectEdit: () => void
onSelectDelete: () => void
}
export const OAuthAppRow = ({ app, onSelectEdit, onSelectDelete }: OAuthAppRowProps) => {
const { can: canUpdateOAuthApps } = useAsyncCheckPermissionsV2(
FGA_PERMISSIONS.ORGANIZATION.CONFIG_WRITE
)
const { can: canDeleteOAuthApps } = useAsyncCheckPermissionsV2(
FGA_PERMISSIONS.ORGANIZATION.CONFIG_WRITE
)
return (
<TableRow>
<TableCell className="w-[54px] min-w-[54px] max-w-[54px] pr-2">
<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 className="pl-0">
<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 variant="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 icon={<MoreVerticalIcon />} 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()
}}
>
<EditIcon 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()
}}
>
<TrashIcon 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>
)
}