2023-09-26 14:26:59 +00:00
|
|
|
import React, { useState } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { Popover2 } from "@blueprintjs/popover2";
|
2023-10-20 11:37:46 +00:00
|
|
|
import { MoreHorizontal, Pencil, Trash2, ChevronRight, Link } from "lucide-react";
|
2023-09-26 14:26:59 +00:00
|
|
|
// hooks
|
|
|
|
import useToast from "hooks/use-toast";
|
2023-11-02 10:32:34 +00:00
|
|
|
// components
|
|
|
|
import { Tooltip } from "@plane/ui";
|
2023-10-18 07:02:02 +00:00
|
|
|
// helpers
|
2023-10-31 06:48:04 +00:00
|
|
|
import { copyUrlToClipboard } from "helpers/string.helper";
|
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-09-26 14:26:59 +00:00
|
|
|
handleEditIssue: (issue: IIssue) => void;
|
|
|
|
handleDeleteIssue: (issue: IIssue) => void;
|
2023-11-03 11:50:14 +00:00
|
|
|
setIssuePeekOverView: React.Dispatch<
|
|
|
|
React.SetStateAction<{
|
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
|
|
|
issueId: string;
|
|
|
|
} | null>
|
|
|
|
>;
|
2023-09-26 14:26:59 +00:00
|
|
|
disableUserActions: boolean;
|
|
|
|
nestingLevel: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const IssueColumn: React.FC<Props> = ({
|
|
|
|
issue,
|
|
|
|
expanded,
|
|
|
|
handleToggleExpand,
|
2023-11-03 11:50:14 +00:00
|
|
|
setIssuePeekOverView,
|
2023-09-26 14:26:59 +00:00
|
|
|
properties,
|
|
|
|
handleEditIssue,
|
|
|
|
handleDeleteIssue,
|
|
|
|
disableUserActions,
|
|
|
|
nestingLevel,
|
|
|
|
}) => {
|
|
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const { workspaceSlug } = router.query;
|
|
|
|
|
|
|
|
const { setToastAlert } = useToast();
|
|
|
|
|
|
|
|
const handleCopyText = () => {
|
2023-10-31 06:48:04 +00:00
|
|
|
copyUrlToClipboard(`${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`).then(() => {
|
2023-09-26 14:26:59 +00:00
|
|
|
setToastAlert({
|
|
|
|
type: "success",
|
|
|
|
title: "Link Copied!",
|
|
|
|
message: "Issue link copied to clipboard.",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-11-03 11:50:14 +00:00
|
|
|
const handleIssuePeekOverview = (issue: IIssue) => {
|
|
|
|
const { query } = router;
|
|
|
|
setIssuePeekOverView({
|
|
|
|
workspaceSlug: issue?.workspace_detail?.slug,
|
|
|
|
projectId: issue?.project_detail?.id,
|
|
|
|
issueId: issue?.id,
|
|
|
|
});
|
|
|
|
router.push({
|
|
|
|
pathname: router.pathname,
|
|
|
|
query: { ...query, peekIssueId: issue?.id },
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-09-26 14:26:59 +00:00
|
|
|
const paddingLeft = `${nestingLevel * 54}px`;
|
|
|
|
|
|
|
|
return (
|
2023-11-03 11:50:14 +00:00
|
|
|
<>
|
|
|
|
<div className="group flex items-center w-[28rem] text-sm h-11 sticky top-0 bg-custom-background-100 truncate border-b border-custom-border-100">
|
|
|
|
{properties.key && (
|
|
|
|
<div
|
2023-11-14 12:58:49 +00:00
|
|
|
className="flex gap-1.5 px-4 pr-0 py-2.5 items-center min-w-min"
|
2023-11-03 11:50:14 +00:00
|
|
|
style={issue.parent && nestingLevel !== 0 ? { paddingLeft } : {}}
|
|
|
|
>
|
|
|
|
<div className="relative flex items-center cursor-pointer text-xs text-center hover:text-custom-text-100">
|
|
|
|
<span className="flex items-center justify-center font-medium opacity-100 group-hover:opacity-0 ">
|
|
|
|
{issue.project_detail?.identifier}-{issue.sequence_id}
|
|
|
|
</span>
|
|
|
|
|
|
|
|
{!disableUserActions && (
|
|
|
|
<div className="absolute top-0 left-2.5 opacity-0 group-hover:opacity-100">
|
|
|
|
<Popover2
|
|
|
|
isOpen={isOpen}
|
|
|
|
canEscapeKeyClose
|
|
|
|
onInteraction={(nextOpenState) => setIsOpen(nextOpenState)}
|
|
|
|
content={
|
|
|
|
<div className="flex flex-col whitespace-nowrap rounded-md border border-custom-border-100 p-1 text-xs shadow-lg focus:outline-none min-w-full bg-custom-background-100 space-y-0.5">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="hover:text-custom-text-200 w-full select-none gap-2 rounded p-1 text-left text-custom-text-200 hover:bg-custom-background-80"
|
|
|
|
onClick={() => {
|
|
|
|
handleCopyText();
|
|
|
|
setIsOpen(false);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<Link className="h-3 w-3" />
|
|
|
|
<span>Copy link</span>
|
|
|
|
</div>
|
|
|
|
</button>
|
2023-09-29 09:35:27 +00:00
|
|
|
|
2023-11-03 11:50:14 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="hover:text-custom-text-200 w-full select-none gap-2 rounded p-1 text-left text-custom-text-200 hover:bg-custom-background-80"
|
|
|
|
onClick={() => {
|
|
|
|
handleEditIssue(issue);
|
|
|
|
setIsOpen(false);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<Pencil className="h-3 w-3" />
|
|
|
|
<span>Edit issue</span>
|
|
|
|
</div>
|
|
|
|
</button>
|
2023-09-29 09:35:27 +00:00
|
|
|
|
2023-11-03 11:50:14 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="w-full select-none gap-2 rounded p-1 text-left text-red-500 hover:bg-custom-background-80"
|
|
|
|
onClick={() => {
|
|
|
|
handleDeleteIssue(issue);
|
|
|
|
setIsOpen(false);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<Trash2 className="h-3 w-3" />
|
|
|
|
<span>Delete issue</span>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
placement="bottom-start"
|
|
|
|
>
|
|
|
|
<MoreHorizontal className="h-5 w-5 text-custom-text-200" />
|
|
|
|
</Popover2>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2023-09-29 09:35:27 +00:00
|
|
|
|
2023-11-03 11:50:14 +00:00
|
|
|
{issue.sub_issues_count > 0 && (
|
|
|
|
<div className="h-6 w-6 flex justify-center items-center">
|
|
|
|
<button
|
|
|
|
className="h-5 w-5 hover:bg-custom-background-90 hover:text-custom-text-100 rounded-sm cursor-pointer"
|
|
|
|
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
|
|
|
|
className="px-4 py-2.5 h-full w-full truncate text-custom-text-100 text-left cursor-pointer text-[0.825rem]"
|
|
|
|
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
|
|
|
);
|
|
|
|
};
|