Files
Alaister YoungandAlaister Young df798783e1 [FE-5108] (part 4) refactor(studio): migrate integrations, settings & observability off next/link (#54307)
Part 4 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 ← this PR** | **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/{Integrations,Settings,Observability,LogDrains,Issues,Linter,Reports,QueryPerformance,QuerySources,ConfigDrift,DiskManagement,Compute}/`
off `next/link`.

**Changed:**

- Replaced `next/link` across all 72 files in Integrations, Settings,
Observability, LogDrains, Issues, Linter, Reports, QueryPerformance,
QuerySources, ConfigDrift, DiskManagement, and Compute interfaces
- Updated legacy permanent-redirect hrefs (`/settings/database` →
`/database/settings`, `/settings/vault/secrets` →
`/integrations/vault/secrets`, `/reports/database#database-size-report`
→ `/observability/database#database-size-report`) to canonical routes
- Flattened legacy nested `<Link><a>...</a></Link>` markup in
`DatabaseReadOnlyAlert.tsx` and dropped `passHref` in
`Integrations/Queues/QueueTab.tsx`
- Standardized external `target="_blank"` anchors with `rel="noreferrer
noopener"`, switched `ObservabilityOverviewFooter.tsx` to `InlineLink` +
`DOCS_URL`, and applied `InlineLinkClassName` to the typed billing links
in `DatabaseReadOnlyAlert.tsx` per review feedback
- Removed `vi.mock('next/link', ...)` from
`Settings/General/Project.test.tsx` and
`MobileIssuesNavigation.platform.test.tsx`

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

## To test

- [ ] Navigate across Integrations (marketplace, cron, queues, wrappers,
Vercel/GitHub), Settings (database, infrastructure, read replicas,
logs), Observability, Issues, and Compute pages
- [ ] Verify Logs Preview → Logs Explorer links preserve multi-line SQL
queries in search params
- [ ] Verify billing and database-size links preserve query parameters
and hash fragments

---------

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

125 lines
4.6 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { Link } from '@tanstack/react-router'
import { useParams } from 'common'
import { AlertCircleIcon, ArrowUpRightIcon, CheckCircle2Icon } from 'lucide-react'
import { HoverCard, HoverCardContent, HoverCardTrigger } from 'ui'
import { branchesQueryOptions } from '@/data/branches/branches-query'
import { useGitHubConnectionsQuery } from '@/data/integrations/github-connections-query'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { BASE_PATH } from '@/lib/constants'
import { useGrant } from '@/lib/grants'
export const GitHubStatus = () => {
const { ref: projectRef } = useParams()
const { data: selectedProject } = useSelectedProjectQuery()
const { data: selectedOrganization } = useSelectedOrganizationQuery()
const parentProjectRef = selectedProject?.parent_project_ref || projectRef
const { data: connections } = useGitHubConnectionsQuery(
{ organizationId: selectedOrganization?.id },
{ enabled: !!selectedOrganization?.id }
)
const branchesGrant = useGrant('GET /v1/projects/{ref}/branches', {
projectRef: parentProjectRef,
})
const { data: branches } = useQuery(
branchesQueryOptions(
{ projectRef: parentProjectRef, grant: branchesGrant.grant },
{ enabled: !!parentProjectRef }
)
)
const githubConnection = connections?.find(
(connection) => connection.project.ref === parentProjectRef
)
const mainBranch = branches?.find((branch) => branch.is_default)
const isConnected = Boolean(githubConnection)
const hasGitBranchSync = Boolean(mainBranch?.git_branch?.trim())
const hasAutomaticBranching = Boolean(githubConnection?.new_branch_per_pr)
return (
<HoverCard openDelay={300} closeDelay={100}>
<HoverCardTrigger asChild>
<Link
to="/project/$ref/settings/integrations"
params={{ ref: parentProjectRef ?? '_' }}
className="block w-full transition truncate text-sm text-foreground-light hover:text-foreground"
>
<div className="w-full flex items-center justify-between">
<h3 className="text-sm">GitHub connection</h3>
<ArrowUpRightIcon strokeWidth={1} className="h-4 w-4" />
</div>
<p className="mt-0.5 text-xs text-foreground-lighter flex items-center gap-2">
{isConnected ? (
<>
<img
className="dark:invert"
src={`${BASE_PATH}/img/icons/github-icon.svg`}
width={16}
height={16}
alt=""
aria-hidden="true"
/>
{githubConnection?.repository.name}
</>
) : (
'Not connected'
)}
</p>
</Link>
</HoverCardTrigger>
<HoverCardContent side="right" align="start" className="w-80 p-4 space-y-2">
<div className="flex items-center gap-2 text-sm">
<img
className="dark:invert"
src={`${BASE_PATH}/img/icons/github-icon.svg`}
width={20}
height={20}
alt="GitHub"
/>
<span className="truncate">
{isConnected ? githubConnection?.repository.name : 'Not connected'}
</span>
</div>
{isConnected ? (
<div className="flex flex-col gap-2 text-xs text-foreground-light">
<div className="flex items-center gap-2">
{hasGitBranchSync ? (
<CheckCircle2Icon size={12} className="text-brand-600" />
) : (
<AlertCircleIcon size={12} className="text-warning" />
)}
<span>
{hasGitBranchSync
? `Syncing production (${mainBranch?.git_branch})`
: 'Production sync disabled'}
</span>
</div>
<div className="flex items-center gap-2">
{hasAutomaticBranching ? (
<CheckCircle2Icon size={12} className="text-brand-600" />
) : (
<AlertCircleIcon size={12} className="text-warning" />
)}
<span>
{hasAutomaticBranching
? 'Automatically creating branches'
: 'Automatic branching disabled'}
</span>
</div>
</div>
) : (
<p className="text-xs text-foreground-light">Not connected to any repository</p>
)}
</HoverCardContent>
</HoverCard>
)
}