mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +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). ```
52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import { ChevronDownIcon, ChevronRightIcon } from 'lucide-react'
|
|
import { useState } from 'react'
|
|
import { Button, Collapsible, CollapsibleContent, CollapsibleTrigger } from 'ui'
|
|
|
|
import { PermissionsList } from './PermissionList'
|
|
|
|
const PERMISSIONS_COLLAPSE_THRESHOLD = 5
|
|
|
|
interface TokenPermissionsSectionProps {
|
|
groupedPermissions: Record<string, string[]>
|
|
totalCount: number
|
|
}
|
|
|
|
export const TokenPermissionsSection = ({
|
|
groupedPermissions,
|
|
totalCount,
|
|
}: TokenPermissionsSectionProps) => {
|
|
const [permissionsOpen, setPermissionsOpen] = useState(false)
|
|
const shouldCollapse = totalCount > PERMISSIONS_COLLAPSE_THRESHOLD
|
|
|
|
if (totalCount === 0) return null
|
|
|
|
return (
|
|
<div className="pt-4 border-t border-default">
|
|
{shouldCollapse ? (
|
|
<Collapsible open={permissionsOpen} onOpenChange={setPermissionsOpen}>
|
|
<CollapsibleTrigger asChild>
|
|
<Button
|
|
variant="text"
|
|
size="tiny"
|
|
className="w-full justify-start px-0.5 h-auto text-sm font-medium text-foreground-light hover:text-foreground"
|
|
>
|
|
<div className="flex items-center gap-1.5">
|
|
{permissionsOpen ? <ChevronDownIcon size={14} /> : <ChevronRightIcon size={14} />}
|
|
<span>Permissions assigned to this token ({totalCount})</span>
|
|
</div>
|
|
</Button>
|
|
</CollapsibleTrigger>
|
|
<CollapsibleContent className="pt-3 transition-all data-closed:animate-collapsible-up data-open:animate-collapsible-down">
|
|
<PermissionsList groupedPermissions={groupedPermissions} />
|
|
</CollapsibleContent>
|
|
</Collapsible>
|
|
) : (
|
|
<>
|
|
<h3 className="text-sm font-medium mb-3">Permissions assigned to this token:</h3>
|
|
<PermissionsList groupedPermissions={groupedPermissions} />
|
|
</>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|