Files
supabase/apps/studio/components/interfaces/BranchManagement/BranchingEmptyState.tsx
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

93 lines
3.5 KiB
TypeScript

import { Link } from '@tanstack/react-router'
import { useParams } from 'common'
import { GitBranchIcon } from 'lucide-react'
import { Badge, Button, Card, CardContent, CardDescription, CardHeader, CardTitle } from 'ui'
import { IntegrationSectionIcon } from '../Settings/Integrations/IntegrationsSettings'
import { CreateBranchButton } from './CreateBranchButton'
import { DocsButton } from '@/components/ui/DocsButton'
import { DOCS_URL } from '@/lib/constants'
export const BranchingEmptyState = ({
isGithubConnected = false,
}: {
isGithubConnected?: boolean
}) => {
const { ref } = useParams()
return (
<Card>
<CardHeader>
<CardTitle>Get started with branching</CardTitle>
<CardDescription>
Create isolated environments to test changes before merging to production
</CardDescription>
</CardHeader>
<CardContent className="p-0 grid grid-cols-1 lg:grid-cols-2 divide-y lg:divide-y-0 lg:divide-x items-stretch">
<div className="p-8">
<div className="flex items-start gap-x-4">
<div className="shrink-0 text-foreground-light">
<Card className="flex h-10 w-10 shrink-0 items-center justify-center p-0">
<GitBranchIcon size={16} />
</Card>
</div>
<div className="text-sm">
<p className="space-x-2">Create a preview branch</p>
<p className="text-foreground-light text-balance mt-1 mb-4">
Make schema or Edge Function changes on a clone of your project, then merge them
back when ready.
</p>
<div className="flex items-center gap-x-2">
<CreateBranchButton />
<DocsButton
label="Learn more"
topic="Branching via the dashboard"
href={`${DOCS_URL}/guides/deployment/branching/dashboard`}
/>
</div>
</div>
</div>
</div>
<div className="p-8">
<div className="flex items-start gap-x-4">
<IntegrationSectionIcon title="github" className=" h-10 w-10" />
<div className="text-sm">
<p className="space-x-2">
<span>Connect with GitHub</span>
{isGithubConnected ? (
<Badge variant="success" className="-translate-y-px">
Connected
</Badge>
) : (
<Badge variant="default" className="-translate-y-px">
Optional
</Badge>
)}
</p>
<p className="text-foreground-light text-balance mt-1 mb-4">
Automatically create a preview branch for each pull request and apply your
migrations on every commit.
</p>
<div className="flex items-center gap-x-2">
{!isGithubConnected && (
<Button asChild>
<Link to="/project/$ref/settings/integrations" params={{ ref: ref ?? '_' }}>
Connect GitHub
</Link>
</Button>
)}
<DocsButton
label="Learn more"
topic="Branching GitHub integration"
href={`${DOCS_URL}/guides/deployment/branching/github-integration`}
/>
</div>
</div>
</div>
</div>
</CardContent>
</Card>
)
}