mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Context This is largely just a mechanical change here: Opting to use lucide icons with the `Icon` suffix across all icon imports within `studio` - so that it’s clearer which components are icons + reduces the possibility of name collision with our own components - e.g <User /> vs <UserIcon /> Also added a eslint rule for this: <img width="1069" height="167" alt="image" src="https://github.com/user-attachments/assets/7f36f443-5ca2-4bf6-8d22-86e774513bfc" /> And updated `AGENTS.md` as such: ``` Icons come from `lucide-react`, always imported with the `Icon` suffix (`import { CheckIcon, Trash2Icon } from 'lucide-react'`) — never the bare names (`Check`) or `Check as CheckIcon` aliases (lint-enforced). ```
75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
import { XIcon } from 'lucide-react'
|
|
import { toast } from 'sonner'
|
|
import { Button, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
import { Input } from 'ui-patterns/DataInputs/Input'
|
|
|
|
import { useGroupedPermissions } from '../hooks/useGroupedPermissions'
|
|
import { TokenPermissionsSection } from './TokenPermissionSection'
|
|
|
|
interface AccessTokenNewBannerProps<T> {
|
|
token: T
|
|
onClose: () => void
|
|
getTokenValue: (token: T) => string
|
|
getTokenPermissions?: (token: T) => string[] | undefined
|
|
title?: string
|
|
description?: string
|
|
}
|
|
|
|
export const AccessTokenNewBanner = <T,>({
|
|
token,
|
|
onClose,
|
|
getTokenValue,
|
|
getTokenPermissions,
|
|
title = 'Successfully generated a new token!',
|
|
description = 'Copy this access token and store it in a secure place. You will not be able to see it again.',
|
|
}: AccessTokenNewBannerProps<T>) => {
|
|
const tokenPermissions = getTokenPermissions?.(token)
|
|
const { groupedPermissions, totalCount } = useGroupedPermissions(tokenPermissions)
|
|
|
|
return (
|
|
<Admonition
|
|
type="note"
|
|
title={title}
|
|
className="mb-6 relative"
|
|
actions={
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
variant="text"
|
|
aria-label="Close token banner"
|
|
icon={<XIcon />}
|
|
className="w-7 h-7 absolute top-2.5 right-2.5"
|
|
onClick={onClose}
|
|
/>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom">Close token banner</TooltipContent>
|
|
</Tooltip>
|
|
}
|
|
>
|
|
<div className="space-y-4">
|
|
<p className="text-sm text-foreground-light">{description}</p>
|
|
<div className="w-full pb-2">
|
|
<Input
|
|
copy
|
|
readOnly
|
|
size="small"
|
|
className="w-full input-mono"
|
|
id="access-token-value"
|
|
value={getTokenValue(token)}
|
|
onChange={() => {}}
|
|
onCopy={() => toast.success('Token copied to clipboard')}
|
|
/>
|
|
</div>
|
|
|
|
{tokenPermissions && tokenPermissions.length > 0 && (
|
|
<TokenPermissionsSection
|
|
groupedPermissions={groupedPermissions}
|
|
totalCount={totalCount}
|
|
/>
|
|
)}
|
|
</div>
|
|
</Admonition>
|
|
)
|
|
}
|