mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
Part 2 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 ← this PR** | **`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 | 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 all `apps/studio/components/layouts/**` files and top-level navigation shell components off `next/link`. **Changed:** - Replaced `next/link` across `components/layouts/**` (`AccountLayout`, `AppLayout`, `AuthLayout`, `BranchLayout`, `DatabaseLayout`, `EdgeFunctionsLayout`, `ExplorerLayout`, `IssuesLayout`, `LogsLayout`, `Navigation`, `ObservabilityLayout`, `ProjectLayout`, `ProjectNeedsSecuring`, `SQLEditorLayout`, `SignInLayout`, `TableEditorLayout`, `Tabs`) and top-level shell components (`Sidebar.tsx`, `UserDropdown.tsx`, `LocalDropdown.tsx`, `HomePageActions.tsx`) - Removed `vi.mock('next/link', ...)` from `LocalDropdown.test.tsx` and `ProjectNeedsSecuring.test.tsx` - Added accessible labels where external icon/logo links switched from `<Link>` to plain `<a>` (`AdminStudioButton.tsx`, `ForgotPasswordLayout.tsx`) Addresses [FE-5108](https://linear.app/supabase/issue/FE-5108/replace-the-nextlink-shim-with-tanstack-link) ## To test - [ ] Navigate across top header, left sidebar, user/local dropdown, and project/org/branch switchers - [ ] Verify mobile navigation menu items and recent-tab links navigate with expected query params - [ ] Verify sign-in and forgot-password layout links work cleanly --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
132 lines
3.6 KiB
TypeScript
132 lines
3.6 KiB
TypeScript
import { Link } from '@tanstack/react-router'
|
|
import { PlusIcon } from 'lucide-react'
|
|
import {
|
|
Button,
|
|
cn,
|
|
Command,
|
|
CommandEmpty,
|
|
CommandGroup,
|
|
CommandInput,
|
|
CommandList,
|
|
CommandSeparator,
|
|
ScrollArea,
|
|
} from 'ui'
|
|
|
|
import { OrgCommandItem } from './OrgCommandItem'
|
|
import { CommandItemLink } from '@/components/ui/CommandItemLink'
|
|
import type { Organization } from '@/types'
|
|
|
|
export interface OrganizationDropdownCommandContentProps {
|
|
embedded: boolean
|
|
className?: string
|
|
organizations: Organization[]
|
|
selectedSlug: string | undefined
|
|
routePathname: string
|
|
hasRouteSlug: boolean
|
|
organizationCreationEnabled: boolean
|
|
onClose: () => void
|
|
}
|
|
|
|
export function OrganizationDropdownCommandContent({
|
|
embedded,
|
|
className,
|
|
organizations,
|
|
selectedSlug,
|
|
routePathname,
|
|
hasRouteSlug,
|
|
organizationCreationEnabled,
|
|
onClose,
|
|
}: OrganizationDropdownCommandContentProps) {
|
|
const orgList = (
|
|
<>
|
|
{organizations?.map((org) => (
|
|
<OrgCommandItem
|
|
key={org.slug}
|
|
org={org}
|
|
selectedSlug={selectedSlug}
|
|
routePathname={routePathname}
|
|
hasRouteSlug={hasRouteSlug}
|
|
onClose={onClose}
|
|
/>
|
|
))}
|
|
</>
|
|
)
|
|
|
|
if (embedded) {
|
|
return (
|
|
<Command className={cn(className, 'flex flex-col flex-1 min-h-0 overflow-hidden')}>
|
|
<div className="flex items-center gap-2 shrink-0 border-b p-2">
|
|
<Button variant="outline" block size="small" asChild>
|
|
<Link
|
|
to="/organizations"
|
|
className="text-xs text-foreground-light hover:text-foreground"
|
|
onClick={onClose}
|
|
>
|
|
All Organizations
|
|
</Link>
|
|
</Button>
|
|
{organizationCreationEnabled && (
|
|
<Button block size="small" asChild icon={<PlusIcon size={14} strokeWidth={1.5} />}>
|
|
<Link
|
|
to="/new"
|
|
className="text-xs text-foreground-light hover:text-foreground"
|
|
onClick={onClose}
|
|
>
|
|
New organization
|
|
</Link>
|
|
</Button>
|
|
)}
|
|
</div>
|
|
<CommandInput
|
|
placeholder="Find organization..."
|
|
wrapperClassName="shrink-0"
|
|
className="text-sm"
|
|
/>
|
|
<CommandList className="flex flex-col flex-1 min-h-0 overflow-y-auto p-1 max-h-none!">
|
|
<CommandEmpty>No organizations found</CommandEmpty>
|
|
<CommandGroup className="min-h-0">{orgList}</CommandGroup>
|
|
</CommandList>
|
|
</Command>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Command className={className}>
|
|
<CommandInput placeholder="Find organization..." />
|
|
<CommandList>
|
|
<CommandEmpty>No organizations found</CommandEmpty>
|
|
<CommandGroup>
|
|
<ScrollArea className={(organizations || []).length > 7 ? 'md:h-[210px]' : ''}>
|
|
{orgList}
|
|
</ScrollArea>
|
|
</CommandGroup>
|
|
<CommandSeparator />
|
|
<CommandGroup>
|
|
<CommandItemLink
|
|
href="/organizations"
|
|
className="cursor-pointer w-full gap-2"
|
|
onSelect={onClose}
|
|
>
|
|
All Organizations
|
|
</CommandItemLink>
|
|
</CommandGroup>
|
|
{organizationCreationEnabled && (
|
|
<>
|
|
<CommandSeparator />
|
|
<CommandGroup>
|
|
<CommandItemLink
|
|
href="/new"
|
|
className="cursor-pointer w-full gap-2"
|
|
onSelect={onClose}
|
|
>
|
|
<PlusIcon size={14} strokeWidth={1.5} />
|
|
<p>New organization</p>
|
|
</CommandItemLink>
|
|
</CommandGroup>
|
|
</>
|
|
)}
|
|
</CommandList>
|
|
</Command>
|
|
)
|
|
}
|