mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
improvement: open sub-issues accordion by default in issue details page. (#3724)
This commit is contained in:
parent
614096fd2f
commit
e9fdb0ff5d
@ -1,4 +1,4 @@
|
|||||||
import { FC, useMemo, useState } from "react";
|
import { FC, useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { Plus, ChevronRight, ChevronDown, Loader } from "lucide-react";
|
import { Plus, ChevronRight, ChevronDown, Loader } from "lucide-react";
|
||||||
@ -260,6 +260,31 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = observer((props) => {
|
|||||||
const subIssues = subIssuesByIssueId(parentIssueId);
|
const subIssues = subIssuesByIssueId(parentIssueId);
|
||||||
const subIssueHelpers = subIssueHelpersByIssueId(`${parentIssueId}_root`);
|
const subIssueHelpers = subIssueHelpersByIssueId(`${parentIssueId}_root`);
|
||||||
|
|
||||||
|
const handleFetchSubIssues = useCallback(async () => {
|
||||||
|
if (!subIssueHelpers.issue_visibility.includes(parentIssueId)) {
|
||||||
|
setSubIssueHelpers(`${parentIssueId}_root`, "preview_loader", parentIssueId);
|
||||||
|
await subIssueOperations.fetchSubIssues(workspaceSlug, projectId, parentIssueId);
|
||||||
|
setSubIssueHelpers(`${parentIssueId}_root`, "preview_loader", parentIssueId);
|
||||||
|
}
|
||||||
|
setSubIssueHelpers(`${parentIssueId}_root`, "issue_visibility", parentIssueId);
|
||||||
|
}, [
|
||||||
|
parentIssueId,
|
||||||
|
projectId,
|
||||||
|
setSubIssueHelpers,
|
||||||
|
subIssueHelpers.issue_visibility,
|
||||||
|
subIssueOperations,
|
||||||
|
workspaceSlug,
|
||||||
|
]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleFetchSubIssues();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
handleFetchSubIssues();
|
||||||
|
};
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [parentIssueId]);
|
||||||
|
|
||||||
if (!issue) return <></>;
|
if (!issue) return <></>;
|
||||||
return (
|
return (
|
||||||
<div className="h-full w-full space-y-2">
|
<div className="h-full w-full space-y-2">
|
||||||
@ -272,14 +297,7 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = observer((props) => {
|
|||||||
<div className="relative flex items-center gap-4 text-xs">
|
<div className="relative flex items-center gap-4 text-xs">
|
||||||
<div
|
<div
|
||||||
className="flex cursor-pointer select-none items-center gap-1 rounded border border-custom-border-100 p-1.5 px-2 shadow transition-all hover:bg-custom-background-80"
|
className="flex cursor-pointer select-none items-center gap-1 rounded border border-custom-border-100 p-1.5 px-2 shadow transition-all hover:bg-custom-background-80"
|
||||||
onClick={async () => {
|
onClick={handleFetchSubIssues}
|
||||||
if (!subIssueHelpers.issue_visibility.includes(parentIssueId)) {
|
|
||||||
setSubIssueHelpers(`${parentIssueId}_root`, "preview_loader", parentIssueId);
|
|
||||||
await subIssueOperations.fetchSubIssues(workspaceSlug, projectId, parentIssueId);
|
|
||||||
setSubIssueHelpers(`${parentIssueId}_root`, "preview_loader", parentIssueId);
|
|
||||||
}
|
|
||||||
setSubIssueHelpers(`${parentIssueId}_root`, "issue_visibility", parentIssueId);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div className="flex h-[16px] w-[16px] flex-shrink-0 items-center justify-center">
|
<div className="flex h-[16px] w-[16px] flex-shrink-0 items-center justify-center">
|
||||||
{subIssueHelpers.preview_loader.includes(parentIssueId) ? (
|
{subIssueHelpers.preview_loader.includes(parentIssueId) ? (
|
||||||
|
Loading…
Reference in New Issue
Block a user