Files
supabase/apps/studio/components/interfaces/APIKeys/APIKeyRow.tsx
T
Brian-AnandDanny White f1082e28c7 chore: migrate Framer Motion imports to Motion (#51520)
## Problem

Closes #31221.
The applications and shared UI packages still import the former
`framer-motion` package instead of Motion's React entry point.

## Solution

Replace runtime imports, type imports, and three test mocks with
`motion/react` across the consuming workspaces.
Replace the seven direct dependency declarations with `motion:
^11.18.2`.
Preserve the existing animation engine version and all other dependency
resolutions, including the asynchronous `domMax` feature loader.
Historical blog examples remain as published; `framer-motion` remains a
transitive implementation dependency of Motion.

## Review instructions

1. Run `pnpm install --frozen-lockfile` and check the seven dependency
replacements in the lockfile.
2. Open the WWW Auth page and Docs homepage at desktop and mobile
widths, with normal and reduced motion preferences.
3. Open the mobile navigation, expand Product on WWW, and close the menu
using Escape and the close button.
4. Check the existing animation components, shared form validation, and
Studio tests for unchanged behavior.

Validation:

- Studio: 731 test files, 8,334 passing tests and one expected failure,
with `--maxWorkers=4`.
- Shared UI, UI patterns, WWW, and UI library: 615 passing tests.
- `pnpm run typecheck --concurrency=1`: all 16 repository tasks pass.
- All six application source lint scripts and lint ratchets pass;
generated Docs example copies are excluded from local lint.
- Repository Prettier source check, lockfile formatting, and case hazard
check pass.
- WWW: 10 existing end-to-end checks across nine pages.
- Docs: 5 existing guide link and accessibility checks across Database
and Auth.
- WWW and Docs mobile navigation pass at desktop/mobile sizes with
normal/reduced motion; SQL-to-REST translation tabs exercise the
asynchronous feature loader without browser errors.
- Frozen-lockfile installation passes; all existing package and snapshot
resolutions are unchanged.
- Learn and UI library command palettes open, filter results, and close
with Escape without browser errors.
- Independent code review finds no actionable defects.
- `npm run build -- --filter=www --filter=docs --filter=studio
--filter=learn --filter=library --concurrency=1 --continue=always`: all
five affected applications build successfully (9 tasks including
prerequisites); asset uploads disabled for local validation.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
(no docs topics changed)

---------

Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
2026-10-14 07:16:00 +00:00

115 lines
3.7 KiB
TypeScript

import { IS_PLATFORM } from 'common'
import { MoreVertical } 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={
<MoreVertical
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.',
}}
/>
</>
)
}