mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
742143766f
* fix: existing issues modal for cycle and module * refactor: existing issues modal code * fix: build errors
96 lines
3.3 KiB
TypeScript
96 lines
3.3 KiB
TypeScript
import React, { useState } from "react";
|
|
import { useRouter } from "next/router";
|
|
import { observer } from "mobx-react-lite";
|
|
import useSWR from "swr";
|
|
// mobx store
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
// components
|
|
import {
|
|
CycleAppliedFiltersRoot,
|
|
CycleCalendarLayout,
|
|
CycleEmptyState,
|
|
CycleGanttLayout,
|
|
CycleKanBanLayout,
|
|
CycleListLayout,
|
|
CycleSpreadsheetLayout,
|
|
} from "components/issues";
|
|
import { TransferIssues, TransferIssuesModal } from "components/cycles";
|
|
// ui
|
|
import { Spinner } from "@plane/ui";
|
|
// helpers
|
|
import { getDateRangeStatus } from "helpers/date-time.helper";
|
|
|
|
export const CycleLayoutRoot: React.FC = observer(() => {
|
|
const [transferIssuesModal, setTransferIssuesModal] = useState(false);
|
|
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId, cycleId } = router.query;
|
|
|
|
const {
|
|
issueFilter: issueFilterStore,
|
|
cycle: cycleStore,
|
|
cycleIssue: cycleIssueStore,
|
|
cycleIssueFilter: cycleIssueFilterStore,
|
|
} = useMobxStore();
|
|
|
|
useSWR(workspaceSlug && projectId && cycleId ? `CYCLE_FILTERS_AND_ISSUES_${cycleId.toString()}` : null, async () => {
|
|
if (workspaceSlug && projectId && cycleId) {
|
|
// fetching the project display filters and display properties
|
|
await issueFilterStore.fetchUserProjectFilters(workspaceSlug.toString(), projectId.toString());
|
|
// fetching the cycle filters
|
|
await cycleIssueFilterStore.fetchCycleFilters(workspaceSlug.toString(), projectId.toString(), cycleId.toString());
|
|
|
|
// fetching the cycle issues
|
|
await cycleIssueStore.fetchIssues(workspaceSlug.toString(), projectId.toString(), cycleId.toString());
|
|
}
|
|
});
|
|
|
|
const activeLayout = issueFilterStore.userDisplayFilters.layout;
|
|
|
|
const cycleDetails = cycleId ? cycleStore.cycle_details[cycleId.toString()] : undefined;
|
|
const cycleStatus =
|
|
cycleDetails?.start_date && cycleDetails?.end_date
|
|
? getDateRangeStatus(cycleDetails?.start_date, cycleDetails?.end_date)
|
|
: "draft";
|
|
|
|
const issueCount = cycleIssueStore.getIssuesCount;
|
|
|
|
if (!cycleIssueStore.getIssues)
|
|
return (
|
|
<div className="h-full w-full grid place-items-center">
|
|
<Spinner />
|
|
</div>
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<TransferIssuesModal handleClose={() => setTransferIssuesModal(false)} isOpen={transferIssuesModal} />
|
|
<div className="relative w-full h-full flex flex-col overflow-hidden">
|
|
{cycleStatus === "completed" && <TransferIssues handleClick={() => setTransferIssuesModal(true)} />}
|
|
<CycleAppliedFiltersRoot />
|
|
{(activeLayout === "list" || activeLayout === "spreadsheet") && issueCount === 0 ? (
|
|
<CycleEmptyState
|
|
workspaceSlug={workspaceSlug?.toString()}
|
|
projectId={projectId?.toString()}
|
|
cycleId={cycleId?.toString()}
|
|
/>
|
|
) : (
|
|
<div className="w-full h-full overflow-auto">
|
|
{activeLayout === "list" ? (
|
|
<CycleListLayout />
|
|
) : activeLayout === "kanban" ? (
|
|
<CycleKanBanLayout />
|
|
) : activeLayout === "calendar" ? (
|
|
<CycleCalendarLayout />
|
|
) : activeLayout === "gantt_chart" ? (
|
|
<CycleGanttLayout />
|
|
) : activeLayout === "spreadsheet" ? (
|
|
<CycleSpreadsheetLayout />
|
|
) : null}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</>
|
|
);
|
|
});
|