mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +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>
113 lines
3.1 KiB
TypeScript
113 lines
3.1 KiB
TypeScript
import { Edit2Icon, MoreVerticalIcon, TrashIcon } from 'lucide-react'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
Menu,
|
|
} from 'ui'
|
|
|
|
import { DynamicLink } from '@/components/ui/DynamicLink'
|
|
import { ContentBase } from '@/data/content/content-query'
|
|
import {
|
|
FGA_PERMISSIONS,
|
|
useAsyncCheckUserContentPermissions,
|
|
} from '@/hooks/misc/useCheckPermissionsV2'
|
|
import { useProfile } from '@/lib/profile'
|
|
import type { Dashboards } from '@/types'
|
|
|
|
interface ReportMenuItemProps {
|
|
item: {
|
|
id?: string
|
|
name: string
|
|
description: string
|
|
key: string
|
|
url: string
|
|
hasDropdownActions: boolean
|
|
report: ContentBase & {
|
|
type: 'report'
|
|
content: Dashboards.Content
|
|
}
|
|
}
|
|
pageKey: string
|
|
onSelectEdit: () => void
|
|
onSelectDelete: () => void
|
|
}
|
|
|
|
export const ObservabilityMenuItem = ({
|
|
item,
|
|
pageKey,
|
|
onSelectEdit,
|
|
onSelectDelete,
|
|
}: ReportMenuItemProps) => {
|
|
const { profile } = useProfile()
|
|
const { can: canUpdateCustomReport } = useAsyncCheckUserContentPermissions(
|
|
FGA_PERMISSIONS.PROJECT.SNIPPETS_WRITE,
|
|
{
|
|
mode: 'existing',
|
|
type: 'report',
|
|
visibility: item.report.visibility,
|
|
ownerId: item.report.owner_id,
|
|
subjectId: profile?.id,
|
|
}
|
|
)
|
|
|
|
const menuItem = (
|
|
<Menu.Item active={item.key === pageKey} className="pr-2.5">
|
|
<div className="flex w-full items-center justify-between gap-1">
|
|
<p className="truncate w-full">{item.name}</p>
|
|
|
|
{canUpdateCustomReport && (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
aria-label="More actions"
|
|
variant="text"
|
|
className="px-0.5 h-[20px] opacity-50 hover:opacity-100"
|
|
icon={<MoreVerticalIcon size={12} strokeWidth={2} />}
|
|
onClick={(e) => {
|
|
e.preventDefault()
|
|
e.stopPropagation()
|
|
}}
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="start" className="w-44 *:gap-x-2">
|
|
<DropdownMenuItem
|
|
onClick={(e) => {
|
|
e.preventDefault()
|
|
e.stopPropagation()
|
|
if (!item.id) return
|
|
onSelectEdit()
|
|
}}
|
|
>
|
|
<Edit2Icon size={12} />
|
|
<div>Rename report</div>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem
|
|
onClick={(e) => {
|
|
e.preventDefault()
|
|
e.stopPropagation()
|
|
if (!item.id) return
|
|
onSelectDelete()
|
|
}}
|
|
>
|
|
<TrashIcon size={12} />
|
|
<div>Delete report</div>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)}
|
|
</div>
|
|
</Menu.Item>
|
|
)
|
|
|
|
return (
|
|
<DynamicLink key={item.key + '-menukey'} href={item.url} className="block">
|
|
{menuItem}
|
|
</DynamicLink>
|
|
)
|
|
}
|