Files
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

114 lines
4.4 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { Link } from '@tanstack/react-router'
import { Badge, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { InstanceConfiguration } from '../Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration'
import { ActivityStats } from '@/components/interfaces/ProjectHome/ActivityStats'
import { ProjectConnectionPopover } from '@/components/interfaces/ProjectHome/ProjectConnectionPopover'
import { ProjectPausedState } from '@/components/layouts/ProjectLayout/PausedState/ProjectPausedState'
import { InlineLink } from '@/components/ui/InlineLink'
import { ProjectUpgradeFailedBanner } from '@/components/ui/ProjectUpgradeFailedBanner'
import { branchesQueryOptions } from '@/data/branches/branches-query'
import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
import { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL, IS_PLATFORM, PROJECT_STATUS } from '@/lib/constants'
import { useGrant } from '@/lib/grants'
export const TopSection = () => {
const isOrioleDb = useIsOrioleDb()
const { data: project, isLoading } = useSelectedProjectQuery()
const { data: parentProject } = useProjectDetailQuery({ ref: project?.parent_project_ref })
const branchesProjectRef = project?.parent_project_ref ?? project?.ref
const branchesGrant = useGrant('GET /v1/projects/{ref}/branches', {
projectRef: branchesProjectRef,
})
const { data: branches } = useQuery(
branchesQueryOptions({ projectRef: branchesProjectRef, grant: branchesGrant.grant })
)
const mainBranch = branches?.find((branch) => branch.is_default)
const currentBranch = branches?.find((branch) => branch.project_ref === project?.ref)
const isMainBranch = currentBranch?.name === mainBranch?.name
const isPaused = project?.status === PROJECT_STATUS.INACTIVE
const projectName =
currentBranch && !isMainBranch
? currentBranch.name
: project?.name
? project.name
: 'Welcome to your project'
if (isPaused) {
return <ProjectPausedState />
}
return (
<div className="flex flex-col gap-y-4">
<div
className={cn(
'grid grid-cols-1 gap-8 py-0 w-full items-center',
IS_PLATFORM && 'md:grid-cols-2'
)}
>
<div className="flex flex-col">
<div className="flex flex-row flex-wrap items-center gap-4 w-full">
<div>
{!isMainBranch && (
<Link
to="/project/$ref"
params={{ ref: parentProject?.ref ?? '_' }}
className="text-sm text-foreground-light"
>
{parentProject?.name}
</Link>
)}
<div className="flex items-center gap-x-2">
{isLoading ? (
<ShimmeringLoader className="w-32 py-0 h-[33.6px]" />
) : (
<h1 className="text-3xl">{projectName}</h1>
)}
{isOrioleDb && (
<Tooltip>
<TooltipTrigger asChild>
<Badge variant="warning">OrioleDB</Badge>
</TooltipTrigger>
<TooltipContent side="bottom" align="start" className="max-w-80 text-center">
This project is using Postgres with OrioleDB which is currently in preview and
not suitable for production workloads. View our{' '}
<InlineLink href={`${DOCS_URL}/guides/database/orioledb`}>
documentation
</InlineLink>{' '}
for all limitations.
</TooltipContent>
</Tooltip>
)}
</div>
<ProjectConnectionPopover projectRef={project?.ref} />
</div>
</div>
{IS_PLATFORM && (
<div className="mt-8">
<ActivityStats />
</div>
)}
</div>
{IS_PLATFORM && (
<div>
<div
className={cn(
'w-full h-[400px] md:h-[500px] border border-muted rounded-md overflow-hidden flex flex-col relative'
)}
>
<InstanceConfiguration />
</div>
</div>
)}
</div>
<ProjectUpgradeFailedBanner />
</div>
)
}