Files
Alaister YoungandAlaister Young e0635f2f38 [FE-5108] (part 3) refactor(studio): migrate database, editors & storage off next/link (#54306)
Part 3 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 ← this PR** | **Database, TableGridEditor, Storage,
SQLEditor, BranchManagement, Branching, Functions, Realtime** |
| 4 | #54307 | Integrations, Settings, Observability, LogDrains, Issues,
Linter, Reports, QueryPerformance, QuerySources, ConfigDrift,
DiskManagement, Compute |
| 5 | #54308 | 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
`components/interfaces/{Database,TableGridEditor,Storage,SQLEditor,BranchManagement,Branching,Functions,Realtime}/`
off `next/link`.

**Changed:**

- Replaced `next/link` across all 60 importing files in Database,
TableGridEditor, Storage, SQLEditor, BranchManagement, Branching,
Functions, and Realtime interfaces
- Updated legacy permanent-redirect hrefs (`/reports` →
`/observability`, `/database/schema` → `/database/schemas`) to their
canonical TanStack routes
- Dropped legacy `passHref` in `GridHeaderActions.tsx`, removed
duplicate `RouterLink` alias in `ChooseFunctionForm.tsx`, and removed
`vi.mock('next/link', ...)` in `ReplicationPipelineLayout.test.tsx`

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

## To test

- [ ] Check Table Editor, SQL Editor, Database (tables, policies,
functions, triggers, replication, backups), Storage
(files/analytics/vector buckets), Edge Functions, Branching, and
Realtime links
- [ ] Verify SQL Editor and Table Editor links with query parameters
(`schema`, `content`, `search`) do not double-encode values

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 16:43:56 +08:00

79 lines
2.4 KiB
TypeScript

import { Link } from '@tanstack/react-router'
import { Button, GithubIcon } from 'ui'
import { BranchSelector } from './BranchSelector'
import { DocsButton } from '@/components/ui/DocsButton'
import type { Branch } from '@/data/branches/branches-query'
import { DOCS_URL } from '@/lib/constants'
const EMPTY_STATE_CONTAINER = 'flex items-center flex-col gap-0.5 justify-center w-full py-10 px-4'
export const PullRequestsEmptyState = ({
url,
projectRef,
branches,
onBranchSelected,
isUpdating,
hasGithubConnection,
}: {
url: string
projectRef: string
branches: Branch[]
onBranchSelected: (branch: Branch) => void
isUpdating: boolean
hasGithubConnection?: boolean
}) => {
return (
<div className={EMPTY_STATE_CONTAINER}>
<p>No merge requests</p>
<p className="text-foreground-lighter text-center text-balance">
Create your first merge request to merge changes back to the main branch
</p>
<div className="flex items-center space-x-2 mt-4">
{hasGithubConnection ? (
<Button variant="outline" asChild icon={<GithubIcon />}>
<a href={url} target="_blank" rel="noopener noreferrer">
Create pull request
</a>
</Button>
) : (
<Button asChild variant="outline">
<Link to="/project/$ref/settings/integrations" params={{ ref: projectRef ?? '_' }}>
Connect to GitHub
</Link>
</Button>
)}
<BranchSelector
variant="outline"
align="center"
branches={branches}
onBranchSelected={onBranchSelected}
isUpdating={isUpdating}
/>
</div>
</div>
)
}
export const PreviewBranchesEmptyState = ({
onSelectCreateBranch,
}: {
onSelectCreateBranch: () => void
}) => {
return (
<div className={EMPTY_STATE_CONTAINER}>
<p>Create your first preview branch</p>
<p className="text-foreground-lighter text-center text-balance mb-4">
Preview branches are short-lived environments that let you safely experiment with changes to
your database schema without affecting your main database.
</p>
<div className="flex items-center space-x-2">
<DocsButton href={`${DOCS_URL}/guides/platform/branching`} />
<Button variant="primary" onClick={() => onSelectCreateBranch()}>
Create branch
</Button>
</div>
</div>
)
}