import { ChevronRight, EllipsisVertical, Pencil, Shield, Trash2 } from 'lucide-react' import { Button, Card, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from 'ui' const policies = [ { id: 'policy-1', name: 'Anyone can view all active listings', command: 'select', appliedTo: 'public', }, { id: 'policy-2', name: 'Users can delete their own listings', command: 'delete', appliedTo: 'authenticated', }, { id: 'policy-3', name: 'Admins can update any listing', command: 'update', appliedTo: 'authenticated', }, ] // Studio: See also createNavigationHandler in apps/studio/lib/navigation.ts // It handles all of the below, plus modifier clicks and middle mouse button clicks. const handlePolicyNavigation = ( policyId: string, event: React.MouseEvent | React.KeyboardEvent ) => { const url = `/${policyId}` if (event.metaKey || event.ctrlKey) { // window.open(`${url}`, '_blank') Disabled for demo purposes } else { // router.push(url) Disabled for demo purposes } } export default function TableRowLinkActions() { return ( Icon Name Command Applied to Actions {policies.map((policy) => ( { if (event.currentTarget !== event.target) return handlePolicyNavigation(policy.id, event) }} onKeyDown={(event) => { if (event.currentTarget !== event.target) return if (event.key === 'Enter' || event.key === ' ') { event.preventDefault() handlePolicyNavigation(policy.id, event) } }} tabIndex={0} > {policy.name} {policy.command} {policy.appliedTo}
event.stopPropagation()} onKeyDown={(event) => event.stopPropagation()} >
))}
) }