import { ActionIcon, Badge, Box, Group, Text, Tooltip, UnstyledButton, } from "@mantine/core"; import classes from "./app-header.module.css"; import React from "react"; import TopMenu from "@/components/layouts/global/top-menu.tsx"; import { Link, useLocation } from "react-router-dom"; import { IconSparkles } from "@tabler/icons-react"; import useToggleAside from "@/hooks/use-toggle-aside.tsx"; import APP_ROUTE from "@/lib/app-route.ts"; import { useAtom } from "jotai"; import { desktopSidebarAtom, mobileSidebarAtom, } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts"; import { useToggleSidebar } from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar.ts"; import SidebarToggle from "@/components/ui/sidebar-toggle-button.tsx"; import { useTranslation } from "react-i18next"; import useTrial from "@/ee/hooks/use-trial.tsx"; import { isCloud } from "@/lib/config.ts"; import { SearchControl, SearchMobileControl, } from "@/features/search/components/search-control.tsx"; import { searchSpotlight, shareSearchSpotlight, } from "@/features/search/constants.ts"; import { NotificationPopover } from "@/features/notification/components/notification-popover.tsx"; import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts"; const links = [ { link: APP_ROUTE.HOME, label: "Home" }, ]; export function AppHeader() { const { t } = useTranslation(); const [mobileOpened] = useAtom(mobileSidebarAtom); const toggleMobile = useToggleSidebar(mobileSidebarAtom); const [desktopOpened] = useAtom(desktopSidebarAtom); const toggleDesktop = useToggleSidebar(desktopSidebarAtom); const { isTrial, trialDaysLeft } = useTrial(); const location = useLocation(); const toggleAside = useToggleAside(); const [workspace] = useAtom(workspaceAtom); const aiChatEnabled = workspace?.settings?.ai?.chat === true; const isPageRoute = location.pathname.includes("/p/"); const items = links.map((link) => ( {t(link.label)} )); return ( <> Docmost Docmost {items}
{aiChatEnabled && ( <> { if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) { return; } if (isPageRoute) { e.preventDefault(); toggleAside("chat"); } }} > {t("AI Chat")} { if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) { return; } if (isPageRoute) { e.preventDefault(); toggleAside("chat"); } }} > )} {isCloud() && isTrial && trialDaysLeft !== 0 && ( {trialDaysLeft === 1 ? "1 day left" : `${trialDaysLeft} days left`} )}
); }