2023-09-26 14:26:59 +00:00
|
|
|
import React, { useState } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
2023-11-27 08:45:33 +00:00
|
|
|
import { ChevronRight } 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-11-27 08:45:33 +00:00
|
|
|
quickActions: (issue: IIssue) => React.ReactNode;
|
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,
|
2023-11-27 08:45:33 +00:00
|
|
|
quickActions,
|
2023-09-26 14:26:59 +00:00
|
|
|
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
|
|
|
<>
|
2023-11-27 08:45:33 +00:00
|
|
|
<div className="group flex items-center w-[28rem] text-sm h-11 top-0 bg-custom-background-100 truncate border-b border-custom-border-100">
|
2023-11-03 11:50:14 +00:00
|
|
|
{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 && (
|
2023-11-27 08:45:33 +00:00
|
|
|
<div className="absolute top-0 left-2.5 opacity-0 group-hover:opacity-100">{quickActions(issue)}</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 && (
|
|
|
|
<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
|
|
|
);
|
|
|
|
};
|