Files
supabase/apps/studio/components/interfaces/ConnectSheet/WarehouseTab.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

143 lines
4.8 KiB
TypeScript

import { Link } from '@tanstack/react-router'
import { useParams } from 'common'
import { Button } from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
import {
isWarehouseProvisioned,
isWarehouseSettingUp,
type WarehouseSetupStatus,
} from '../Integrations/Warehouse/Warehouse.utils'
import { WarehouseConnectionCard } from '../Integrations/Warehouse/WarehouseConnectSection'
import { AlertError } from '@/components/ui/AlertError'
import { checkLocalPipelinesNotSetUp } from '@/data/replication/utils'
import { useWarehouseSetupStatusQuery } from '@/data/warehouse/warehouse-setup-status-query'
const getNotProvisionedContent = (setupStatus?: WarehouseSetupStatus) => {
if (isWarehouseSettingUp(setupStatus)) {
return {
type: 'default' as const,
title: 'Warehouse is being set up',
description: 'Connection details appear here once the first backfill finishes.',
action: 'View progress',
}
}
if (setupStatus === 'error') {
return {
type: 'warning' as const,
title: 'Warehouse setup failed',
description: 'Review the error and retry setup to get connection details.',
action: 'View Warehouse',
}
}
return {
type: 'default' as const,
title: 'Warehouse is not set up',
description: 'Choose which schemas or tables to replicate in order to connect to Warehouse.',
action: 'Choose tables',
}
}
/**
* Read-only view of the Warehouse connection details. Setting Warehouse up, changing which tables
* replicate, and disabling it all live on the Warehouse integration instead.
*/
export const WarehouseTab = () => {
const { ref: projectRef } = useParams()
const { data, isPending, isFetching, isError, error, refetch } = useWarehouseSetupStatusQuery({
projectRef,
})
const hasLiveTables = data?.tables.some((table) => table.state === 'live') ?? false
const canShowConnectionDetails =
data?.setup_status !== 'error' && (isWarehouseProvisioned(data?.setup_status) || hasLiveTables)
let content: React.ReactNode
if (isPending) content = <GenericSkeletonLoader />
// Warehouse rides on the replication API, which isn't wired up in local development. Same
// treatment Pipelines gives it, so a local dev doesn't read this as a broken build.
else if (isError && checkLocalPipelinesNotSetUp(error)) {
content = (
<Admonition
type="default"
title="Warehouse is unavailable locally"
description="Configure the replication API to set up Warehouse in local development."
/>
)
} else if (isError) {
content = (
<AlertError
subject="Failed to load Warehouse status"
error={error}
additionalActions={
<Button variant="default" loading={isFetching} onClick={() => refetch()}>
Retry
</Button>
}
/>
)
} else if (!canShowConnectionDetails) {
const { type, title, description, action } = getNotProvisionedContent(data?.setup_status)
content = (
<Admonition
type={type}
layout="responsive"
title={title}
description={description}
actions={[
<Button key="open-warehouse" asChild variant="default">
<Link
to="/project/$ref/integrations/$id/$pageId"
params={{ ref: projectRef ?? '_', id: 'warehouse', pageId: 'overview' }}
>
{action}
</Link>
</Button>,
]}
/>
)
} else {
return (
<div>
{isWarehouseSettingUp(data?.setup_status) && (
<div className="px-8 pt-8">
<Admonition
type="default"
layout="responsive"
title="Warehouse setup is still running"
description="Some tables are ready to query. The remaining tables will become available as their backfills finish."
actions={[
<Button key="view-progress" asChild variant="default">
<Link
to="/project/$ref/integrations/$id/$pageId"
params={{ ref: projectRef ?? '_', id: 'warehouse', pageId: 'overview' }}
>
View progress
</Link>
</Button>,
]}
/>
</div>
)}
<WarehouseConnectionCard variant="sheet" />
<div className="border-t px-8 py-4">
<Button asChild variant="default" size="tiny">
<Link
to="/project/$ref/integrations/$id/$pageId"
params={{ ref: projectRef ?? '_', id: 'warehouse', pageId: 'overview' }}
>
Manage Warehouse
</Link>
</Button>
</div>
</div>
)
}
return <div className="p-8">{content}</div>
}