import { useState } from "react"; import { observer } from "mobx-react"; import { ArchiveRestoreIcon, ExternalLink, Link, Lock, Trash2, UsersRound } from "lucide-react"; import { ArchiveIcon, CustomMenu, TOAST_TYPE, setToast } from "@plane/ui"; // components import { DeletePageModal } from "@/components/pages"; // helpers import { copyUrlToClipboard } from "@/helpers/string.helper"; // hooks import { usePage } from "@/hooks/store"; type Props = { pageId: string; projectId: string; workspaceSlug: string; }; export const PageQuickActions: React.FC = observer((props) => { const { pageId, projectId, workspaceSlug } = props; // states const [deletePageModal, setDeletePageModal] = useState(false); // store hooks const { access, archive, archived_at, makePublic, makePrivate, restore } = usePage(pageId); const pageLink = `${workspaceSlug}/projects/${projectId}/pages/${pageId}`; const handleCopyText = () => copyUrlToClipboard(pageLink).then(() => { setToast({ type: TOAST_TYPE.SUCCESS, title: "Link Copied!", message: "Page link copied to clipboard.", }); }); const handleOpenInNewTab = () => window.open(`/${pageLink}`, "_blank"); return ( <> setDeletePageModal(false)} pageId={pageId} projectId={projectId} /> { e.preventDefault(); e.stopPropagation(); handleCopyText(); }} > Copy link { e.preventDefault(); e.stopPropagation(); handleOpenInNewTab(); }} > Open in new tab { e.preventDefault(); e.stopPropagation(); if (archived_at) restore(); else archive(); }} > {archived_at ? ( <> Restore ) : ( <> Archive )} {!archived_at && ( { e.preventDefault(); e.stopPropagation(); access === 0 ? makePrivate() : makePublic(); }} > {access === 0 ? ( <> Make private ) : ( <> Make public )} )} {archived_at && ( { e.preventDefault(); e.stopPropagation(); setDeletePageModal(true); }} > Delete )} ); });