import { useState } from "react"; import { useRouter } from "next/router"; import { CustomMenu } from "@plane/ui"; import { Copy, Link, Pencil, Trash2, XCircle } from "lucide-react"; // hooks import useToast from "hooks/use-toast"; // components import { CreateUpdateIssueModal, DeleteIssueModal } from "components/issues"; // helpers import { copyUrlToClipboard } from "helpers/string.helper"; // types import { IIssue } from "types"; import { IQuickActionProps } from "../list/list-view-types"; import { EProjectStore } from "store/command-palette.store"; export const CycleIssueQuickActions: React.FC = (props) => { const { issue, handleDelete, handleUpdate, handleRemoveFromView, customActionButton } = props; const router = useRouter(); const { workspaceSlug, cycleId } = router.query; // states const [createUpdateIssueModal, setCreateUpdateIssueModal] = useState(false); const [issueToEdit, setIssueToEdit] = useState(null); const [deleteIssueModal, setDeleteIssueModal] = useState(false); const { setToastAlert } = useToast(); const handleCopyIssueLink = () => { copyUrlToClipboard(`${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`).then(() => setToastAlert({ type: "success", title: "Link copied", message: "Issue link copied to clipboard", }) ); }; return ( <> setDeleteIssueModal(false)} onSubmit={handleDelete} /> { setCreateUpdateIssueModal(false); setIssueToEdit(null); }} // pre-populate date only if not editing prePopulateData={!issueToEdit && createUpdateIssueModal ? { ...issue, name: `${issue.name} (copy)` } : {}} data={issueToEdit} onSubmit={async (data) => { if (issueToEdit && handleUpdate) handleUpdate({ ...issueToEdit, ...data }); }} currentStore={EProjectStore.CYCLE} /> e.stopPropagation()} > { e.preventDefault(); e.stopPropagation(); handleCopyIssueLink(); }} >
Copy link
{ e.preventDefault(); e.stopPropagation(); setIssueToEdit({ ...issue, cycle: cycleId?.toString() ?? null, }); setCreateUpdateIssueModal(true); }} >
Edit issue
{ e.preventDefault(); e.stopPropagation(); handleRemoveFromView && handleRemoveFromView(); }} >
Remove from cycle
{ e.preventDefault(); e.stopPropagation(); setCreateUpdateIssueModal(true); }} >
Make a copy
{ e.preventDefault(); e.stopPropagation(); setDeleteIssueModal(true); }} >
Delete issue
); };