mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
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>
164 lines
5.4 KiB
TypeScript
164 lines
5.4 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { Link } from '@tanstack/react-router'
|
|
import { useParams } from 'common'
|
|
import { ContainerIcon, PackageIcon } from 'lucide-react'
|
|
import { parseAsStringEnum, useQueryState } from 'nuqs'
|
|
import {
|
|
BreadcrumbItem,
|
|
BreadcrumbLink,
|
|
BreadcrumbList,
|
|
BreadcrumbPage,
|
|
BreadcrumbSeparator,
|
|
Button,
|
|
Card,
|
|
NavMenu,
|
|
NavMenuItem,
|
|
} from 'ui'
|
|
import { PageBreadcrumbs } from 'ui-patterns/PageBreadcrumbs'
|
|
import {
|
|
PageHeader,
|
|
PageHeaderDescription,
|
|
PageHeaderIcon,
|
|
PageHeaderMeta,
|
|
PageHeaderSummary,
|
|
PageHeaderTitle,
|
|
} from 'ui-patterns/PageHeader'
|
|
import { PageNav } from 'ui-patterns/PageNav'
|
|
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { ComputeInstanceStatePill } from '../ComputeInstanceStatePill'
|
|
import { RuntimeBadge } from '../RuntimeBadge'
|
|
import {
|
|
ComputeInstanceDetailSkeleton,
|
|
ComputeInstanceOverviewTabSkeleton,
|
|
} from './ComputeInstanceDetailSkeleton'
|
|
import { ComputeInstanceLogsTab } from './ComputeInstanceLogsTab'
|
|
import { ComputeInstanceOverviewTab } from './ComputeInstanceOverviewTab'
|
|
import { AlertError } from '@/components/ui/AlertError'
|
|
import type { ComputeInstanceLogStream } from '@/data/compute/compute-instance-logs-query'
|
|
import { computeInstanceQueryOptions } from '@/data/compute/compute-instance-query'
|
|
import { PRODUCT_NAME } from '@/lib/constants/compute'
|
|
|
|
type ComputeInstanceTab = 'overview' | 'invocations' | 'logs' | 'activity'
|
|
const COMPUTE_INSTANCE_TABS: ComputeInstanceTab[] = ['overview', 'invocations', 'logs', 'activity']
|
|
|
|
const TAB_LABEL: Record<ComputeInstanceTab, string> = {
|
|
overview: 'Overview',
|
|
invocations: 'Invocations',
|
|
logs: 'Logs',
|
|
activity: 'Activity',
|
|
}
|
|
|
|
const TAB_STREAM: Partial<Record<ComputeInstanceTab, ComputeInstanceLogStream>> = {
|
|
invocations: 'requests',
|
|
logs: 'output',
|
|
activity: 'builds',
|
|
}
|
|
|
|
export const ComputeInstanceDetail = () => {
|
|
const { ref: projectRef, name: instanceName } = useParams()
|
|
|
|
const [tab, setTab] = useQueryState(
|
|
'tab',
|
|
parseAsStringEnum<ComputeInstanceTab>(COMPUTE_INSTANCE_TABS)
|
|
.withDefault('overview')
|
|
.withOptions({ history: 'push' })
|
|
)
|
|
|
|
const {
|
|
data: instance,
|
|
error,
|
|
isPending,
|
|
isError,
|
|
} = useQuery(computeInstanceQueryOptions({ projectRef, name: instanceName }))
|
|
|
|
if (!projectRef) return null
|
|
if (isPending) {
|
|
return (
|
|
<ComputeInstanceDetailSkeleton>
|
|
{tab === 'overview' && <ComputeInstanceOverviewTabSkeleton />}
|
|
{tab !== 'overview' && <GenericSkeletonLoader className="p-4" />}
|
|
</ComputeInstanceDetailSkeleton>
|
|
)
|
|
}
|
|
if (isError) return <AlertError error={error} subject="Failed to retrieve instance" />
|
|
|
|
if (!instance) {
|
|
return (
|
|
<div className="flex flex-1 flex-col items-center justify-center gap-3 py-24 text-center">
|
|
<p className="text-sm text-foreground-light">
|
|
Instance "{instanceName}" does not exist in this project
|
|
</p>
|
|
<Button asChild>
|
|
<Link to="/project/$ref/compute" params={{ ref: projectRef ?? '_' }}>
|
|
Back to {PRODUCT_NAME}
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const stream = TAB_STREAM[tab]
|
|
|
|
return (
|
|
<div className="w-full min-h-full flex flex-col items-stretch">
|
|
<PageBreadcrumbs>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link to="/project/$ref/compute" params={{ ref: projectRef ?? '_' }}>
|
|
{PRODUCT_NAME}
|
|
</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>{instance.name}</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</PageBreadcrumbs>
|
|
|
|
<PageHeader className="py-4 [&>div]:px-4 [&>div]:xl:px-4">
|
|
<PageHeaderMeta className="px-0 xl:px-0">
|
|
<PageHeaderIcon>
|
|
<Card className="flex h-14 w-14 shrink-0 items-center justify-center">
|
|
<ContainerIcon className="h-5 w-5" />
|
|
</Card>
|
|
</PageHeaderIcon>
|
|
<PageHeaderSummary>
|
|
<PageHeaderTitle>{instance.name}</PageHeaderTitle>
|
|
<PageHeaderDescription className="flex flex-row flex-wrap items-center gap-x-4 gap-y-1 text-sm">
|
|
<ComputeInstanceStatePill instance={instance} />
|
|
<RuntimeBadge runtime={instance.runtime} />
|
|
{instance.imageVersion !== undefined && (
|
|
<span className="flex items-center gap-2 text-foreground-light">
|
|
<PackageIcon size={14} strokeWidth={1.5} className="text-foreground-lighter" />
|
|
Version {instance.imageVersion}
|
|
</span>
|
|
)}
|
|
</PageHeaderDescription>
|
|
</PageHeaderSummary>
|
|
</PageHeaderMeta>
|
|
</PageHeader>
|
|
<PageNav>
|
|
<NavMenu>
|
|
{COMPUTE_INSTANCE_TABS.map((item) => (
|
|
<NavMenuItem key={item} active={tab === item}>
|
|
<button type="button" tabIndex={0} onClick={() => setTab(item)}>
|
|
{TAB_LABEL[item]}
|
|
</button>
|
|
</NavMenuItem>
|
|
))}
|
|
</NavMenu>
|
|
</PageNav>
|
|
|
|
{tab === 'overview' && <ComputeInstanceOverviewTab instance={instance} />}
|
|
{stream !== undefined && (
|
|
<div className="flex flex-1 flex-col min-h-0">
|
|
<ComputeInstanceLogsTab key={stream} instanceName={instance.name} stream={stream} />
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|