2024-01-24 15:03:54 +00:00
|
|
|
import React from "react";
|
2024-04-08 13:41:47 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-04-10 08:22:57 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { CalendarCheck2, CopyPlus, Signal, Tag } from "lucide-react";
|
|
|
|
import { TInboxDuplicateIssueDetails, TIssue } from "@plane/types";
|
|
|
|
import { ControlLink, DoubleCircleIcon, Tooltip, UserGroupIcon } from "@plane/ui";
|
2024-01-24 15:03:54 +00:00
|
|
|
// components
|
2024-03-19 14:38:35 +00:00
|
|
|
import { DateDropdown, PriorityDropdown, MemberDropdown, StateDropdown } from "@/components/dropdowns";
|
|
|
|
import { IssueLabel, TIssueOperations } from "@/components/issues";
|
2024-01-25 08:11:02 +00:00
|
|
|
// helper
|
2024-03-19 14:38:35 +00:00
|
|
|
import { getDate, renderFormattedPayloadDate } from "@/helpers/date-time.helper";
|
2024-04-10 08:22:57 +00:00
|
|
|
// hooks
|
|
|
|
import { useProject } from "@/hooks/store";
|
2024-01-24 15:03:54 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
2024-04-08 13:41:47 +00:00
|
|
|
issue: Partial<TIssue>;
|
2024-01-24 15:03:54 +00:00
|
|
|
issueOperations: TIssueOperations;
|
2024-04-10 10:38:31 +00:00
|
|
|
isEditable: boolean;
|
2024-04-10 08:22:57 +00:00
|
|
|
duplicateIssueDetails: TInboxDuplicateIssueDetails | undefined;
|
2024-01-24 15:03:54 +00:00
|
|
|
};
|
|
|
|
|
2024-04-15 07:19:14 +00:00
|
|
|
export const InboxIssueContentProperties: React.FC<Props> = observer((props) => {
|
2024-04-10 10:38:31 +00:00
|
|
|
const { workspaceSlug, projectId, issue, issueOperations, isEditable, duplicateIssueDetails } = props;
|
2024-04-10 08:22:57 +00:00
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
// store hooks
|
|
|
|
const { currentProjectDetails } = useProject();
|
2024-01-24 15:03:54 +00:00
|
|
|
|
2024-03-19 12:10:20 +00:00
|
|
|
const minDate = issue.start_date ? getDate(issue.start_date) : null;
|
2024-01-24 15:03:54 +00:00
|
|
|
minDate?.setDate(minDate.getDate());
|
2024-04-08 13:41:47 +00:00
|
|
|
if (!issue || !issue?.id) return <></>;
|
2024-05-02 15:09:43 +00:00
|
|
|
|
2024-01-24 15:03:54 +00:00
|
|
|
return (
|
2024-04-08 13:41:47 +00:00
|
|
|
<div className="flex h-min w-full flex-col divide-y-2 divide-custom-border-200 overflow-hidden">
|
2024-05-01 12:31:30 +00:00
|
|
|
<div className="h-min w-full overflow-y-auto px-3">
|
2024-01-25 08:11:02 +00:00
|
|
|
<h5 className="text-sm font-medium my-4">Properties</h5>
|
2024-04-10 10:38:31 +00:00
|
|
|
<div className={`divide-y-2 divide-custom-border-200 ${!isEditable ? "opacity-60" : ""}`}>
|
2024-01-25 08:11:02 +00:00
|
|
|
<div className="flex flex-col gap-3">
|
2024-01-24 15:03:54 +00:00
|
|
|
{/* State */}
|
2024-01-25 08:11:02 +00:00
|
|
|
<div className="flex items-center gap-2 h-8">
|
|
|
|
<div className="flex items-center gap-1 w-2/5 flex-shrink-0 text-sm text-custom-text-300">
|
2024-01-24 15:03:54 +00:00
|
|
|
<DoubleCircleIcon className="h-4 w-4 flex-shrink-0" />
|
2024-01-25 08:11:02 +00:00
|
|
|
<span>State</span>
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
2024-04-08 13:41:47 +00:00
|
|
|
{issue?.state_id && (
|
|
|
|
<StateDropdown
|
|
|
|
value={issue?.state_id}
|
|
|
|
onChange={(val) =>
|
|
|
|
issue?.id && issueOperations.update(workspaceSlug, projectId, issue?.id, { state_id: val })
|
|
|
|
}
|
|
|
|
projectId={projectId?.toString() ?? ""}
|
2024-04-10 10:38:31 +00:00
|
|
|
disabled={!isEditable}
|
2024-04-08 13:41:47 +00:00
|
|
|
buttonVariant="transparent-with-text"
|
|
|
|
className="w-3/5 flex-grow group"
|
|
|
|
buttonContainerClassName="w-full text-left"
|
|
|
|
buttonClassName="text-sm"
|
|
|
|
dropdownArrow
|
|
|
|
dropdownArrowClassName="h-3.5 w-3.5 hidden group-hover:inline"
|
|
|
|
/>
|
|
|
|
)}
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
|
|
|
{/* Assignee */}
|
2024-01-25 08:11:02 +00:00
|
|
|
<div className="flex items-center gap-2 h-8">
|
|
|
|
<div className="flex items-center gap-1 w-2/5 flex-shrink-0 text-sm text-custom-text-300">
|
2024-01-24 15:03:54 +00:00
|
|
|
<UserGroupIcon className="h-4 w-4 flex-shrink-0" />
|
2024-01-25 08:11:02 +00:00
|
|
|
<span>Assignees</span>
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
2024-02-28 09:48:11 +00:00
|
|
|
<MemberDropdown
|
2024-04-08 13:41:47 +00:00
|
|
|
value={issue?.assignee_ids ?? []}
|
|
|
|
onChange={(val) =>
|
|
|
|
issue?.id && issueOperations.update(workspaceSlug, projectId, issue?.id, { assignee_ids: val })
|
|
|
|
}
|
2024-04-10 10:38:31 +00:00
|
|
|
disabled={!isEditable}
|
2024-01-25 08:11:02 +00:00
|
|
|
projectId={projectId?.toString() ?? ""}
|
|
|
|
placeholder="Add assignees"
|
|
|
|
multiple
|
2024-04-08 13:41:47 +00:00
|
|
|
buttonVariant={
|
|
|
|
(issue?.assignee_ids || [])?.length > 0 ? "transparent-without-text" : "transparent-with-text"
|
|
|
|
}
|
2024-01-25 08:11:02 +00:00
|
|
|
className="w-3/5 flex-grow group"
|
|
|
|
buttonContainerClassName="w-full text-left"
|
|
|
|
buttonClassName={`text-sm justify-between ${
|
2024-04-08 13:41:47 +00:00
|
|
|
(issue?.assignee_ids || [])?.length > 0 ? "" : "text-custom-text-400"
|
2024-01-25 08:11:02 +00:00
|
|
|
}`}
|
|
|
|
hideIcon={issue.assignee_ids?.length === 0}
|
|
|
|
dropdownArrow
|
|
|
|
dropdownArrowClassName="h-3.5 w-3.5 hidden group-hover:inline"
|
|
|
|
/>
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
|
|
|
{/* Priority */}
|
2024-01-25 08:11:02 +00:00
|
|
|
<div className="flex items-center gap-2 h-8">
|
|
|
|
<div className="flex items-center gap-1 w-2/5 flex-shrink-0 text-sm text-custom-text-300">
|
2024-01-24 15:03:54 +00:00
|
|
|
<Signal className="h-4 w-4 flex-shrink-0" />
|
2024-01-25 08:11:02 +00:00
|
|
|
<span>Priority</span>
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
2024-01-25 08:11:02 +00:00
|
|
|
<PriorityDropdown
|
2024-04-08 13:41:47 +00:00
|
|
|
value={issue?.priority || "none"}
|
|
|
|
onChange={(val) =>
|
|
|
|
issue?.id && issueOperations.update(workspaceSlug, projectId, issue?.id, { priority: val })
|
|
|
|
}
|
2024-04-10 10:38:31 +00:00
|
|
|
disabled={!isEditable}
|
2024-01-25 08:11:02 +00:00
|
|
|
buttonVariant="border-with-text"
|
|
|
|
className="w-3/5 flex-grow rounded px-2 hover:bg-custom-background-80"
|
|
|
|
buttonContainerClassName="w-full text-left"
|
|
|
|
buttonClassName="w-min h-auto whitespace-nowrap"
|
|
|
|
/>
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-10 10:38:31 +00:00
|
|
|
<div className={`divide-y-2 divide-custom-border-200 mt-3 ${!isEditable ? "opacity-60" : ""}`}>
|
2024-01-25 08:11:02 +00:00
|
|
|
<div className="flex flex-col gap-3">
|
2024-01-24 15:03:54 +00:00
|
|
|
{/* Due Date */}
|
2024-01-25 08:11:02 +00:00
|
|
|
<div className="flex items-center gap-2 h-8">
|
|
|
|
<div className="flex items-center gap-1 w-2/5 flex-shrink-0 text-sm text-custom-text-300">
|
|
|
|
<CalendarCheck2 className="h-4 w-4 flex-shrink-0" />
|
|
|
|
<span>Due date</span>
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
2024-01-25 08:11:02 +00:00
|
|
|
<DateDropdown
|
|
|
|
placeholder="Add due date"
|
2024-04-08 13:41:47 +00:00
|
|
|
value={issue.target_date || null}
|
2024-01-25 08:11:02 +00:00
|
|
|
onChange={(val) =>
|
2024-04-08 13:41:47 +00:00
|
|
|
issue?.id &&
|
|
|
|
issueOperations.update(workspaceSlug, projectId, issue?.id, {
|
2024-01-25 08:11:02 +00:00
|
|
|
target_date: val ? renderFormattedPayloadDate(val) : null,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
minDate={minDate ?? undefined}
|
2024-04-10 10:38:31 +00:00
|
|
|
disabled={!isEditable}
|
2024-01-25 08:11:02 +00:00
|
|
|
buttonVariant="transparent-with-text"
|
|
|
|
className="w-3/5 flex-grow group"
|
|
|
|
buttonContainerClassName="w-full text-left"
|
|
|
|
buttonClassName={`text-sm ${issue?.target_date ? "" : "text-custom-text-400"}`}
|
|
|
|
hideIcon
|
|
|
|
clearIconClassName="h-3 w-3 hidden group-hover:inline"
|
|
|
|
/>
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
|
|
|
{/* Labels */}
|
2024-01-25 08:11:02 +00:00
|
|
|
<div className="flex items-center gap-2 min-h-8">
|
|
|
|
<div className="flex items-center gap-1 w-2/5 flex-shrink-0 text-sm text-custom-text-300">
|
2024-01-24 15:03:54 +00:00
|
|
|
<Tag className="h-4 w-4 flex-shrink-0" />
|
2024-01-25 08:11:02 +00:00
|
|
|
<span>Labels</span>
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
2024-01-25 08:11:02 +00:00
|
|
|
<div className="w-3/5 flex-grow min-h-8 h-full pt-1">
|
2024-04-08 13:41:47 +00:00
|
|
|
{issue?.id && (
|
|
|
|
<IssueLabel
|
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
projectId={projectId}
|
|
|
|
issueId={issue?.id}
|
2024-04-10 10:38:31 +00:00
|
|
|
disabled={!isEditable}
|
2024-04-08 13:41:47 +00:00
|
|
|
isInboxIssue
|
|
|
|
onLabelUpdate={(val: string[]) =>
|
|
|
|
issue?.id && issueOperations.update(workspaceSlug, projectId, issue?.id, { label_ids: val })
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-10 08:22:57 +00:00
|
|
|
|
|
|
|
{/* duplicate to*/}
|
|
|
|
{duplicateIssueDetails && (
|
|
|
|
<div className="flex min-h-8 gap-2">
|
|
|
|
<div className="flex w-2/5 flex-shrink-0 gap-1 pt-2 text-sm text-custom-text-300">
|
|
|
|
<CopyPlus className="h-4 w-4 flex-shrink-0" />
|
|
|
|
<span>Duplicate of</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ControlLink
|
|
|
|
href={`/${workspaceSlug}/projects/${projectId}/issues/${duplicateIssueDetails?.id}`}
|
|
|
|
onClick={() => {
|
|
|
|
router.push(`/${workspaceSlug}/projects/${projectId}/issues/${duplicateIssueDetails?.id}`);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Tooltip tooltipContent={`${duplicateIssueDetails?.name}`}>
|
|
|
|
<span className="flex items-center gap-1 cursor-pointer text-xs rounded px-1.5 py-1 pb-0.5 bg-custom-background-80 text-custom-text-200">
|
|
|
|
{`${currentProjectDetails?.identifier}-${duplicateIssueDetails?.sequence_id}`}
|
|
|
|
</span>
|
|
|
|
</Tooltip>
|
|
|
|
</ControlLink>
|
|
|
|
</div>
|
|
|
|
)}
|
2024-01-24 15:03:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|