Files
supabase/apps/studio/components/interfaces/APIKeys/APIKeyRow.tsx
T
Joshen Lim 09a1f431bc Mass update for all lucide icon imports to use the component with Icon suffix (#51659)
## 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).
```
2026-10-14 12:56:55 +02:00

115 lines
3.7 KiB
TypeScript

import { IS_PLATFORM } from 'common'
import { MoreVerticalIcon } from 'lucide-react'
import { motion } from 'motion/react'
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuTrigger,
TableCell,
TableRow,
Tooltip,
TooltipContent,
TooltipTrigger,
} from 'ui'
import { APIKeyDeleteDialog } from './APIKeyDeleteDialog'
import { ApiKeyPill } from './ApiKeyPill'
import { TextConfirmModal } from '@/components/ui/TextConfirmModalWrapper'
import type { APIKeysData } from '@/data/api-keys/api-keys-query'
export const APIKeyRow = ({
apiKey,
isDeleting,
isDeleteModalOpen,
onDelete,
setKeyToDelete,
}: {
apiKey: Extract<APIKeysData[number], { type: 'secret' | 'publishable' }>
isDeleting: boolean
isDeleteModalOpen: boolean
onDelete: () => void
setKeyToDelete: (id: string | null) => void
}) => {
const MotionTableRow = motion.create(TableRow)
return (
<>
<MotionTableRow
layout
initial={{ opacity: 0, height: 0 }}
animate={{ opacity: 1, height: 'auto' }}
exit={{ opacity: 0, height: 0 }}
transition={{
type: 'spring',
stiffness: 500,
damping: 50,
mass: 1,
}}
>
<TableCell className="py-2 w-56">
<div className="flex flex-col">
<span className="font-medium">{apiKey.name}</span>
<div className="text-sm text-foreground-lighter">
{apiKey.description || <span className="text-foreground-muted">No description</span>}
</div>
</div>
</TableCell>
<TableCell className="py-2">
<div className="flex flex-row gap-2">
<ApiKeyPill apiKey={apiKey} />
</div>
</TableCell>
{IS_PLATFORM && (
<TableCell className="py-2">
<div className="flex justify-end">
<DropdownMenu>
<Tooltip>
<TooltipTrigger asChild>
<DropdownMenuTrigger className="px-1 focus-visible:outline-hidden" asChild>
<Button
aria-label={`More actions for API key ${apiKey.name}`}
variant="text"
size="tiny"
icon={
<MoreVerticalIcon
size="14"
className="text-foreground-light hover:text-foreground"
/>
}
/>
</DropdownMenuTrigger>
</TooltipTrigger>
<TooltipContent side="bottom">More actions for API key</TooltipContent>
</Tooltip>
<DropdownMenuContent className="max-w-40" align="end">
<APIKeyDeleteDialog apiKey={apiKey} setKeyToDelete={setKeyToDelete} />
</DropdownMenuContent>
</DropdownMenu>
</div>
</TableCell>
)}
</MotionTableRow>
<TextConfirmModal
visible={isDeleteModalOpen}
onCancel={() => setKeyToDelete(null)}
onConfirm={onDelete}
title={`Delete ${apiKey.type} API key: ${apiKey.name}`}
confirmString={apiKey.name}
confirmLabel="Yes, irreversibly delete this API key"
confirmPlaceholder="Type the name of the API key to confirm"
loading={isDeleting}
variant="destructive"
alert={{
title: 'This cannot be undone',
description:
'Make sure all applications and services using it have been updated before deletion. Deletion will cause them to receive HTTP 401 Unauthorized status codes on all Supabase APIs.',
}}
/>
</>
)
}