import React from "react"; import { observer } from "mobx-react-lite"; import { ChevronRight, X, Pencil, Trash, Link as LinkIcon, Loader } from "lucide-react"; import { TIssue } from "@plane/types"; // components import { ControlLink, CustomMenu, Tooltip } from "@plane/ui"; import { cn } from "@/helpers/common.helper"; import { useIssueDetail, useProject, useProjectState } from "@/hooks/store"; import { usePlatformOS } from "@/hooks/use-platform-os"; 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 { peekIssue, setPeekIssue, issue: { getIssueById }, subIssues: { subIssueHelpersByIssueId, setSubIssueHelpers }, toggleCreateIssueModal, toggleDeleteIssueModal, } = useIssueDetail(); const project = useProject(); const { getProjectStates } = useProjectState(); const { isMobile } = usePlatformOS(); 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 && peekIssue?.issueId !== 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); }} >
)} )}
{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 }); toggleCreateIssueModal(true); }} >
Edit issue
)} {disabled && ( { handleIssueCrudState("delete", parentIssueId, issue); toggleDeleteIssueModal(issue.id); }} >
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 && ( )}
); });