import { FC, useState } from "react"; import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import { CalendarDays, Link2, Plus, Signal, Tag, Triangle, LayoutPanelTop } from "lucide-react"; // hooks import { useIssueDetail, useProject, useUser } from "hooks/store"; // ui icons import { DiceIcon, DoubleCircleIcon, UserGroupIcon, ContrastIcon } from "@plane/ui"; import { IssueLinkRoot, SidebarCycleSelect, SidebarLabelSelect, SidebarModuleSelect, SidebarParentSelect, } from "components/issues"; import { EstimateDropdown, PriorityDropdown, ProjectMemberDropdown, StateDropdown } from "components/dropdowns"; // components import { CustomDatePicker } from "components/ui"; import { LinkModal } from "components/core"; // types import { TIssue, TIssuePriorities, ILinkDetails, IIssueLink } from "@plane/types"; // constants import { EUserProjectRoles } from "constants/project"; interface IPeekOverviewProperties { issue: TIssue; issueUpdate: (issue: Partial) => void; issueLinkCreate: (data: IIssueLink) => Promise; issueLinkUpdate: (data: IIssueLink, linkId: string) => Promise; issueLinkDelete: (linkId: string) => Promise; disableUserActions: boolean; } export const PeekOverviewProperties: FC = observer((props) => { const { issue, issueUpdate, issueLinkCreate, issueLinkUpdate, issueLinkDelete, disableUserActions } = props; // states const [selectedLinkToUpdate, setSelectedLinkToUpdate] = useState(null); // store hooks const { membership: { currentProjectRole }, } = useUser(); const { fetchIssue, isIssueLinkModalOpen, toggleIssueLinkModal } = useIssueDetail(); const { getProjectById } = useProject(); // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; const uneditable = currentProjectRole ? [5, 10].includes(currentProjectRole) : false; const isAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; const handleState = (_state: string) => { issueUpdate({ ...issue, state_id: _state }); }; const handlePriority = (_priority: TIssuePriorities) => { issueUpdate({ ...issue, priority: _priority }); }; const handleAssignee = (_assignees: string[]) => { issueUpdate({ ...issue, assignee_ids: _assignees }); }; const handleEstimate = (_estimate: number | null) => { issueUpdate({ ...issue, estimate_point: _estimate }); }; const handleStartDate = (_startDate: string | null) => { issueUpdate({ ...issue, start_date: _startDate || undefined }); }; const handleTargetDate = (_targetDate: string | null) => { issueUpdate({ ...issue, target_date: _targetDate || undefined }); }; const handleParent = (_parent: string) => { issueUpdate({ ...issue, parent_id: _parent }); }; const handleLabels = (formData: Partial) => { issueUpdate({ ...issue, ...formData }); }; const handleCycleOrModuleChange = async () => { if (!workspaceSlug || !projectId) return; await fetchIssue(workspaceSlug.toString(), projectId.toString(), issue.id); }; const handleEditLink = (link: ILinkDetails) => { setSelectedLinkToUpdate(link); toggleIssueLinkModal(true); }; const projectDetails = getProjectById(issue.project_id); const isEstimateEnabled = projectDetails?.estimate; const minDate = issue.start_date ? new Date(issue.start_date) : null; minDate?.setDate(minDate.getDate()); const maxDate = issue.target_date ? new Date(issue.target_date) : null; maxDate?.setDate(maxDate.getDate()); return ( <> { toggleIssueLinkModal(false); setSelectedLinkToUpdate(null); }} data={selectedLinkToUpdate} status={selectedLinkToUpdate ? true : false} createIssueLink={issueLinkCreate} updateIssueLink={issueLinkUpdate} />
{/* state */}

State

{/* assignee */}

Assignees

0 ? "transparent-without-text" : "background-with-text"} buttonClassName={issue.assignee_ids?.length > 0 ? "hover:bg-transparent px-0" : ""} />
{/* priority */}

Priority

{/* estimate */} {isEstimateEnabled && (

Estimate

)} {/* start date */}

Start date

{/* due date */}

Due date

{/* parent */}

Parent

{projectDetails?.cycle_view && (

Cycle

)} {projectDetails?.module_view && (

Module

)}

Label

); });