mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +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>
161 lines
6.2 KiB
TypeScript
161 lines
6.2 KiB
TypeScript
import { Link } from '@tanstack/react-router'
|
|
import { useParams } from 'common'
|
|
import { partition } from 'lodash'
|
|
import { ChevronRightIcon, EditIcon, ExternalLinkIcon, Table2Icon, TrashIcon } from 'lucide-react'
|
|
import { parseAsString, useQueryState } from 'nuqs'
|
|
import { Badge, TableCell, TableRow, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
import { INTEGRATIONS } from '../Landing/Integrations.constants'
|
|
import { convertKVStringArrayToJson, formatWrapperTables } from './Wrappers.utils'
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import type { FDW } from '@/data/fdw/fdws-query'
|
|
import { FGA_PERMISSIONS, useAsyncCheckPermissionsV2 } from '@/hooks/misc/useCheckPermissionsV2'
|
|
|
|
interface WrapperRowProps {
|
|
wrapper: FDW
|
|
}
|
|
|
|
export const WrapperRow = ({ wrapper }: WrapperRowProps) => {
|
|
const { ref, id } = useParams()
|
|
const { can: canManageWrappers } = useAsyncCheckPermissionsV2(
|
|
FGA_PERMISSIONS.PROJECT.DATABASE_WRITE
|
|
)
|
|
|
|
const [, setSelectedWrapperToEdit] = useQueryState('edit', parseAsString)
|
|
const [, setSelectedWrapperToDelete] = useQueryState('delete', parseAsString)
|
|
|
|
const integration = INTEGRATIONS.find((i) => i.id === id)
|
|
|
|
if (!integration || integration.type !== 'wrapper') {
|
|
return <p className="text-foreground-lighter text-sm">A wrapper with this ID does not exist</p>
|
|
}
|
|
|
|
const serverOptions = convertKVStringArrayToJson(wrapper.server_options ?? [])
|
|
const [encryptedMetadata, visibleMetadata] = partition(
|
|
integration?.meta?.server.options.filter((option) => !option.hidden),
|
|
'secureEntry'
|
|
)
|
|
|
|
const _tables = formatWrapperTables(wrapper, integration?.meta)
|
|
|
|
const editTooltip = canManageWrappers
|
|
? 'Edit wrapper'
|
|
: 'You need additional permissions to edit wrappers'
|
|
|
|
return (
|
|
<TableRow>
|
|
<TableCell className="gap-2 align-top py-3! min-w-80">
|
|
<p className="text-sm">{wrapper.server_name}</p>
|
|
{visibleMetadata.map((metadata) => (
|
|
<div
|
|
key={metadata.name}
|
|
className="flex items-center space-x-2 text-sm text-foreground-light"
|
|
>
|
|
<span className="text-foreground-lighter text-nowrap">{metadata.label}:</span>
|
|
<span className="truncate max-w-72" title={serverOptions[metadata.name]}>
|
|
{serverOptions[metadata.name] ?? metadata.defaultValue}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</TableCell>
|
|
|
|
<TableCell className="space-y-2 p-4!">
|
|
{_tables?.map((table) => {
|
|
const target =
|
|
(table.table as string | undefined) ??
|
|
(table.object as string | undefined) ??
|
|
(table.src_key as string | undefined) ??
|
|
table.table_name
|
|
const tableId = table.id as string
|
|
|
|
return (
|
|
<div key={tableId} className="flex items-center">
|
|
<Badge className="bg-surface-300 gap-2 font-mono text-xs tracking-tight h-6 text-foreground rounded-r-none">
|
|
<div className="relative w-3 h-3 flex items-center justify-center">
|
|
{integration.icon({ className: 'p-0' })}
|
|
</div>
|
|
<Tooltip>
|
|
<TooltipTrigger className="truncate max-w-28">{target}</TooltipTrigger>
|
|
<TooltipContent
|
|
side="bottom"
|
|
className="max-w-64 whitespace-pre-wrap wrap-break-word"
|
|
>
|
|
{target}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
<ChevronRightIcon
|
|
size={12}
|
|
strokeWidth={1.5}
|
|
className="text-foreground-lighter/50"
|
|
/>
|
|
</Badge>
|
|
|
|
<Link to="/project/$ref/editor/$id" params={{ ref: ref ?? '_', id: String(tableId) }}>
|
|
<Badge className="transition hover:bg-surface-300 px-2 rounded-l-none gap-1.5 h-6 font-mono text-xs tracking-tight border-l-0">
|
|
<Table2Icon size={12} strokeWidth={1.5} className="text-foreground-lighter/50" />
|
|
<Tooltip>
|
|
<TooltipTrigger className="truncate max-w-28">
|
|
{table.schema}.{table.table_name}
|
|
</TooltipTrigger>
|
|
<TooltipContent
|
|
side="bottom"
|
|
className="max-w-64 whitespace-pre-wrap wrap-break-word"
|
|
>
|
|
{table.schema}.{table.table_name}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</Badge>
|
|
</Link>
|
|
</div>
|
|
)
|
|
})}
|
|
</TableCell>
|
|
<TableCell>
|
|
{encryptedMetadata.map((metadata) => (
|
|
<div key={metadata.name} className="flex items-center space-x-2 text-sm">
|
|
<Link
|
|
to="/project/$ref/integrations/$id/$pageId"
|
|
params={{ ref: ref ?? '_', id: 'vault', pageId: 'secrets' }}
|
|
search={{ search: serverOptions[metadata.name] ?? '' }}
|
|
className="transition text-foreground-light hover:text-foreground flex items-center gap-x-2"
|
|
>
|
|
<span title={`View ${metadata.label} in Vault`}>{metadata.label}</span>
|
|
<ExternalLinkIcon size={14} strokeWidth={1.5} />
|
|
</Link>
|
|
</div>
|
|
))}
|
|
</TableCell>
|
|
<TableCell className="flex-nowrap">
|
|
<div className="flex items-center gap-x-2">
|
|
<ButtonTooltip
|
|
disabled={!canManageWrappers}
|
|
icon={<EditIcon strokeWidth={1.5} />}
|
|
className="px-1.5"
|
|
onClick={() => setSelectedWrapperToEdit(wrapper.id.toString())}
|
|
tooltip={{
|
|
content: {
|
|
side: 'bottom',
|
|
text: editTooltip,
|
|
},
|
|
}}
|
|
/>
|
|
<ButtonTooltip
|
|
disabled={!canManageWrappers}
|
|
icon={<TrashIcon strokeWidth={1.5} />}
|
|
className="px-1.5"
|
|
onClick={() => setSelectedWrapperToDelete(wrapper.id.toString())}
|
|
tooltip={{
|
|
content: {
|
|
side: 'bottom',
|
|
text: !canManageWrappers
|
|
? 'You need additional permissions to delete wrappers'
|
|
: 'Delete connection',
|
|
},
|
|
}}
|
|
/>
|
|
</div>
|
|
</TableCell>
|
|
</TableRow>
|
|
)
|
|
}
|