import { ActionIcon, Group, Menu, Tooltip } from "@mantine/core"; import { IconArrowsHorizontal, IconDots, IconDownload, IconHistory, IconLink, IconMessage, IconPrinter, IconTrash, } from "@tabler/icons-react"; import React from "react"; import useToggleAside from "@/hooks/use-toggle-aside.tsx"; import { useAtom } from "jotai"; import { historyAtoms } from "@/features/page-history/atoms/history-atoms.ts"; import { useClipboard, useDisclosure } from "@mantine/hooks"; import { useParams } from "react-router-dom"; import { usePageQuery } from "@/features/page/queries/page-query.ts"; import { buildPageUrl } from "@/features/page/page.utils.ts"; import { notifications } from "@mantine/notifications"; import { getAppUrl } from "@/lib/config.ts"; import { extractPageSlugId } from "@/lib"; import { treeApiAtom } from "@/features/page/tree/atoms/tree-api-atom.ts"; import { useDeletePageModal } from "@/features/page/hooks/use-delete-page-modal.tsx"; import { PageWidthToggle } from "@/features/user/components/page-width-pref.tsx"; import PageExportModal from "@/features/page/components/page-export-modal.tsx"; import { useTranslation } from "react-i18next"; interface PageHeaderMenuProps { readOnly?: boolean; } export default function PageHeaderMenu({ readOnly }: PageHeaderMenuProps) { const toggleAside = useToggleAside(); return ( <> toggleAside("comments")} > ); } interface PageActionMenuProps { readOnly?: boolean; } function PageActionMenu({ readOnly }: PageActionMenuProps) { const { t } = useTranslation("translation", { keyPrefix: "page" }); const [, setHistoryModalOpen] = useAtom(historyAtoms); const clipboard = useClipboard({ timeout: 500 }); const { pageSlug, spaceSlug } = useParams(); const { data: page, isLoading } = usePageQuery({ pageId: extractPageSlugId(pageSlug), }); const { openDeleteModal } = useDeletePageModal(); const [tree] = useAtom(treeApiAtom); const [exportOpened, { open: openExportModal, close: closeExportModal }] = useDisclosure(false); const handleCopyLink = () => { const pageUrl = getAppUrl() + buildPageUrl(spaceSlug, page.slugId, page.title); clipboard.copy(pageUrl); notifications.show({ message: t("Link copied") }); }; const handlePrint = () => { setTimeout(() => { window.print(); }, 250); }; const openHistoryModal = () => { setHistoryModalOpen(true); }; const handleDeletePage = () => { openDeleteModal({ onConfirm: () => tree?.delete(page.id) }); }; return ( <> } onClick={handleCopyLink} > {t("Copy link")} }> } onClick={openHistoryModal} > {t("Page history")} } onClick={openExportModal} > {t("Export")} } onClick={handlePrint} > {t("Print PDF")} {!readOnly && ( <> } onClick={handleDeletePage} > {t("Delete")} )} ); }