/* eslint-disable react/display-name */ import { useState, useRef, forwardRef } from "react"; import { observer } from "mobx-react"; import { MoreHorizontal } from "lucide-react"; import { TIssue } from "@plane/types"; // components import { Tooltip, ControlLink } from "@plane/ui"; // hooks import { cn } from "@/helpers/common.helper"; import { useAppRouter, useIssueDetail, useProject, useProjectState } from "@/hooks/store"; import useOutsideClickDetector from "@/hooks/use-outside-click-detector"; // helpers // types import { usePlatformOS } from "@/hooks/use-platform-os"; import { TRenderQuickActions } from "../list/list-view-types"; type Props = { issue: TIssue; quickActions: TRenderQuickActions; isDragging?: boolean; }; export const CalendarIssueBlock = observer( forwardRef((props, ref) => { const { issue, quickActions, isDragging = false } = props; // states const [isMenuActive, setIsMenuActive] = useState(false); // refs const blockRef = useRef(null); const menuActionRef = useRef(null); // hooks const { workspaceSlug, projectId } = useAppRouter(); const { getProjectIdentifierById } = useProject(); const { getProjectStates } = useProjectState(); const { getIsIssuePeeked, setPeekIssue } = useIssueDetail(); const { isMobile } = usePlatformOS(); const stateColor = getProjectStates(issue?.project_id)?.find((state) => state?.id == issue?.state_id)?.color || ""; const handleIssuePeekOverview = (issue: TIssue) => workspaceSlug && issue && issue.project_id && issue.id && !getIsIssuePeeked(issue.id) && setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id }); useOutsideClickDetector(menuActionRef, () => setIsMenuActive(false)); const customActionButton = (
setIsMenuActive(!isMenuActive)} >
); const isMenuActionRefAboveScreenBottom = menuActionRef?.current && menuActionRef?.current?.getBoundingClientRect().bottom < window.innerHeight - 220; const placement = isMenuActionRefAboveScreenBottom ? "bottom-end" : "top-end"; return ( handleIssuePeekOverview(issue)} className="block w-full text-sm text-custom-text-100 rounded border-b md:border-[1px] border-custom-border-200 hover:border-custom-border-400" disabled={!!issue?.tempId || isMobile} ref={ref} > <> {issue?.tempId !== undefined && (
)}
{getProjectIdentifierById(issue?.project_id)}-{issue.sequence_id}
{issue.name}
{ e.preventDefault(); e.stopPropagation(); }} > {quickActions({ issue, parentRef: blockRef, customActionButton, placement, })}
); }) ); CalendarIssueBlock.displayName = "CalendarIssueBlock";