import { Link, router } from '@inertiajs/react'; import { route } from '@izzyjs/route/client'; import { AppShell, Burger, Divider, Group, Kbd, NavLink, rem, ScrollArea, Text, } from '@mantine/core'; import { openSpotlight } from '@mantine/spotlight'; import { useTranslation } from 'react-i18next'; import { AiOutlineFolderAdd } from 'react-icons/ai'; import { IoIosSearch } from 'react-icons/io'; import { IoAdd, IoShieldHalfSharp } from 'react-icons/io5'; import { PiGearLight } from 'react-icons/pi'; import { UserCard } from '~/components/common/user_card'; import { FavoriteList } from '~/components/dashboard/favorite/favorite_list'; import { SearchSpotlight } from '~/components/search/search'; import { useActiveCollection } from '~/hooks/collections/use_active_collection'; import { useAuth } from '~/hooks/use_auth'; import useShortcut from '~/hooks/use_shortcut'; import { appendCollectionId } from '~/lib/navigation'; import { useGlobalHotkeysStore } from '~/stores/global_hotkeys_store'; interface DashboardNavbarProps { isOpen: boolean; toggle: () => void; } export function DashboardNavbar({ isOpen, toggle }: DashboardNavbarProps) { const { t } = useTranslation('common'); const { isAuthenticated, user } = useAuth(); const activeCollection = useActiveCollection(); const { globalHotkeysEnabled, setGlobalHotkeysEnabled } = useGlobalHotkeysStore(); const common = { variant: 'subtle', color: 'blue', active: true, styles: { label: { fontSize: rem(16), }, root: { borderRadius: rem(5), }, }, }; useShortcut( 'OPEN_CREATE_LINK_KEY', () => router.visit( appendCollectionId(route('link.create-form').url, activeCollection?.id) ), { enabled: globalHotkeysEnabled, } ); useShortcut( 'OPEN_CREATE_COLLECTION_KEY', () => router.visit(route('collection.create-form').url), { enabled: globalHotkeysEnabled, } ); useShortcut('OPEN_SEARCH_KEY', () => openSpotlight(), { enabled: globalHotkeysEnabled, }); const onSpotlightOpen = () => setGlobalHotkeysEnabled(false); const onSpotlightClose = () => setGlobalHotkeysEnabled(true); return ( Navigation {isAuthenticated && user.isAdmin && ( } color="var(--mantine-color-red-5)" /> )} } color="var(--mantine-color-text)" disabled /> <> {/* Search button */} } onClick={() => openSpotlight()} rightSection={S} /> {/* Search spotlight / modal */} } rightSection={C} /> } rightSection={L} /> ); }