import React from "react"; import { ChevronDown, ChevronRight, X, Pencil, Trash, Link as LinkIcon, Loader } from "lucide-react"; // components import { IssueList } from "./issues-list"; import { IssueProperty } from "./properties"; // ui import { ControlLink, CustomMenu, Tooltip } from "@plane/ui"; // types import { TIssue } from "@plane/types"; import { TSubIssueOperations } from "./root"; // import { ISubIssuesRootLoaders, ISubIssuesRootLoadersHandler } from "./root"; import { useIssueDetail, useProject, useProjectState } from "hooks/store"; import { observer } from "mobx-react-lite"; export interface ISubIssues { workspaceSlug: string; projectId: string; parentIssueId: string; spacingLeft: number; disabled: boolean; handleIssueCrudState: ( key: "create" | "existing" | "update" | "delete", issueId: string, issue?: TIssue | null ) => void; subIssueOperations: TSubIssueOperations; issueId: string; } export const IssueListItem: React.FC = observer((props) => { const { workspaceSlug, projectId, parentIssueId, spacingLeft = 10, disabled, handleIssueCrudState, subIssueOperations, issueId, } = props; const { setPeekIssue, issue: { getIssueById }, subIssues: { subIssueHelpersByIssueId, setSubIssueHelpers }, } = useIssueDetail(); const project = useProject(); const { getProjectStates } = useProjectState(); const issue = getIssueById(issueId); const projectDetail = (issue && issue.project_id && project.getProjectById(issue.project_id)) || undefined; const currentIssueStateDetail = (issue?.project_id && getProjectStates(issue?.project_id)?.find((state) => issue?.state_id == state.id)) || undefined; const subIssueHelpers = subIssueHelpersByIssueId(parentIssueId); const handleIssuePeekOverview = (issue: TIssue) => workspaceSlug && issue && issue.project_id && issue.id && setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id }); if (!issue) return <>; return (
{issue && (
{issue?.sub_issues_count > 0 && ( <> {subIssueHelpers.preview_loader.includes(issue.id) ? (
) : (
{ setSubIssueHelpers(parentIssueId, "preview_loader", issue.id); setSubIssueHelpers(parentIssueId, "issue_visibility", issue.id); }} > {subIssueHelpers.issue_visibility.includes(issue.id) ? ( ) : ( )}
)} )}
{projectDetail?.identifier}-{issue?.sequence_id}
handleIssuePeekOverview(issue)} className="w-full line-clamp-1 cursor-pointer text-sm text-custom-text-100" > {issue.name}
{disabled && ( handleIssueCrudState("update", parentIssueId, issue)}>
Edit issue
)} {disabled && ( handleIssueCrudState("delete", parentIssueId, issue)}>
Delete issue
)} subIssueOperations.copyText(`${workspaceSlug}/projects/${issue.project_id}/issues/${issue.id}`) } >
Copy issue link
{disabled && ( <> {subIssueHelpers.issue_loader.includes(issue.id) ? (
) : (
{ subIssueOperations.removeSubIssue(workspaceSlug, issue.project_id, parentIssueId, issue.id); }} >
)} )}
)} {subIssueHelpers.issue_visibility.includes(issueId) && issue.sub_issues_count && issue.sub_issues_count > 0 && ( )}
); });