import { useState } from "react"; import { useRouter } from "next/router"; import { CustomMenu } from "@plane/ui"; import { ExternalLink, Link, RotateCcw, Trash2 } from "lucide-react"; // hooks import useToast from "hooks/use-toast"; import { useEventTracker, useIssues, useUser } from "hooks/store"; // components import { DeleteIssueModal } from "components/issues"; // helpers import { copyUrlToClipboard } from "helpers/string.helper"; // types import { IQuickActionProps } from "../list/list-view-types"; import { EUserProjectRoles } from "constants/project"; import { EIssuesStoreType } from "constants/issue"; export const ArchivedIssueQuickActions: React.FC = (props) => { const { issue, handleDelete, handleRestore, customActionButton, portalElement, readOnly = false } = props; // states const [deleteIssueModal, setDeleteIssueModal] = useState(false); // router const router = useRouter(); const { workspaceSlug } = router.query; // store hooks const { membership: { currentProjectRole }, } = useUser(); const { setTrackElement } = useEventTracker(); const { issuesFilter } = useIssues(EIssuesStoreType.ARCHIVED); // derived values const activeLayout = `${issuesFilter.issueFilters?.displayFilters?.layout} layout`; // auth const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER && !readOnly; const isRestoringAllowed = handleRestore && isEditingAllowed; // toast alert const { setToastAlert } = useToast(); const issueLink = `${workspaceSlug}/projects/${issue.project_id}/archived-issues/${issue.id}`; const handleOpenInNewTab = () => window.open(`/${issueLink}`, "_blank"); const handleCopyIssueLink = () => copyUrlToClipboard(issueLink).then(() => setToastAlert({ type: "success", title: "Link copied", message: "Issue link copied to clipboard", }) ); return ( <> setDeleteIssueModal(false)} onSubmit={handleDelete} /> {isRestoringAllowed && (
Restore
)}
Open in new tab
Copy link
{isEditingAllowed && ( { setTrackElement(activeLayout); setDeleteIssueModal(true); }} >
Delete issue
)}
); };