forked from github/plane
e08fc59114
* feat: spreadsheet view * fix: fix scroll and overflow issues, feat: updated issue properties component, style: ui improvements * feat: sub-issue toggle and sub-issue hook added, chore: code refactor * fix: only render parent issue * feat: sub issue fetching hook updated and nested sub issue added, chore: code refactor * style: title sticky to left on scroll and column styling * fix: tooltip , filter and view z-index fix * feat: spreadsheet view column sorting, fix: sticky scroll issue fix * feat: updated issue view filter for spreadsheet view * style: spreadsheet view column * feat: double click to edit title * fix: estimate sorting fix * style: spreadsheet view columns * fix: spreadsheet view mutation, feat: edit , copy and delete option added * fix: edit sub issue fix
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
import React, { useState } from "react";
|
|
|
|
// components
|
|
import { SingleSpreadsheetIssue } from "components/core";
|
|
// hooks
|
|
import useSubIssue from "hooks/use-sub-issue";
|
|
// types
|
|
import { ICurrentUserResponse, IIssue, Properties, UserAuth } from "types";
|
|
|
|
type Props = {
|
|
key: string;
|
|
issue: IIssue;
|
|
expandedIssues: string[];
|
|
setExpandedIssues: React.Dispatch<React.SetStateAction<string[]>>;
|
|
properties: Properties;
|
|
handleEditIssue: (issue: IIssue) => void;
|
|
handleDeleteIssue: (issue: IIssue) => void;
|
|
gridTemplateColumns: string;
|
|
user: ICurrentUserResponse | undefined;
|
|
userAuth: UserAuth;
|
|
nestingLevel?: number;
|
|
};
|
|
|
|
export const SpreadsheetIssues: React.FC<Props> = ({
|
|
key,
|
|
issue,
|
|
expandedIssues,
|
|
setExpandedIssues,
|
|
gridTemplateColumns,
|
|
properties,
|
|
handleEditIssue,
|
|
handleDeleteIssue,
|
|
user,
|
|
userAuth,
|
|
nestingLevel = 0,
|
|
}) => {
|
|
const handleToggleExpand = (issueId: string) => {
|
|
setExpandedIssues((prevState) => {
|
|
const newArray = [...prevState];
|
|
const index = newArray.indexOf(issueId);
|
|
if (index > -1) {
|
|
newArray.splice(index, 1);
|
|
} else {
|
|
newArray.push(issueId);
|
|
}
|
|
return newArray;
|
|
});
|
|
};
|
|
|
|
const isExpanded = expandedIssues.indexOf(issue.id) > -1;
|
|
|
|
const { subIssues, isLoading } = useSubIssue(issue.id, isExpanded);
|
|
|
|
return (
|
|
<div>
|
|
<SingleSpreadsheetIssue
|
|
issue={issue}
|
|
expanded={isExpanded}
|
|
handleToggleExpand={handleToggleExpand}
|
|
gridTemplateColumns={gridTemplateColumns}
|
|
properties={properties}
|
|
handleEditIssue={() => handleEditIssue(issue)}
|
|
handleDeleteIssue={handleDeleteIssue}
|
|
user={user}
|
|
userAuth={userAuth}
|
|
nestingLevel={nestingLevel}
|
|
/>
|
|
|
|
{isExpanded &&
|
|
!isLoading &&
|
|
subIssues &&
|
|
subIssues.length > 0 &&
|
|
subIssues.map((subIssue: IIssue, subIndex: number) => (
|
|
<SpreadsheetIssues
|
|
key={subIssue.id}
|
|
issue={subIssue}
|
|
expandedIssues={expandedIssues}
|
|
setExpandedIssues={setExpandedIssues}
|
|
gridTemplateColumns={gridTemplateColumns}
|
|
properties={properties}
|
|
handleEditIssue={() => handleEditIssue(subIssue)}
|
|
handleDeleteIssue={handleDeleteIssue}
|
|
user={user}
|
|
userAuth={userAuth}
|
|
nestingLevel={nestingLevel + 1}
|
|
/>
|
|
))}
|
|
</div>
|
|
);
|
|
};
|