import { Dispatch, MutableRefObject, SetStateAction, useRef, useState } from "react"; import { observer } from "mobx-react"; import { useRouter } from "next/router"; // icons import { ChevronRight, MoreHorizontal } from "lucide-react"; import { IIssueDisplayProperties, TIssue } from "@plane/types"; // ui import { ControlLink, Tooltip } from "@plane/ui"; // components import RenderIfVisible from "@/components/core/render-if-visible-HOC"; // helper import { cn } from "@/helpers/common.helper"; // hooks import { useIssueDetail, useProject } from "@/hooks/store"; import useOutsideClickDetector from "@/hooks/use-outside-click-detector"; import { usePlatformOS } from "@/hooks/use-platform-os"; // types // local components import { TRenderQuickActions } from "../list/list-view-types"; import { WithDisplayPropertiesHOC } from "../properties/with-display-properties-HOC"; import { IssueColumn } from "./issue-column"; interface Props { displayProperties: IIssueDisplayProperties; isEstimateEnabled: boolean; quickActions: TRenderQuickActions; canEditProperties: (projectId: string | undefined) => boolean; updateIssue: ((projectId: string, issueId: string, data: Partial) => Promise) | undefined; portalElement: React.MutableRefObject; nestingLevel: number; issueId: string; isScrolled: MutableRefObject; containerRef: MutableRefObject; issueIds: string[]; spreadsheetColumnsList: (keyof IIssueDisplayProperties)[]; } export const SpreadsheetIssueRow = observer((props: Props) => { const { displayProperties, issueId, isEstimateEnabled, nestingLevel, portalElement, updateIssue, quickActions, canEditProperties, isScrolled, containerRef, issueIds, spreadsheetColumnsList, } = props; const [isExpanded, setExpanded] = useState(false); const { subIssues: subIssuesStore } = useIssueDetail(); const subIssues = subIssuesStore.subIssuesByIssueId(issueId); return ( <> {/* first column/ issue name and key column */} } changingReference={issueIds} > {isExpanded && subIssues && subIssues.length > 0 && subIssues.map((subIssueId: string) => ( ))} ); }); interface IssueRowDetailsProps { displayProperties: IIssueDisplayProperties; isEstimateEnabled: boolean; quickActions: TRenderQuickActions; canEditProperties: (projectId: string | undefined) => boolean; updateIssue: ((projectId: string, issueId: string, data: Partial) => Promise) | undefined; portalElement: React.MutableRefObject; nestingLevel: number; issueId: string; isScrolled: MutableRefObject; isExpanded: boolean; setExpanded: Dispatch>; spreadsheetColumnsList: (keyof IIssueDisplayProperties)[]; } const IssueRowDetails = observer((props: IssueRowDetailsProps) => { const { displayProperties, issueId, isEstimateEnabled, nestingLevel, portalElement, updateIssue, quickActions, canEditProperties, isScrolled, isExpanded, setExpanded, spreadsheetColumnsList, } = props; // states const [isMenuActive, setIsMenuActive] = useState(false); // refs const cellRef = useRef(null); const menuActionRef = useRef(null); // router const router = useRouter(); const { workspaceSlug } = router.query; // hooks const { getProjectIdentifierById } = useProject(); const { getIsIssuePeeked, setPeekIssue } = useIssueDetail(); const { isMobile } = usePlatformOS(); const handleIssuePeekOverview = (issue: TIssue) => workspaceSlug && issue && issue.project_id && issue.id && !getIsIssuePeeked(issue.id) && setPeekIssue({ workspaceSlug: workspaceSlug.toString(), projectId: issue.project_id, issueId: issue.id }); const { subIssues: subIssuesStore, issue } = useIssueDetail(); const issueDetail = issue.getIssueById(issueId); const paddingLeft = `${nestingLevel * 54}px`; useOutsideClickDetector(menuActionRef, () => setIsMenuActive(false)); const handleToggleExpand = () => { setExpanded((prevState) => { if (!prevState && workspaceSlug && issueDetail) subIssuesStore.fetchSubIssues(workspaceSlug.toString(), issueDetail.project_id, issueDetail.id); return !prevState; }); }; const customActionButton = (
setIsMenuActive(!isMenuActive)} >
); if (!issueDetail) return null; const disableUserActions = !canEditProperties(issueDetail.project_id); return ( <>
{getProjectIdentifierById(issueDetail.project_id)}-{issueDetail.sequence_id}
{issueDetail.sub_issues_count > 0 && (
)}
handleIssuePeekOverview(issueDetail)} className="clickable w-full line-clamp-1 cursor-pointer text-sm text-custom-text-100" disabled={!!issueDetail?.tempId} >
{issueDetail.name}
{/* Rest of the columns */} {spreadsheetColumnsList.map((property) => ( ))} ); });