mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: sub issue hook and spreadsheet view refactor
This commit is contained in:
parent
a3a2fb84a3
commit
b297241d34
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React from "react";
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { SingleSpreadsheetIssue } from "components/core";
|
import { SingleSpreadsheetIssue } from "components/core";
|
||||||
@ -49,7 +49,7 @@ export const SpreadsheetIssues: React.FC<Props> = ({
|
|||||||
|
|
||||||
const isExpanded = expandedIssues.indexOf(issue.id) > -1;
|
const isExpanded = expandedIssues.indexOf(issue.id) > -1;
|
||||||
|
|
||||||
const { subIssues, isLoading } = useSubIssue(issue.id, isExpanded);
|
const { subIssues, isLoading } = useSubIssue(issue.project_detail.id, issue.id, isExpanded);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -3,13 +3,14 @@ import React, { useState } from "react";
|
|||||||
// next
|
// next
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
|
import { KeyedMutator } from "swr";
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { SpreadsheetColumns, SpreadsheetIssues } from "components/core";
|
import { SpreadsheetColumns, SpreadsheetIssues } from "components/core";
|
||||||
import { CustomMenu, Spinner } from "components/ui";
|
import { CustomMenu, Spinner } from "components/ui";
|
||||||
import { IssuePeekOverview } from "components/issues";
|
import { IssuePeekOverview } from "components/issues";
|
||||||
// hooks
|
// hooks
|
||||||
import useIssuesProperties from "hooks/use-issue-properties";
|
import useIssuesProperties from "hooks/use-issue-properties";
|
||||||
import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view";
|
|
||||||
// types
|
// types
|
||||||
import { ICurrentUserResponse, IIssue, Properties, UserAuth } from "types";
|
import { ICurrentUserResponse, IIssue, Properties, UserAuth } from "types";
|
||||||
// constants
|
// constants
|
||||||
@ -18,6 +19,13 @@ import { SPREADSHEET_COLUMN } from "constants/spreadsheet";
|
|||||||
import { PlusIcon } from "@heroicons/react/24/outline";
|
import { PlusIcon } from "@heroicons/react/24/outline";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
spreadsheetIssues: IIssue[];
|
||||||
|
mutateIssues: KeyedMutator<
|
||||||
|
| IIssue[]
|
||||||
|
| {
|
||||||
|
[key: string]: IIssue[];
|
||||||
|
}
|
||||||
|
>;
|
||||||
handleIssueAction: (issue: IIssue, action: "copy" | "delete" | "edit") => void;
|
handleIssueAction: (issue: IIssue, action: "copy" | "delete" | "edit") => void;
|
||||||
openIssuesListModal?: (() => void) | null;
|
openIssuesListModal?: (() => void) | null;
|
||||||
disableUserActions: boolean;
|
disableUserActions: boolean;
|
||||||
@ -26,6 +34,8 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const SpreadsheetView: React.FC<Props> = ({
|
export const SpreadsheetView: React.FC<Props> = ({
|
||||||
|
spreadsheetIssues,
|
||||||
|
mutateIssues,
|
||||||
handleIssueAction,
|
handleIssueAction,
|
||||||
openIssuesListModal,
|
openIssuesListModal,
|
||||||
disableUserActions,
|
disableUserActions,
|
||||||
@ -39,8 +49,6 @@ export const SpreadsheetView: React.FC<Props> = ({
|
|||||||
|
|
||||||
const type = cycleId ? "cycle" : moduleId ? "module" : "issue";
|
const type = cycleId ? "cycle" : moduleId ? "module" : "issue";
|
||||||
|
|
||||||
const { spreadsheetIssues, mutateIssues } = useSpreadsheetIssuesView();
|
|
||||||
|
|
||||||
const [properties] = useIssuesProperties(workspaceSlug as string, projectId as string);
|
const [properties] = useIssuesProperties(workspaceSlug as string, projectId as string);
|
||||||
|
|
||||||
const columnData = SPREADSHEET_COLUMN.map((column) => ({
|
const columnData = SPREADSHEET_COLUMN.map((column) => ({
|
||||||
|
@ -11,9 +11,9 @@ import { ISubIssueResponse } from "types";
|
|||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { SUB_ISSUES } from "constants/fetch-keys";
|
import { SUB_ISSUES } from "constants/fetch-keys";
|
||||||
|
|
||||||
const useSubIssue = (issueId: string, isExpanded: boolean) => {
|
const useSubIssue = (projectId: string, issueId: string, isExpanded: boolean) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug } = router.query;
|
||||||
|
|
||||||
const shouldFetch = workspaceSlug && projectId && issueId && isExpanded;
|
const shouldFetch = workspaceSlug && projectId && issueId && isExpanded;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user