import { MutableRefObject, memo } from "react"; import { Draggable, DraggableProvided, DraggableStateSnapshot } from "@hello-pangea/dnd"; import { observer } from "mobx-react-lite"; // hooks import { Tooltip, ControlLink } from "@plane/ui"; import RenderIfVisible from "components/core/render-if-visible-HOC"; import { cn } from "helpers/common.helper"; import { useApplication, useIssueDetail, useProject } from "hooks/store"; import { usePlatformOS } from "hooks/use-platform-os"; // components import { TIssue, IIssueDisplayProperties, IIssueMap } from "@plane/types"; import { IssueProperties } from "../properties/all-properties"; import { WithDisplayPropertiesHOC } from "../properties/with-display-properties-HOC"; // ui // types // helper interface IssueBlockProps { peekIssueId?: string; issueId: string; issuesMap: IIssueMap; displayProperties: IIssueDisplayProperties | undefined; isDragDisabled: boolean; draggableId: string; index: number; updateIssue: ((projectId: string, issueId: string, data: Partial) => Promise) | undefined; quickActions: (issue: TIssue) => React.ReactNode; canEditProperties: (projectId: string | undefined) => boolean; scrollableContainerRef?: MutableRefObject; isDragStarted?: boolean; issueIds: string[]; //DO NOT REMOVE< needed to force render for virtualization } interface IssueDetailsBlockProps { issue: TIssue; displayProperties: IIssueDisplayProperties | undefined; updateIssue: ((projectId: string, issueId: string, data: Partial) => Promise) | undefined; quickActions: (issue: TIssue) => React.ReactNode; isReadOnly: boolean; } const KanbanIssueDetailsBlock: React.FC = observer((props: IssueDetailsBlockProps) => { const { issue, updateIssue, quickActions, isReadOnly, displayProperties } = props; // hooks const { isMobile } = usePlatformOS(); const { getProjectIdentifierById } = useProject(); const { router: { workspaceSlug }, } = useApplication(); const { setPeekIssue } = useIssueDetail(); const handleIssuePeekOverview = (issue: TIssue) => workspaceSlug && issue && issue.project_id && issue.id && setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id }); return ( <>
{getProjectIdentifierById(issue.project_id)}-{issue.sequence_id}
{quickActions(issue)}
{issue?.is_draft ? ( {issue.name} ) : ( handleIssuePeekOverview(issue)} className="w-full line-clamp-1 cursor-pointer text-sm text-custom-text-100" disabled={!!issue?.tempId} > {issue.name} )} ); }); export const KanbanIssueBlock: React.FC = memo((props) => { const { peekIssueId, issueId, issuesMap, displayProperties, isDragDisabled, draggableId, index, updateIssue, quickActions, canEditProperties, scrollableContainerRef, isDragStarted, issueIds, } = props; const issue = issuesMap[issueId]; if (!issue) return null; const canEditIssueProperties = canEditProperties(issue.project_id); return ( {(provided: DraggableProvided, snapshot: DraggableStateSnapshot) => (
)}
); }); KanbanIssueBlock.displayName = "KanbanIssueBlock";