Files
supabase/apps/studio/components/interfaces/Integrations/Integration/ConnectedResourceGroupSection.tsx
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

112 lines
3.9 KiB
TypeScript

import { SettingsIcon, Trash2Icon, TriangleAlertIcon } from 'lucide-react'
import { Badge, Button } from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { type ResourceGroup } from './MarketplaceIntegrationSettingsTab.types'
import { type ConnectedResource } from '@/components/interfaces/Integrations/Landing/Landing.utils'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { DynamicLink } from '@/components/ui/DynamicLink'
export const ResourceGroupSection = ({
group,
onRemove,
getRemoveDisabledReason,
}: {
group: ResourceGroup
onRemove: (resource: ConnectedResource) => void
/** Returns why a resource can't be removed, which disables its Remove button. */
getRemoveDisabledReason?: (resource: ConnectedResource) => string | undefined
}) => {
return (
<section className="flex flex-col gap-y-4 border-b py-8 first:pt-0 last:border-b-0">
<div className="flex flex-col gap-y-2">
<div className="flex items-center gap-x-2">
<h3 className="text-base text-foreground">{group.title}</h3>
{group.missing ? (
<Badge variant="warning" className="gap-x-1.5">
<TriangleAlertIcon size={12} strokeWidth={1.5} />
Not connected
</Badge>
) : (
group.badge && (
<Badge variant="success" className="gap-x-1.5">
<span className="h-1.5 w-1.5 rounded-full bg-primary-bright" />
{group.badge}
</Badge>
)
)}
</div>
<p className="text-sm text-foreground-light max-w-2xl">{group.description}</p>
</div>
<Admonition
type={group.missing ? 'warning' : 'default'}
className="m-0 max-w-2xl"
title={group.missing ? 'This resource is missing' : undefined}
>
{group.missing ? group.missingNote : group.note}
</Admonition>
{group.missing ? (
group.manageAction && (
<div className="max-w-2xl">
<Button asChild icon={<SettingsIcon />}>
<DynamicLink href={group.manageAction.href}>{group.manageAction.label}</DynamicLink>
</Button>
</div>
)
) : (
<div className="max-w-2xl divide-y rounded-md border bg-surface-100">
{group.items.map((item) => (
<div
key={item.resource.key}
className="flex items-center justify-between gap-x-4 px-4 py-3"
>
<div className="flex min-w-0 flex-col">
<code
data-code-style="plain"
className="truncate font-mono text-sm text-foreground"
title={item.identifier}
>
{item.identifier}
</code>
{item.meta && <span className="text-xs text-foreground-lighter">{item.meta}</span>}
</div>
<div className="flex shrink-0 items-center gap-x-2">
{group.manageAction && (
<Button asChild icon={<SettingsIcon />}>
<DynamicLink href={group.manageAction.href}>
{group.manageAction.label}
</DynamicLink>
</Button>
)}
<RemoveResourceButton
disabledReason={getRemoveDisabledReason?.(item.resource)}
onClick={() => onRemove(item.resource)}
/>
</div>
</div>
))}
</div>
)}
</section>
)
}
const RemoveResourceButton = ({
disabledReason,
onClick,
}: {
disabledReason?: string
onClick: () => void
}) => (
<ButtonTooltip
icon={<Trash2Icon className="text-foreground-light" />}
onClick={onClick}
disabled={disabledReason !== undefined}
tooltip={{ content: { side: 'bottom', text: disabledReason } }}
>
Remove
</ButtonTooltip>
)