2023-09-01 11:12:30 +00:00
|
|
|
// hooks
|
|
|
|
import useToast from "hooks/use-toast";
|
2023-11-07 10:45:34 +00:00
|
|
|
// ui
|
|
|
|
import { StateGroupIcon } from "@plane/ui";
|
2023-09-01 11:12:30 +00:00
|
|
|
// icons
|
|
|
|
import { Icon } from "components/ui";
|
2023-09-04 09:17:28 +00:00
|
|
|
// helpers
|
2023-09-07 07:23:49 +00:00
|
|
|
import { copyTextToClipboard, addSpaceIfCamelCase } from "helpers/string.helper";
|
|
|
|
import { renderFullDate } from "helpers/date-time.helper";
|
|
|
|
import { dueDateIconDetails } from "../board-views/block-due-date";
|
2023-09-01 11:12:30 +00:00
|
|
|
// types
|
|
|
|
import { IIssue } from "types/issue";
|
2023-09-04 09:17:28 +00:00
|
|
|
import { IPeekMode } from "store/issue_details";
|
2023-09-01 11:12:30 +00:00
|
|
|
// constants
|
|
|
|
import { issueGroupFilter, issuePriorityFilter } from "constants/data";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
issueDetails: IIssue;
|
|
|
|
mode?: IPeekMode;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const PeekOverviewIssueProperties: React.FC<Props> = ({ issueDetails, mode }) => {
|
|
|
|
const { setToastAlert } = useToast();
|
|
|
|
|
|
|
|
const state = issueDetails.state_detail;
|
|
|
|
const stateGroup = issueGroupFilter(state.group);
|
|
|
|
|
|
|
|
const priority = issueDetails.priority ? issuePriorityFilter(issueDetails.priority) : null;
|
|
|
|
|
2023-09-07 07:23:49 +00:00
|
|
|
const dueDateIcon = dueDateIconDetails(issueDetails.target_date, state.group);
|
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
const handleCopyLink = () => {
|
2023-09-04 09:17:28 +00:00
|
|
|
const urlToCopy = window.location.href;
|
2023-09-01 11:12:30 +00:00
|
|
|
|
2023-09-04 09:17:28 +00:00
|
|
|
copyTextToClipboard(urlToCopy).then(() => {
|
2023-09-01 11:12:30 +00:00
|
|
|
setToastAlert({
|
|
|
|
type: "success",
|
|
|
|
title: "Link copied!",
|
|
|
|
message: "Issue link copied to clipboard",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2024-01-29 08:17:56 +00:00
|
|
|
<div className={mode === "full" ? "divide-y divide-neutral-border-medium" : ""}>
|
2023-09-01 11:12:30 +00:00
|
|
|
{mode === "full" && (
|
|
|
|
<div className="flex justify-between gap-2 pb-3">
|
|
|
|
<h6 className="flex items-center gap-2 font-medium">
|
|
|
|
{issueDetails.project_detail.identifier}-{issueDetails.sequence_id}
|
|
|
|
</h6>
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<button type="button" onClick={handleCopyLink} className="-rotate-45">
|
|
|
|
<Icon iconName="link" />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className={`space-y-4 ${mode === "full" ? "pt-3" : ""}`}>
|
|
|
|
<div className="flex items-center gap-2 text-sm">
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex w-1/4 flex-shrink-0 items-center gap-2 font-medium">
|
|
|
|
<Icon iconName="radio_button_checked" className="flex-shrink-0 !text-base" />
|
2023-09-01 11:12:30 +00:00
|
|
|
<span className="flex-grow truncate">State</span>
|
|
|
|
</div>
|
|
|
|
<div className="w-3/4">
|
|
|
|
{stateGroup && (
|
2024-01-30 06:46:21 +00:00
|
|
|
<div className="inline-flex rounded bg-neutral-component-surface-dark px-2.5 py-0.5 text-sm">
|
2024-02-08 12:53:13 +00:00
|
|
|
<div className="flex items-center gap-1.5 text-left text-neutral-text-strong">
|
2023-11-07 10:45:34 +00:00
|
|
|
<StateGroupIcon stateGroup={state.group} color={state.color} />
|
2023-09-01 11:12:30 +00:00
|
|
|
{addSpaceIfCamelCase(state?.name ?? "")}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2 text-sm">
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex w-1/4 flex-shrink-0 items-center gap-2 font-medium">
|
|
|
|
<Icon iconName="signal_cellular_alt" className="flex-shrink-0 !text-base" />
|
2023-09-01 11:12:30 +00:00
|
|
|
<span className="flex-grow truncate">Priority</span>
|
|
|
|
</div>
|
|
|
|
<div className="w-3/4">
|
|
|
|
<div
|
2023-12-10 10:18:10 +00:00
|
|
|
className={`inline-flex items-center gap-1.5 rounded px-2.5 py-0.5 text-left text-sm capitalize ${
|
2023-09-01 11:12:30 +00:00
|
|
|
priority?.key === "urgent"
|
2024-02-08 14:35:52 +00:00
|
|
|
? "border-red-500/20 bg-danger-component-surface-dark text-danger-text-medium"
|
2023-09-01 11:12:30 +00:00
|
|
|
: priority?.key === "high"
|
2023-12-10 10:18:10 +00:00
|
|
|
? "border-orange-500/20 bg-orange-500/20 text-orange-500"
|
|
|
|
: priority?.key === "medium"
|
2024-02-09 10:42:42 +00:00
|
|
|
? "border-yellow-500/20 bg-warning-component-surface-light text-warning-text-subtle"
|
2023-12-10 10:18:10 +00:00
|
|
|
: priority?.key === "low"
|
2024-02-08 14:35:52 +00:00
|
|
|
? "border-green-500/20 bg-success-component-surface-dark text-success-text-medium"
|
2024-01-30 06:46:21 +00:00
|
|
|
: "border-neutral-border-medium bg-neutral-component-surface-dark"
|
2023-09-01 11:12:30 +00:00
|
|
|
}`}
|
|
|
|
>
|
|
|
|
{priority && (
|
2023-12-10 10:18:10 +00:00
|
|
|
<span className="-my-1 grid place-items-center">
|
2023-09-01 11:12:30 +00:00
|
|
|
<Icon iconName={priority?.icon!} />
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
<span>{priority?.title ?? "None"}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center gap-2 text-sm">
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex w-1/4 flex-shrink-0 items-center gap-2 font-medium">
|
|
|
|
<Icon iconName="calendar_today" className="flex-shrink-0 !text-base" />
|
2023-09-01 11:12:30 +00:00
|
|
|
<span className="flex-grow truncate">Due date</span>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{issueDetails.target_date ? (
|
2024-02-08 12:53:13 +00:00
|
|
|
<div className="flex h-6 items-center gap-1 rounded border border-neutral-border-subtle bg-neutral-component-surface-dark px-2.5 py-1 text-xs text-neutral-text-strong">
|
2023-12-10 10:18:10 +00:00
|
|
|
<span className={`material-symbols-rounded -my-0.5 text-sm ${dueDateIcon.className}`}>
|
2023-09-07 07:23:49 +00:00
|
|
|
{dueDateIcon.iconName}
|
|
|
|
</span>
|
|
|
|
{renderFullDate(issueDetails.target_date)}
|
2023-09-01 11:12:30 +00:00
|
|
|
</div>
|
|
|
|
) : (
|
2024-02-08 12:53:13 +00:00
|
|
|
<span className="text-neutral-text-medium">Empty</span>
|
2023-09-01 11:12:30 +00:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|