forked from github/plane
9d0056cfee
* fix: spreadsheet subissues property update * fix: hover effect for sub-issues * refactor: mutate sub-issues
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import React from "react";
|
|
|
|
// components
|
|
import { IssuePropertyState } from "../../properties";
|
|
// hooks
|
|
import useSubIssue from "hooks/use-sub-issue";
|
|
// types
|
|
import { IIssue, IState } from "types";
|
|
import { mutate } from "swr";
|
|
import { SUB_ISSUES } from "constants/fetch-keys";
|
|
|
|
type Props = {
|
|
issue: IIssue;
|
|
onChange: (issue: IIssue, data: Partial<IIssue>) => void;
|
|
states: IState[] | undefined;
|
|
expandedIssues: string[];
|
|
disabled: boolean;
|
|
};
|
|
|
|
export const SpreadsheetStateColumn: React.FC<Props> = (props) => {
|
|
const { issue, onChange, states, expandedIssues, disabled } = props;
|
|
|
|
const isExpanded = expandedIssues.indexOf(issue.id) > -1;
|
|
|
|
const { subIssues, isLoading, mutateSubIssues } = useSubIssue(issue.project_detail?.id, issue.id, isExpanded);
|
|
|
|
return (
|
|
<>
|
|
<IssuePropertyState
|
|
projectId={issue.project_detail?.id ?? null}
|
|
value={issue.state}
|
|
defaultOptions={issue?.state_detail ? [issue.state_detail] : []}
|
|
onChange={(data) => {
|
|
onChange(issue, { state: data.id, state_detail: data });
|
|
if (issue.parent) {
|
|
mutateSubIssues(issue, { state: data.id, state_detail: data });
|
|
}
|
|
}}
|
|
className="w-full !h-11 border-b-[0.5px] border-custom-border-200"
|
|
buttonClassName="!shadow-none !border-0 h-full w-full"
|
|
hideDropdownArrow
|
|
disabled={disabled}
|
|
/>
|
|
|
|
{isExpanded &&
|
|
!isLoading &&
|
|
subIssues &&
|
|
subIssues.length > 0 &&
|
|
subIssues.map((subIssue) => (
|
|
<div className="h-11">
|
|
<SpreadsheetStateColumn
|
|
key={subIssue.id}
|
|
issue={subIssue}
|
|
onChange={onChange}
|
|
states={states}
|
|
expandedIssues={expandedIssues}
|
|
disabled={disabled}
|
|
/>
|
|
</div>
|
|
))}
|
|
</>
|
|
);
|
|
};
|