import { FC } from "react"; import { observer } from "mobx-react-lite"; import { differenceInCalendarDays } from "date-fns"; import { Signal, Tag, Triangle, LayoutPanelTop, CircleDot, CopyPlus, XCircle, CalendarDays } from "lucide-react"; // hooks import { useIssueDetail, useProject } from "hooks/store"; // ui icons import { DiceIcon, DoubleCircleIcon, UserGroupIcon, ContrastIcon, RelatedIcon } from "@plane/ui"; import { IssueLinkRoot, IssueCycleSelect, IssueModuleSelect, IssueParentSelect, IssueLabel, TIssueOperations, IssueRelationSelect, } from "components/issues"; import { DateDropdown, EstimateDropdown, PriorityDropdown, ProjectMemberDropdown, StateDropdown, } from "components/dropdowns"; // components import { renderFormattedPayloadDate } from "helpers/date-time.helper"; // helpers import { cn } from "helpers/common.helper"; interface IPeekOverviewProperties { workspaceSlug: string; projectId: string; issueId: string; disabled: boolean; issueOperations: TIssueOperations; } export const PeekOverviewProperties: FC = observer((props) => { const { workspaceSlug, projectId, issueId, issueOperations, disabled } = props; // store hooks const { getProjectById } = useProject(); const { issue: { getIssueById }, } = useIssueDetail(); // derived values const issue = getIssueById(issueId); if (!issue) return <>; 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()); const targetDateDistance = issue.target_date ? differenceInCalendarDays(new Date(issue.target_date), new Date()) : 1; return (
Properties
{/* TODO: render properties using a common component */}
{/* state */}
State
issueOperations.update(workspaceSlug, projectId, issueId, { state_id: val })} projectId={projectId} disabled={disabled} buttonVariant="transparent-with-text" className="w-3/4 flex-grow group" buttonContainerClassName="w-full text-left" buttonClassName="text-sm" dropdownArrow dropdownArrowClassName="h-3.5 w-3.5 hidden group-hover:inline" />
{/* assignee */}
Assignees
issueOperations.update(workspaceSlug, projectId, issueId, { assignee_ids: val })} disabled={disabled} projectId={projectId} placeholder="Add assignees" multiple buttonVariant={issue?.assignee_ids?.length > 1 ? "transparent-without-text" : "transparent-with-text"} className="w-3/4 flex-grow group" buttonContainerClassName="w-full text-left" buttonClassName={`text-sm justify-between ${issue?.assignee_ids?.length > 0 ? "" : "text-custom-text-400"}`} hideIcon={issue.assignee_ids?.length === 0} dropdownArrow dropdownArrowClassName="h-3.5 w-3.5 hidden group-hover:inline" />
{/* priority */}
Priority
issueOperations.update(workspaceSlug, projectId, issueId, { priority: val })} disabled={disabled} buttonVariant="border-with-text" className="w-3/4 flex-grow rounded px-2 hover:bg-custom-background-80 group" buttonContainerClassName="w-full text-left" buttonClassName="w-min h-auto whitespace-nowrap" />
{/* start date */}
Start date
issueOperations.update(workspaceSlug, projectId, issueId, { start_date: val ? renderFormattedPayloadDate(val) : null, }) } placeholder="Add start date" buttonVariant="transparent-with-text" maxDate={maxDate ?? undefined} disabled={disabled} className="w-3/4 flex-grow group" buttonContainerClassName="w-full text-left" buttonClassName={`text-sm ${issue?.start_date ? "" : "text-custom-text-400"}`} hideIcon clearIconClassName="h-3 w-3 hidden group-hover:inline" // TODO: add this logic // showPlaceholderIcon />
{/* due date */}
Due date
issueOperations.update(workspaceSlug, projectId, issueId, { target_date: val ? renderFormattedPayloadDate(val) : null, }) } placeholder="Add due date" buttonVariant="transparent-with-text" minDate={minDate ?? undefined} disabled={disabled} className="w-3/4 flex-grow group" buttonContainerClassName="w-full text-left" buttonClassName={cn("text-sm", { "text-custom-text-400": !issue.target_date, "text-red-500": targetDateDistance <= 0, })} hideIcon clearIconClassName="h-3 w-3 hidden group-hover:inline !text-custom-text-100" // TODO: add this logic // showPlaceholderIcon />
{/* estimate */} {isEstimateEnabled && (
Estimate
issueOperations.update(workspaceSlug, projectId, issueId, { estimate_point: val })} projectId={projectId} disabled={disabled} buttonVariant="transparent-with-text" className="w-3/4 flex-grow group" buttonContainerClassName="w-full text-left" buttonClassName={`text-sm ${issue?.estimate_point !== null ? "" : "text-custom-text-400"}`} placeholder="None" hideIcon dropdownArrow dropdownArrowClassName="h-3.5 w-3.5 hidden group-hover:inline" />
)} {projectDetails?.module_view && (
Module
)} {projectDetails?.cycle_view && (
Cycle
)} {/* parent */}

Parent

{/* relates to */}
Relates to
{/* blocking */}
Blocking
{/* blocked by */}
Blocked by
{/* duplicate of */}
Duplicate of
{/* label */}
Labels
); });