2023-12-06 13:51:24 +00:00
|
|
|
import React, { useRef, useState } from "react";
|
2023-09-26 14:26:59 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-12-06 13:51:24 +00:00
|
|
|
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
2023-11-02 10:32:34 +00:00
|
|
|
// components
|
|
|
|
import { Tooltip } from "@plane/ui";
|
2023-12-06 13:51:24 +00:00
|
|
|
// hooks
|
|
|
|
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
2023-09-26 14:26:59 +00:00
|
|
|
// types
|
2023-10-19 09:23:01 +00:00
|
|
|
import { IIssue, IIssueDisplayProperties } from "types";
|
2023-09-26 14:26:59 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
issue: IIssue;
|
|
|
|
expanded: boolean;
|
|
|
|
handleToggleExpand: (issueId: string) => void;
|
2023-10-19 09:23:01 +00:00
|
|
|
properties: IIssueDisplayProperties;
|
2023-12-06 13:51:24 +00:00
|
|
|
quickActions: (issue: IIssue, customActionButton?: React.ReactElement) => React.ReactNode;
|
2023-12-07 14:16:57 +00:00
|
|
|
canEditProperties: (projectId: string | undefined) => boolean;
|
2023-09-26 14:26:59 +00:00
|
|
|
nestingLevel: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const IssueColumn: React.FC<Props> = ({
|
|
|
|
issue,
|
|
|
|
expanded,
|
|
|
|
handleToggleExpand,
|
|
|
|
properties,
|
2023-11-27 08:45:33 +00:00
|
|
|
quickActions,
|
2023-12-07 14:16:57 +00:00
|
|
|
canEditProperties,
|
2023-09-26 14:26:59 +00:00
|
|
|
nestingLevel,
|
|
|
|
}) => {
|
2023-11-29 08:55:57 +00:00
|
|
|
// router
|
2023-09-26 14:26:59 +00:00
|
|
|
const router = useRouter();
|
2023-12-06 13:51:24 +00:00
|
|
|
// states
|
|
|
|
const [isMenuActive, setIsMenuActive] = useState(false);
|
|
|
|
|
|
|
|
const menuActionRef = useRef<HTMLDivElement | null>(null);
|
2023-09-26 14:26:59 +00:00
|
|
|
|
2023-11-03 11:50:14 +00:00
|
|
|
const handleIssuePeekOverview = (issue: IIssue) => {
|
|
|
|
const { query } = router;
|
2023-11-29 08:55:57 +00:00
|
|
|
|
2023-11-03 11:50:14 +00:00
|
|
|
router.push({
|
|
|
|
pathname: router.pathname,
|
2023-11-29 08:55:57 +00:00
|
|
|
query: { ...query, peekIssueId: issue?.id, peekProjectId: issue?.project },
|
2023-11-03 11:50:14 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-09-26 14:26:59 +00:00
|
|
|
const paddingLeft = `${nestingLevel * 54}px`;
|
|
|
|
|
2023-12-06 13:51:24 +00:00
|
|
|
useOutsideClickDetector(menuActionRef, () => setIsMenuActive(false));
|
|
|
|
|
|
|
|
const customActionButton = (
|
|
|
|
<div
|
|
|
|
ref={menuActionRef}
|
2023-12-10 10:18:10 +00:00
|
|
|
className={`w-full cursor-pointer rounded p-1 text-custom-sidebar-text-400 hover:bg-custom-background-80 ${
|
2023-12-06 13:51:24 +00:00
|
|
|
isMenuActive ? "bg-custom-background-80 text-custom-text-100" : "text-custom-text-200"
|
|
|
|
}`}
|
|
|
|
onClick={() => setIsMenuActive(!isMenuActive)}
|
|
|
|
>
|
|
|
|
<MoreHorizontal className="h-3.5 w-3.5" />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2023-09-26 14:26:59 +00:00
|
|
|
return (
|
2023-11-03 11:50:14 +00:00
|
|
|
<>
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="group top-0 flex h-11 w-[28rem] items-center truncate border-b border-custom-border-100 bg-custom-background-100 text-sm">
|
2023-11-03 11:50:14 +00:00
|
|
|
{properties.key && (
|
|
|
|
<div
|
2023-12-10 10:18:10 +00:00
|
|
|
className="flex min-w-min items-center gap-1.5 px-4 py-2.5 pr-0"
|
2023-11-03 11:50:14 +00:00
|
|
|
style={issue.parent && nestingLevel !== 0 ? { paddingLeft } : {}}
|
|
|
|
>
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="relative flex cursor-pointer items-center text-center text-xs hover:text-custom-text-100">
|
2023-12-06 13:51:24 +00:00
|
|
|
<span
|
|
|
|
className={`flex items-center justify-center font-medium opacity-100 group-hover:opacity-0 ${
|
|
|
|
isMenuActive ? "!opacity-0" : ""
|
|
|
|
} `}
|
|
|
|
>
|
2023-11-03 11:50:14 +00:00
|
|
|
{issue.project_detail?.identifier}-{issue.sequence_id}
|
|
|
|
</span>
|
|
|
|
|
2023-12-07 14:16:57 +00:00
|
|
|
{canEditProperties(issue.project) && (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className={`absolute left-2.5 top-0 hidden group-hover:block ${isMenuActive ? "!block" : ""}`}>
|
2023-12-06 13:51:24 +00:00
|
|
|
{quickActions(issue, customActionButton)}
|
|
|
|
</div>
|
2023-11-03 11:50:14 +00:00
|
|
|
)}
|
|
|
|
</div>
|
2023-09-29 09:35:27 +00:00
|
|
|
|
2023-11-03 11:50:14 +00:00
|
|
|
{issue.sub_issues_count > 0 && (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex h-6 w-6 items-center justify-center">
|
2023-11-03 11:50:14 +00:00
|
|
|
<button
|
2023-12-10 10:18:10 +00:00
|
|
|
className="h-5 w-5 cursor-pointer rounded-sm hover:bg-custom-background-90 hover:text-custom-text-100"
|
2023-11-03 11:50:14 +00:00
|
|
|
onClick={() => handleToggleExpand(issue.id)}
|
2023-09-29 09:35:27 +00:00
|
|
|
>
|
2023-11-03 11:50:14 +00:00
|
|
|
<ChevronRight className={`h-3.5 w-3.5 ${expanded ? "rotate-90" : ""}`} />
|
|
|
|
</button>
|
2023-09-29 09:35:27 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2023-11-03 11:50:14 +00:00
|
|
|
)}
|
|
|
|
<div className="w-full overflow-hidden">
|
|
|
|
<Tooltip tooltipHeading="Title" tooltipContent={issue.name}>
|
|
|
|
<div
|
2023-12-10 10:18:10 +00:00
|
|
|
className="h-full w-full cursor-pointer truncate px-4 py-2.5 text-left text-[0.825rem] text-custom-text-100"
|
2023-11-03 11:50:14 +00:00
|
|
|
onClick={() => handleIssuePeekOverview(issue)}
|
|
|
|
>
|
2023-11-02 10:32:34 +00:00
|
|
|
{issue.name}
|
|
|
|
</div>
|
2023-11-03 11:50:14 +00:00
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
2023-09-26 14:26:59 +00:00
|
|
|
);
|
|
|
|
};
|