Files
supabase/apps/studio/components/interfaces/JwtSecrets/jwt-secret-keys-table/copyable-key.tsx
Drew McLellan af98094c8c feat(studio): show created at column in JWT signing keys table (#51845)
## What kind of change does this PR introduce?

Feature

## What is the current behavior?

The JWT signing keys table only shows when a key was last rotated.
There's no way to see when a key was created, and the key ID can't be
copied without selecting it by hand.

Resolves FE-3061

<img width="1133" height="193" alt="Screenshot 2026-10-16 at 13 53 43"
src="https://github.com/user-attachments/assets/e50e5a59-f0c4-4f8a-aa14-f200e5c469bd"
/>


## What is the new behavior?

- Adds a **Created at** column (hidden below `xl`) with the same
relative label and timestamp tooltip as **Last rotated at**.
- Combines the **Status** and **Key ID** columns into a single **Key**
column, with the status on top and the key ID beneath in muted
monospace. This follows the pattern used in the Access Tokens table.
- Makes the key ID copyable: hovering it shows a copy icon and a "Copy
key" tooltip, and clicking copies the ID to the clipboard. This follows
the project ref copy pattern in the project list.

<img width="1151" height="436" alt="Screenshot 2026-10-16 at 15 37 23"
src="https://github.com/user-attachments/assets/46c86f85-bff6-4ee6-8d65-0c7a8c23a19e"
/>


## Additional context

No data or API changes (`created_at` was already returned).
2026-10-19 14:54:26 +01:00

48 lines
1.4 KiB
TypeScript

import { CheckIcon, CopyIcon } from 'lucide-react'
import { useEffect, useState } from 'react'
import { copyToClipboard, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
export const CopyableKey = ({ keyId }: { keyId: string }) => {
const [isCopied, setIsCopied] = useState(false)
useEffect(() => {
if (!isCopied) return
const timer = setTimeout(() => setIsCopied(false), 2000)
return () => clearTimeout(timer)
}, [isCopied])
const handleCopy = () => {
copyToClipboard(keyId, () => setIsCopied(true))
}
return (
<>
<Tooltip>
<TooltipTrigger asChild>
<button
type="button"
tabIndex={0}
onClick={handleCopy}
className="flex w-fit items-center gap-x-1 cursor-pointer group font-mono text-xs text-foreground-lighter mt-1"
>
{keyId}
{isCopied ? (
<CheckIcon size={12} strokeWidth={1.25} className="text-primary" />
) : (
<CopyIcon
size={12}
strokeWidth={1.25}
className="opacity-0 group-hover:opacity-100 transition-opacity"
/>
)}
</button>
</TooltipTrigger>
<TooltipContent>Copy key</TooltipContent>
</Tooltip>
<span role="status" aria-live="polite" className="sr-only">
{isCopied ? 'Key copied to clipboard' : ''}
</span>
</>
)
}