import { useMemo, useState } from 'react' import { Eye, EyeOff, MoreVertical, TrashIcon, Logs, Settings2 } from 'lucide-react' import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, DropdownMenuSeparator, TooltipTrigger_Shadcn_, Tooltip_Shadcn_, } from 'ui' import { TooltipContent } from '@radix-ui/react-tooltip' import CopyButton from 'components/ui/CopyButton' import Table from 'components/to-be-cleaned/Table' import DeleteAPIKeyModal from './DeleteAPIKeyModal' import { APIKeysData } from 'data/api-keys/api-keys-query' export interface APIKeyRowProps { projectRef: string apiKey: APIKeysData[0] } const APIKeyRow = ({ projectRef, apiKey }: APIKeyRowProps) => { const isSecret = apiKey.type === 'secret' const [shown, setShown] = useState(!isSecret) const [deleteVisible, setDeleteVisible] = useState(false) const hiddenKey = useMemo( () => apiKey.prefix + Array.from({ length: apiKey.api_key.length - apiKey.prefix!.length }, () => '•').join(''), [apiKey.api_key, apiKey.prefix] ) const canDeleteAPIKeys = true // todo return (
{shown ? apiKey.api_key : hiddenKey} {isSecret ? (
{isSecret ? ( {apiKey.secret_jwt_template?.role ?? ''} ) : null} {apiKey.description || '/'} View logs from this API key Edit { if (canDeleteAPIKeys) { e.preventDefault() } setDeleteVisible(true) }} > Delete API key {!canDeleteAPIKeys && ( You need additional permissions to delete API keys )}
) } export default APIKeyRow