forked from github/plane
e08fc59114
* feat: spreadsheet view * fix: fix scroll and overflow issues, feat: updated issue properties component, style: ui improvements * feat: sub-issue toggle and sub-issue hook added, chore: code refactor * fix: only render parent issue * feat: sub issue fetching hook updated and nested sub issue added, chore: code refactor * style: title sticky to left on scroll and column styling * fix: tooltip , filter and view z-index fix * feat: spreadsheet view column sorting, fix: sticky scroll issue fix * feat: updated issue view filter for spreadsheet view * style: spreadsheet view column * feat: double click to edit title * fix: estimate sorting fix * style: spreadsheet view columns * fix: spreadsheet view mutation, feat: edit , copy and delete option added * fix: edit sub issue fix
109 lines
3.3 KiB
TypeScript
109 lines
3.3 KiB
TypeScript
import React from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
// ui
|
|
import { CustomSelect, Tooltip } from "components/ui";
|
|
// icons
|
|
import { getPriorityIcon } from "components/icons/priority-icon";
|
|
// types
|
|
import { ICurrentUserResponse, IIssue } from "types";
|
|
// constants
|
|
import { PRIORITIES } from "constants/project";
|
|
// services
|
|
import trackEventServices from "services/track-event.service";
|
|
// helper
|
|
import { capitalizeFirstLetter } from "helpers/string.helper";
|
|
|
|
type Props = {
|
|
issue: IIssue;
|
|
partialUpdateIssue: (formData: Partial<IIssue>, issueId: string) => void;
|
|
position?: "left" | "right";
|
|
selfPositioned?: boolean;
|
|
noBorder?: boolean;
|
|
user: ICurrentUserResponse | undefined;
|
|
isNotAllowed: boolean;
|
|
};
|
|
|
|
export const ViewPrioritySelect: React.FC<Props> = ({
|
|
issue,
|
|
partialUpdateIssue,
|
|
position = "left",
|
|
selfPositioned = false,
|
|
noBorder = false,
|
|
user,
|
|
isNotAllowed,
|
|
}) => {
|
|
const router = useRouter();
|
|
const { workspaceSlug } = router.query;
|
|
|
|
return (
|
|
<CustomSelect
|
|
value={issue.priority}
|
|
onChange={(data: string) => {
|
|
partialUpdateIssue({ priority: data }, issue.id);
|
|
trackEventServices.trackIssuePartialPropertyUpdateEvent(
|
|
{
|
|
workspaceSlug,
|
|
workspaceId: issue.workspace,
|
|
projectId: issue.project_detail.id,
|
|
projectIdentifier: issue.project_detail.identifier,
|
|
projectName: issue.project_detail.name,
|
|
issueId: issue.id,
|
|
},
|
|
"ISSUE_PROPERTY_UPDATE_PRIORITY",
|
|
user
|
|
);
|
|
}}
|
|
maxHeight="md"
|
|
customButton={
|
|
<button
|
|
type="button"
|
|
className={`grid place-items-center rounded ${
|
|
isNotAllowed ? "cursor-not-allowed" : "cursor-pointer"
|
|
} ${noBorder ? "" : "h-6 w-6 border shadow-sm"} ${
|
|
noBorder
|
|
? ""
|
|
: issue.priority === "urgent"
|
|
? "border-red-500/20 bg-red-500/20 text-red-500"
|
|
: issue.priority === "high"
|
|
? "border-orange-500/20 bg-orange-500/20 text-orange-500"
|
|
: issue.priority === "medium"
|
|
? "border-yellow-500/20 bg-yellow-500/20 text-yellow-500"
|
|
: issue.priority === "low"
|
|
? "border-green-500/20 bg-green-500/20 text-green-500"
|
|
: "border-brand-base"
|
|
} items-center`}
|
|
>
|
|
<Tooltip tooltipHeading="Priority" tooltipContent={issue.priority ?? "None"}>
|
|
<span className="flex gap-1 items-center text-brand-secondary text-xs">
|
|
{getPriorityIcon(
|
|
issue.priority && issue.priority !== "" ? issue.priority ?? "" : "None",
|
|
"text-sm"
|
|
)}
|
|
{noBorder
|
|
? issue.priority && issue.priority !== ""
|
|
? capitalizeFirstLetter(issue.priority) ?? ""
|
|
: "None"
|
|
: ""}
|
|
</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>
|
|
);
|
|
};
|