mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Moves Explorer’s back navigation and create actions into a reusable sidebar breadcrumb header. Reduces product-menu headings globally to `text-sm` and keeps breadcrumb links free of padding, borders, and backgrounds. ### How to test 1. Open `/project/<ref>/explorer` and confirm the header shows Explorer and the SQL Editor switch action. 2. Open Notebooks and Chats. Confirm the header shows `Explorer > Notebooks/Chats` and the corresponding create action works. 3. Return using the Explorer breadcrumb with a click or Tab + Enter. Check that the label stays aligned and has no hover background. 4. Open another product, such as Database, and confirm its sidebar heading uses the smaller font size. 5. At a mobile viewport, open the menu and repeat the notebook/chat actions and back navigation without closing the sheet. Confirm the header stays current and disappears when returning to the main menu or opening another product. Validation: 18 focused tests, typecheck, formatting, and lint ratchet passed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a shared Explorer sidebar header with breadcrumbs and contextual actions for creating notebooks and chats. - Added keyboard-accessible navigation between the Explorer overview and notebook or chat sections. - Added support for customized product menu headers across project layouts. - **Improvements** - Centralized Explorer navigation and actions in the shared sidebar layout. - Improved mobile menu updates when navigating between Explorer resources. - Refined Explorer home layout and drag-handle behavior across screen sizes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { Plus } from 'lucide-react'
|
|
import type { ReactNode } from 'react'
|
|
|
|
import { EXPLORER_SECTIONS, type ExplorerResourceType } from './ExplorerLayout.constants'
|
|
import { useCreateChat, useCreateNotebook } from '@/components/interfaces/Explorer/hooks'
|
|
import { SidebarBreadcrumb } from '@/components/layouts/Navigation/SidebarBreadcrumb'
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
|
|
export const ExplorerNavHeader = ({
|
|
section,
|
|
onBack,
|
|
rootAction,
|
|
}: {
|
|
section: ExplorerResourceType | undefined
|
|
onBack: () => void
|
|
rootAction?: ReactNode
|
|
}) => {
|
|
const label = EXPLORER_SECTIONS.find((entry) => entry.type === section)?.label ?? 'Explorer'
|
|
|
|
return (
|
|
<SidebarBreadcrumb
|
|
aria-label="Explorer navigation"
|
|
label={label}
|
|
parent={section ? { label: 'Explorer', onClick: onBack } : undefined}
|
|
action={section ? <ExplorerResourceAction type={section} /> : rootAction}
|
|
/>
|
|
)
|
|
}
|
|
|
|
const ExplorerResourceAction = ({ type }: { type: ExplorerResourceType }) => {
|
|
const { createNotebook } = useCreateNotebook()
|
|
const { createChat } = useCreateChat()
|
|
|
|
return (
|
|
<ButtonTooltip
|
|
size="tiny"
|
|
variant="outline"
|
|
aria-label={`New ${type}`}
|
|
className="size-7 shrink-0 px-0"
|
|
icon={<Plus />}
|
|
tooltip={{ content: { side: 'bottom', text: `New ${type}` } }}
|
|
onClick={() => {
|
|
if (type === 'notebook') createNotebook()
|
|
if (type === 'chat') createChat()
|
|
}}
|
|
/>
|
|
)
|
|
}
|