Files
supabase/apps/studio/components/interfaces/ProjectHome/HomeCard.tsx
Alaister YoungandAlaister Young 680633ee4f [FE-5108] (part 5) refactor(studio): migrate remaining interfaces off next/link (#54308)
Part 5 of a 6-PR stack migrating all `next/link` imports in
`apps/studio` onto TanStack Router's `Link` (or plain `<a>` for known
external URLs) and removing `compat/next/link.tsx`.

| Part | PR | Scope |
| --- | --- | --- |
| 1 | #54304 | `data/prefetchers/PrefetchableLink.tsx` and
`components/ui/**` |
| 2 | #54305 | `components/layouts/**` and top-level shell components |
| 3 | #54306 | Database, TableGridEditor, Storage, SQLEditor,
BranchManagement, Branching, Functions, Realtime |
| 4 | #54307 | Integrations, Settings, Observability, LogDrains, Issues,
Linter, Reports, QueryPerformance, QuerySources, ConfigDrift,
DiskManagement, Compute |
| **5** | **#54308 ← this PR** | **Remaining `components/interfaces/**`
(Org, Billing, Auth, Support, Home, SignIn, ConnectSheet, etc.)** |
| 6 | #54309 | Remove `compat/next/link.tsx` shim, Vite alias, and
update basePath tests/docs |

Migrates the remaining `components/interfaces/**` directories off
`next/link`, leaving zero `next/link` component imports in
`apps/studio`.

**Changed:**

- Replaced `next/link` across all 73 remaining interface files
(`Organization`, `OrganizationInvite`, `Billing`, `Auth`, `Support`,
`ProjectHome`, `Home`, `Project`, `ProjectCreation`, `ProjectAPIDocs`,
`ApiAuthorization`, `App`, `ConnectSheet`, `SignIn`, `APIKeys`,
`Account`, `CliLogin`, `Docs`, `JwtSecrets`, `Platform`)
- Converted the sole remaining `UrlObject` link (`<Link href={{
pathname: '/sign-in-sso', query }}>`) in `SignInSSOForm.tsx` to `<Link
to="/sign-in-sso" search={query}>`
- Migrated `SupportLink.tsx` onto `DynamicLink`
(`createSupportFormUrl(...)`)
- Standardized external `target="_blank"` anchors with `rel="noreferrer
noopener"`, switched `OverviewMetrics.tsx` observability link to typed
`<Link to="/project/$ref/observability/auth">`, and adopted `InlineLink`
/ `InlineLinkClassName` on inline paragraph links per review feedback

Addresses
[FE-5108](https://linear.app/supabase/issue/FE-5108/replace-the-nextlink-shim-with-tanstack-link)

## To test

- [ ] Check Organization (billing, usage, team, documents, AWS
Marketplace), Auth (providers, templates, rate limits, users, OAuth
apps), Support form/links, Project Home, Connect sheet, and Sign-In/SSO
links
- [ ] Verify `SignInWithSSOButton` preserves query params when
navigating to `/sign-in-sso`
- [ ] Verify `SupportLink` pre-populates support form query parameters
cleanly

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 17:33:03 +08:00

61 lines
1.9 KiB
TypeScript

import type { ReactNode } from 'react'
import { Card, CardContent, CardHeader, CardTitle, cn } from 'ui'
import { DynamicLink } from '@/components/ui/DynamicLink'
const STRETCHED_TARGET_CLASS =
'block w-full truncate text-left outline-hidden after:absolute after:inset-0 after:rounded-lg focus-visible:after:ring-1 focus-visible:after:ring-foreground-muted'
type HomeCardTarget = { href: string; onClick?: () => void } | { onClick: () => void; href?: never }
type HomeCardProps = HomeCardTarget & {
icon: ReactNode
label: string
title: string
actions?: ReactNode
description?: ReactNode
meta?: ReactNode
className?: string
}
export const HomeCard = ({
href,
onClick,
icon,
label,
title,
actions,
description,
meta,
className,
}: HomeCardProps) => (
<Card className={cn('relative h-64 flex flex-col', className)}>
<CardHeader className="border-b-0 shrink-0 flex flex-row gap-2 space-y-0 justify-between items-center">
<div className="flex flex-row items-center gap-3">
{icon}
<CardTitle className="text-foreground-light">{label}</CardTitle>
</div>
{actions && <div className="relative z-10 flex items-center gap-1">{actions}</div>}
</CardHeader>
<CardContent className="pt-0 flex flex-col justify-end flex-1 min-h-0">
<h3 className="mb-1">
{href !== undefined ? (
<DynamicLink href={href} onClick={onClick} className={STRETCHED_TARGET_CLASS}>
{title}
</DynamicLink>
) : (
<button type="button" tabIndex={0} onClick={onClick} className={STRETCHED_TARGET_CLASS}>
{title}
</button>
)}
</h3>
{description && (
<div className="text-sm text-muted-foreground line-clamp-3 [&_a]:relative [&_a]:z-10">
{description}
</div>
)}
{meta && <p className="mt-3 text-sm text-foreground-lighter">{meta}</p>}
</CardContent>
</Card>
)