2023-09-26 14:26:59 +00:00
|
|
|
import React from "react";
|
2023-06-23 11:50:05 +00:00
|
|
|
|
|
|
|
// components
|
2023-10-18 07:02:02 +00:00
|
|
|
import { IssueColumn } from "components/issues";
|
2023-06-23 11:50:05 +00:00
|
|
|
// hooks
|
|
|
|
import useSubIssue from "hooks/use-sub-issue";
|
|
|
|
// types
|
2023-10-19 09:23:01 +00:00
|
|
|
import { IIssue, IIssueDisplayProperties } from "types";
|
2023-06-23 11:50:05 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
issue: IIssue;
|
|
|
|
expandedIssues: string[];
|
|
|
|
setExpandedIssues: React.Dispatch<React.SetStateAction<string[]>>;
|
2023-10-19 09:23:01 +00:00
|
|
|
properties: IIssueDisplayProperties;
|
2023-11-27 08:45:33 +00:00
|
|
|
quickActions: (issue: IIssue) => React.ReactNode;
|
2023-07-26 12:21:26 +00:00
|
|
|
disableUserActions: boolean;
|
2023-06-23 11:50:05 +00:00
|
|
|
nestingLevel?: number;
|
|
|
|
};
|
|
|
|
|
2023-09-26 14:26:59 +00:00
|
|
|
export const SpreadsheetIssuesColumn: React.FC<Props> = ({
|
2023-06-23 11:50:05 +00:00
|
|
|
issue,
|
|
|
|
expandedIssues,
|
|
|
|
setExpandedIssues,
|
|
|
|
properties,
|
2023-11-27 08:45:33 +00:00
|
|
|
quickActions,
|
2023-07-26 12:21:26 +00:00
|
|
|
disableUserActions,
|
2023-06-23 11:50:05 +00:00
|
|
|
nestingLevel = 0,
|
|
|
|
}) => {
|
|
|
|
const handleToggleExpand = (issueId: string) => {
|
|
|
|
setExpandedIssues((prevState) => {
|
|
|
|
const newArray = [...prevState];
|
|
|
|
const index = newArray.indexOf(issueId);
|
2023-10-18 07:02:02 +00:00
|
|
|
|
|
|
|
if (index > -1) newArray.splice(index, 1);
|
|
|
|
else newArray.push(issueId);
|
|
|
|
|
2023-06-23 11:50:05 +00:00
|
|
|
return newArray;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const isExpanded = expandedIssues.indexOf(issue.id) > -1;
|
|
|
|
|
2023-11-27 08:45:33 +00:00
|
|
|
const { subIssues, isLoading } = useSubIssue(issue.project_detail?.id, issue.id, isExpanded);
|
2023-06-23 11:50:05 +00:00
|
|
|
|
|
|
|
return (
|
2023-10-20 11:37:46 +00:00
|
|
|
<>
|
2023-09-26 14:26:59 +00:00
|
|
|
<IssueColumn
|
2023-06-23 11:50:05 +00:00
|
|
|
issue={issue}
|
|
|
|
expanded={isExpanded}
|
|
|
|
handleToggleExpand={handleToggleExpand}
|
|
|
|
properties={properties}
|
2023-07-26 12:21:26 +00:00
|
|
|
disableUserActions={disableUserActions}
|
2023-06-23 11:50:05 +00:00
|
|
|
nestingLevel={nestingLevel}
|
2023-11-27 08:45:33 +00:00
|
|
|
quickActions={quickActions}
|
2023-06-23 11:50:05 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
{isExpanded &&
|
|
|
|
!isLoading &&
|
|
|
|
subIssues &&
|
|
|
|
subIssues.length > 0 &&
|
2023-10-20 11:37:46 +00:00
|
|
|
subIssues.map((subIssue) => (
|
2023-09-26 14:26:59 +00:00
|
|
|
<SpreadsheetIssuesColumn
|
2023-06-23 11:50:05 +00:00
|
|
|
key={subIssue.id}
|
|
|
|
issue={subIssue}
|
|
|
|
expandedIssues={expandedIssues}
|
|
|
|
setExpandedIssues={setExpandedIssues}
|
|
|
|
properties={properties}
|
2023-11-27 08:45:33 +00:00
|
|
|
quickActions={quickActions}
|
2023-07-26 12:21:26 +00:00
|
|
|
disableUserActions={disableUserActions}
|
2023-06-23 11:50:05 +00:00
|
|
|
nestingLevel={nestingLevel + 1}
|
|
|
|
/>
|
|
|
|
))}
|
2023-10-20 11:37:46 +00:00
|
|
|
</>
|
2023-06-23 11:50:05 +00:00
|
|
|
);
|
|
|
|
};
|