import React from "react"; import { observer } from "mobx-react-lite"; import { ChevronDown, ChevronRight, X, Pencil, Trash, Link as LinkIcon, Loader } from "lucide-react"; // components import { ControlLink, CustomMenu, Tooltip } from "@plane/ui"; import { useIssueDetail, useProject, useProjectState } from "hooks/store"; import { TIssue } from "@plane/types"; import { IssueList } from "./issues-list"; import { IssueProperty } from "./properties"; // ui // types import { TSubIssueOperations } from "./root"; // import { ISubIssuesRootLoaders, ISubIssuesRootLoadersHandler } from "./root"; 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, issueId, spacingLeft = 10, disabled, handleIssueCrudState, subIssueOperations, } = 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) ? (
) : (
{ if (!subIssueHelpers.issue_visibility.includes(issueId)) { setSubIssueHelpers(parentIssueId, "preview_loader", issueId); await subIssueOperations.fetchSubIssues(workspaceSlug, projectId, issueId); setSubIssueHelpers(parentIssueId, "preview_loader", issueId); } setSubIssueHelpers(parentIssueId, "issue_visibility", issueId); }} > {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 && ( )}
); });