import { memo, useRef, useState } from "react"; import { Draggable } from "@hello-pangea/dnd"; // components import { KanBanProperties } from "./properties"; // ui import { Tooltip } from "@plane/ui"; // hooks import useOutsideClickDetector from "hooks/use-outside-click-detector"; // types import { IIssueDisplayProperties, IIssue } from "types"; import { EIssueActions } from "../types"; import { useRouter } from "next/router"; import { MoreHorizontal } from "lucide-react"; interface IssueBlockProps { sub_group_id: string; columnId: string; index: number; issue: IIssue; isDragDisabled: boolean; showEmptyGroup: boolean; handleIssues: (sub_group_by: string | null, group_by: string | null, issue: IIssue, action: EIssueActions) => void; quickActions: ( sub_group_by: string | null, group_by: string | null, issue: IIssue, customActionButton?: React.ReactElement ) => React.ReactNode; displayProperties: IIssueDisplayProperties | null; isReadOnly: boolean; } export const KanBanIssueMemoBlock: React.FC = (props) => { const { sub_group_id, columnId, index, issue, isDragDisabled, showEmptyGroup, handleIssues, quickActions, displayProperties, isReadOnly, } = props; // router const router = useRouter(); // states const [isMenuActive, setIsMenuActive] = useState(false); const menuActionRef = useRef(null); const updateIssue = (sub_group_by: string | null, group_by: string | null, issueToUpdate: IIssue) => { if (issueToUpdate) handleIssues(sub_group_by, group_by, issueToUpdate, EIssueActions.UPDATE); }; const handleIssuePeekOverview = () => { const { query } = router; router.push({ pathname: router.pathname, query: { ...query, peekIssueId: issue?.id, peekProjectId: issue?.project }, }); }; let draggableId = issue.id; if (columnId) draggableId = `${draggableId}__${columnId}`; if (sub_group_id) draggableId = `${draggableId}__${sub_group_id}`; useOutsideClickDetector(menuActionRef, () => setIsMenuActive(false)); const customActionButton = (
setIsMenuActive(!isMenuActive)} >
); return ( <> {(provided, snapshot) => (
{issue.tempId !== undefined && (
)}
{displayProperties && displayProperties?.key && (
{issue.project_detail.identifier}-{issue.sequence_id}
)}
{issue.name}
)} ); }; const validateMemo = (prevProps: IssueBlockProps, nextProps: IssueBlockProps) => { if (prevProps.issue != nextProps.issue) return true; return false; }; export const KanbanIssueBlock = memo(KanBanIssueMemoBlock, validateMemo);