mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 02:15:05 +03:00
## What kind of change does this PR introduce? Mechanical cleanup on top of the Button default-variant change (#50160). ## What is the current behavior? Many callsites still pass `variant="default"` even though that is now the component default. ## What is the new behavior? Removes redundant static `variant="default"` from legacy `Button` and `ButtonTooltip` callsites. Keeps explicit defaults where they document the API: - `button-default.tsx` and `button-sizes.tsx` demos - `DocsButton`, which pins neutral styling at the wrapper boundary ## To test Studio: - [Auth → Rate Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits): dirty the form so Cancel appears; Cancel stays neutral, Save stays green - [Project Settings → API Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys): `DocsButton` in the header actions stays neutral Design system: - [Design system → Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button): `button-default` / `button-sizes` still show explicit default styling; Primary (green) is restricted to the Primary section (and `asChild`) WWW: - [www → Brand assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets): Download logo kit / Download button kit stay neutral
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 {
|
|
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 { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
|
|
|
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 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={<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>
|
|
)
|
|
}
|