mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
e1e9a5ed96
* dev: Helpers * dev: views * dev: Chart views Month, Year and Day * dev: Chart Workflow updates * update: scroll functionality implementation * update: data vaidation * update: date renders and issue filter in the month view * update: new date render month view * update: scroll enabled left in chart * update: Item render from the date it created. * update: width implementation in chat view * dev: chart render functionality in the gantt chart * update: month view fix * dev: chart render issues resolved * update: fixed allchat views * update: updated week view default values * update: integrated chart view in issues * update: grabble and sidebar logic impleemntation and integrated gantt in issues * update: Preview gantt chart in month view * fix: mutation in gantt chart after creating a new issue * chore: cycles and modules list gantt chart * update: Ui changes on gantt view * fix: gantt chart height, chore: remove link from issue --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
133 lines
3.9 KiB
TypeScript
133 lines
3.9 KiB
TypeScript
import React, { useEffect, useState } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import useSWR from "swr";
|
|
// hooks
|
|
// services
|
|
import cycleService from "services/cycles.service";
|
|
import projectService from "services/project.service";
|
|
// layouts
|
|
import { ProjectAuthorizationWrapper } from "layouts/auth-layout";
|
|
// components
|
|
import { CreateUpdateCycleModal, CyclesView } from "components/cycles";
|
|
// ui
|
|
import { PrimaryButton } from "components/ui";
|
|
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
|
// icons
|
|
import { PlusIcon } from "@heroicons/react/24/outline";
|
|
// types
|
|
import { SelectCycleType } from "types";
|
|
import type { NextPage } from "next";
|
|
// fetch-keys
|
|
import {
|
|
CYCLE_CURRENT_AND_UPCOMING_LIST,
|
|
CYCLE_DRAFT_LIST,
|
|
PROJECT_DETAILS,
|
|
CYCLE_DETAILS,
|
|
} from "constants/fetch-keys";
|
|
|
|
const ProjectCycles: NextPage = () => {
|
|
const [selectedCycle, setSelectedCycle] = useState<SelectCycleType>();
|
|
const [createUpdateCycleModal, setCreateUpdateCycleModal] = useState(false);
|
|
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
const { data: activeProject } = useSWR(
|
|
workspaceSlug && projectId ? PROJECT_DETAILS(projectId as string) : null,
|
|
workspaceSlug && projectId
|
|
? () => projectService.getProject(workspaceSlug as string, projectId as string)
|
|
: null
|
|
);
|
|
|
|
const { data: draftCycles } = useSWR(
|
|
workspaceSlug && projectId ? CYCLE_DRAFT_LIST(projectId as string) : null,
|
|
workspaceSlug && projectId
|
|
? () => cycleService.getDraftCycles(workspaceSlug as string, projectId as string)
|
|
: null
|
|
);
|
|
|
|
const { data: currentAndUpcomingCycles } = useSWR(
|
|
workspaceSlug && projectId ? CYCLE_CURRENT_AND_UPCOMING_LIST(projectId as string) : null,
|
|
workspaceSlug && projectId
|
|
? () => cycleService.getCurrentAndUpcomingCycles(workspaceSlug as string, projectId as string)
|
|
: null
|
|
);
|
|
|
|
const { data: cyclesCompleteList } = useSWR(
|
|
workspaceSlug && projectId ? CYCLE_DETAILS(projectId as string) : null,
|
|
workspaceSlug && projectId
|
|
? () => cycleService.getCycles(workspaceSlug as string, projectId as string)
|
|
: null
|
|
);
|
|
|
|
useEffect(() => {
|
|
if (createUpdateCycleModal) return;
|
|
const timer = setTimeout(() => {
|
|
setSelectedCycle(undefined);
|
|
clearTimeout(timer);
|
|
}, 500);
|
|
}, [createUpdateCycleModal]);
|
|
|
|
const currentTabValue = (tab: string | null) => {
|
|
switch (tab) {
|
|
case "All":
|
|
return 0;
|
|
case "Active":
|
|
return 1;
|
|
case "Upcoming":
|
|
return 2;
|
|
case "Completed":
|
|
return 3;
|
|
case "Drafts":
|
|
return 4;
|
|
default:
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
return (
|
|
<ProjectAuthorizationWrapper
|
|
meta={{
|
|
title: "Plane - Cycles",
|
|
}}
|
|
breadcrumbs={
|
|
<Breadcrumbs>
|
|
<BreadcrumbItem title="Projects" link={`/${workspaceSlug}/projects`} />
|
|
<BreadcrumbItem title={`${activeProject?.name ?? "Project"} Cycles`} />
|
|
</Breadcrumbs>
|
|
}
|
|
right={
|
|
<PrimaryButton
|
|
className="flex items-center gap-2"
|
|
onClick={() => {
|
|
const e = new KeyboardEvent("keydown", { key: "q" });
|
|
document.dispatchEvent(e);
|
|
}}
|
|
>
|
|
<PlusIcon className="h-4 w-4" />
|
|
Add Cycle
|
|
</PrimaryButton>
|
|
}
|
|
>
|
|
<CreateUpdateCycleModal
|
|
isOpen={createUpdateCycleModal}
|
|
handleClose={() => setCreateUpdateCycleModal(false)}
|
|
data={selectedCycle}
|
|
/>
|
|
<div className="space-y-5 p-8 h-full flex flex-col overflow-hidden">
|
|
<CyclesView
|
|
setSelectedCycle={setSelectedCycle}
|
|
setCreateUpdateCycleModal={setCreateUpdateCycleModal}
|
|
cyclesCompleteList={cyclesCompleteList}
|
|
currentAndUpcomingCycles={currentAndUpcomingCycles}
|
|
draftCycles={draftCycles}
|
|
/>
|
|
</div>
|
|
</ProjectAuthorizationWrapper>
|
|
);
|
|
};
|
|
|
|
export default ProjectCycles;
|