2023-02-08 04:43:07 +00:00
|
|
|
import React from "react";
|
|
|
|
|
2023-04-14 14:10:00 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
2023-02-08 04:43:07 +00:00
|
|
|
// ui
|
2023-02-22 06:12:17 +00:00
|
|
|
import { CustomSelect, Tooltip } from "components/ui";
|
2023-02-08 04:43:07 +00:00
|
|
|
// icons
|
|
|
|
import { getPriorityIcon } from "components/icons/priority-icon";
|
|
|
|
// types
|
2023-06-06 16:06:00 +00:00
|
|
|
import { ICurrentUserResponse, IIssue } from "types";
|
2023-02-08 04:43:07 +00:00
|
|
|
// constants
|
|
|
|
import { PRIORITIES } from "constants/project";
|
2023-04-06 06:38:52 +00:00
|
|
|
// services
|
|
|
|
import trackEventServices from "services/track-event.service";
|
2023-02-08 04:43:07 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
issue: IIssue;
|
2023-05-10 20:57:14 +00:00
|
|
|
partialUpdateIssue: (formData: Partial<IIssue>, issueId: string) => void;
|
2023-03-05 14:52:01 +00:00
|
|
|
position?: "left" | "right";
|
2023-02-23 17:04:36 +00:00
|
|
|
selfPositioned?: boolean;
|
2023-06-06 16:06:00 +00:00
|
|
|
user: ICurrentUserResponse | undefined;
|
2023-02-08 04:43:07 +00:00
|
|
|
isNotAllowed: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ViewPrioritySelect: React.FC<Props> = ({
|
|
|
|
issue,
|
|
|
|
partialUpdateIssue,
|
2023-03-05 14:52:01 +00:00
|
|
|
position = "left",
|
2023-02-23 17:04:36 +00:00
|
|
|
selfPositioned = false,
|
2023-06-06 16:06:00 +00:00
|
|
|
user,
|
2023-02-08 04:43:07 +00:00
|
|
|
isNotAllowed,
|
2023-04-14 14:10:00 +00:00
|
|
|
}) => {
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug } = router.query;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CustomSelect
|
|
|
|
value={issue.priority}
|
|
|
|
onChange={(data: string) => {
|
2023-05-10 20:57:14 +00:00
|
|
|
partialUpdateIssue({ priority: data }, issue.id);
|
2023-04-14 14:10:00 +00:00
|
|
|
trackEventServices.trackIssuePartialPropertyUpdateEvent(
|
|
|
|
{
|
|
|
|
workspaceSlug,
|
|
|
|
workspaceId: issue.workspace,
|
|
|
|
projectId: issue.project_detail.id,
|
|
|
|
projectIdentifier: issue.project_detail.identifier,
|
|
|
|
projectName: issue.project_detail.name,
|
|
|
|
issueId: issue.id,
|
|
|
|
},
|
2023-06-06 16:06:00 +00:00
|
|
|
"ISSUE_PROPERTY_UPDATE_PRIORITY",
|
|
|
|
user
|
2023-04-14 14:10:00 +00:00
|
|
|
);
|
|
|
|
}}
|
|
|
|
maxHeight="md"
|
|
|
|
customButton={
|
|
|
|
<button
|
|
|
|
type="button"
|
2023-04-20 20:45:21 +00:00
|
|
|
className={`grid h-6 w-6 place-items-center rounded border ${
|
2023-04-14 14:10:00 +00:00
|
|
|
isNotAllowed ? "cursor-not-allowed" : "cursor-pointer"
|
2023-04-20 12:43:21 +00:00
|
|
|
} items-center shadow-sm ${
|
2023-04-14 14:10:00 +00:00
|
|
|
issue.priority === "urgent"
|
2023-04-20 20:45:21 +00:00
|
|
|
? "border-red-500/20 bg-red-500/20 text-red-500"
|
2023-04-14 14:10:00 +00:00
|
|
|
: issue.priority === "high"
|
2023-04-20 20:45:21 +00:00
|
|
|
? "border-orange-500/20 bg-orange-500/20 text-orange-500"
|
2023-04-14 14:10:00 +00:00
|
|
|
: issue.priority === "medium"
|
2023-04-20 20:45:21 +00:00
|
|
|
? "border-yellow-500/20 bg-yellow-500/20 text-yellow-500"
|
2023-04-14 14:10:00 +00:00
|
|
|
: issue.priority === "low"
|
2023-04-20 20:45:21 +00:00
|
|
|
? "border-green-500/20 bg-green-500/20 text-green-500"
|
|
|
|
: "border-brand-base"
|
2023-04-20 12:43:21 +00:00
|
|
|
}`}
|
2023-04-14 14:10:00 +00:00
|
|
|
>
|
|
|
|
<Tooltip tooltipHeading="Priority" tooltipContent={issue.priority ?? "None"}>
|
|
|
|
<span>
|
|
|
|
{getPriorityIcon(
|
|
|
|
issue.priority && issue.priority !== "" ? issue.priority ?? "" : "None",
|
|
|
|
"text-sm"
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
</Tooltip>
|
|
|
|
</button>
|
|
|
|
}
|
|
|
|
noChevron
|
|
|
|
disabled={isNotAllowed}
|
|
|
|
position={position}
|
|
|
|
selfPositioned={selfPositioned}
|
|
|
|
>
|
|
|
|
{PRIORITIES?.map((priority) => (
|
|
|
|
<CustomSelect.Option key={priority} value={priority} className="capitalize">
|
|
|
|
<>
|
|
|
|
{getPriorityIcon(priority, "text-sm")}
|
|
|
|
{priority ?? "None"}
|
|
|
|
</>
|
|
|
|
</CustomSelect.Option>
|
|
|
|
))}
|
|
|
|
</CustomSelect>
|
|
|
|
);
|
|
|
|
};
|