mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
9075f9441c
* style: added cta at the bottom of sidebar, added missing icons as well, showing dynamic workspace member count on workspace dropdown * refractor: running parallel request, made create/edit label function to async function * fix: sidebar dropdown content going below kanban items outside click detection in need help dropdown * refractor: making parallel api calls fix: create state input comes at bottom, create state input gets on focus automatically, form is getting submitted on enter click * refactoring file structure and signin page * style: changed text and added spinner for signing in loading * refractor: removed unused type * fix: my issue cta in profile page sending to 404 page * fix: added new s3 bucket url in next.config.js file increased image modal height * packaging UI components * eslint config * eslint fixes * refactoring changes * build fixes * minor fixes * adding todo comments for reference * refactor: cleared unused imports and re ordered imports * refactor: removed unused imports * fix: added workspace argument to useissues hook * refactor: removed api-routes file, unnecessary constants * refactor: created helpers folder, removed unnecessary constants * refactor: new context for issue view * refactoring issues page * build fixes * refactoring * refactor: create issue modal * refactor: module ui * fix: sub-issues mutation * fix: create more option in create issue modal * description form debounce issue * refactor: global component for assignees list * fix: link module interface * fix: priority icons and sub-issues count added * fix: cycle mutation in issue details page * fix: remove issue from cycle mutation * fix: create issue modal in home page * fix: removed unnecessary props * fix: updated create issue form status * fix: settings auth breaking * refactor: issue details page Co-authored-by: Dakshesh Jain <dakshesh.jain14@gmail.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: venkatesh-soulpage <venkatesh.marreboyina@soulpageit.com> Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia1001@gmail.com>
215 lines
7.5 KiB
TypeScript
215 lines
7.5 KiB
TypeScript
import { useEffect } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { mutate } from "swr";
|
|
|
|
// react-hook-form
|
|
import { Controller, useForm } from "react-hook-form";
|
|
// icons
|
|
import { CalendarDaysIcon, ChartPieIcon, LinkIcon, UserIcon } from "@heroicons/react/24/outline";
|
|
// services
|
|
import cyclesService from "services/cycles.service";
|
|
// hooks
|
|
import useToast from "hooks/use-toast";
|
|
// ui
|
|
import { Loader } from "components/ui";
|
|
// helpers
|
|
import { copyTextToClipboard } from "helpers/string.helper";
|
|
import { groupBy } from "helpers/array.helper";
|
|
// types
|
|
import { CycleIssueResponse, ICycle } from "types";
|
|
// fetch-keys
|
|
import { CYCLE_DETAIL } from "constants/fetch-keys";
|
|
|
|
type Props = {
|
|
cycle: ICycle | undefined;
|
|
isOpen: boolean;
|
|
cycleIssues: CycleIssueResponse[];
|
|
};
|
|
|
|
const defaultValues: Partial<ICycle> = {
|
|
start_date: new Date().toString(),
|
|
end_date: new Date().toString(),
|
|
};
|
|
|
|
const CycleDetailSidebar: React.FC<Props> = ({ cycle, isOpen, cycleIssues }) => {
|
|
const router = useRouter();
|
|
const {
|
|
query: { workspaceSlug, projectId },
|
|
} = router;
|
|
|
|
const { setToastAlert } = useToast();
|
|
|
|
const { reset, control } = useForm({
|
|
defaultValues,
|
|
});
|
|
|
|
const groupedIssues = {
|
|
backlog: [],
|
|
unstarted: [],
|
|
started: [],
|
|
cancelled: [],
|
|
completed: [],
|
|
...groupBy(cycleIssues ?? [], "issue_detail.state_detail.group"),
|
|
};
|
|
|
|
const submitChanges = (data: Partial<ICycle>) => {
|
|
if (!workspaceSlug || !projectId || !module) return;
|
|
|
|
cyclesService
|
|
.patchCycle(workspaceSlug as string, projectId as string, cycle?.id ?? "", data)
|
|
.then((res) => {
|
|
console.log(res);
|
|
mutate(CYCLE_DETAIL);
|
|
})
|
|
.catch((e) => {
|
|
console.log(e);
|
|
});
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (cycle)
|
|
reset({
|
|
...cycle,
|
|
});
|
|
}, [cycle, reset]);
|
|
|
|
return (
|
|
<div
|
|
className={`fixed top-0 ${
|
|
isOpen ? "right-0" : "-right-[24rem]"
|
|
} z-20 h-full w-[24rem] overflow-y-auto border-l bg-gray-50 p-5 duration-300`}
|
|
>
|
|
{cycle ? (
|
|
<>
|
|
<div className="flex items-center justify-between pb-3">
|
|
<h4 className="text-sm font-medium">{cycle.name}</h4>
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
<button
|
|
type="button"
|
|
className="rounded-md border p-2 shadow-sm duration-300 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"
|
|
onClick={() =>
|
|
copyTextToClipboard(
|
|
`https://app.plane.so/${workspaceSlug}/projects/${projectId}/cycles/${cycle.id}`
|
|
)
|
|
.then(() => {
|
|
setToastAlert({
|
|
type: "success",
|
|
title: "Cycle link copied to clipboard",
|
|
});
|
|
})
|
|
.catch(() => {
|
|
setToastAlert({
|
|
type: "error",
|
|
title: "Some error occurred",
|
|
});
|
|
})
|
|
}
|
|
>
|
|
<LinkIcon className="h-3.5 w-3.5" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div className="divide-y-2 divide-gray-100 text-xs">
|
|
<div className="py-1">
|
|
<div className="flex flex-wrap items-center py-2">
|
|
<div className="flex items-center gap-x-2 text-sm sm:basis-1/2">
|
|
<UserIcon className="h-4 w-4 flex-shrink-0" />
|
|
<p>Owned by</p>
|
|
</div>
|
|
<div className="sm:basis-1/2">
|
|
{cycle.owned_by.first_name !== "" ? (
|
|
<>
|
|
{cycle.owned_by.first_name} {cycle.owned_by.last_name}
|
|
</>
|
|
) : (
|
|
cycle.owned_by.email
|
|
)}
|
|
</div>
|
|
</div>
|
|
<div className="flex flex-wrap items-center py-2">
|
|
<div className="flex items-center gap-x-2 text-sm sm:basis-1/2">
|
|
<ChartPieIcon className="h-4 w-4 flex-shrink-0" />
|
|
<p>Progress</p>
|
|
</div>
|
|
<div className="flex items-center gap-2 sm:basis-1/2">
|
|
<div className="grid flex-shrink-0 place-items-center">
|
|
<span className="h-4 w-4 rounded-full border-2 border-gray-300 border-r-blue-500" />
|
|
</div>
|
|
{groupedIssues.completed.length}/{cycleIssues?.length}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="py-1">
|
|
<div className="flex flex-wrap items-center py-2">
|
|
<div className="flex items-center gap-x-2 text-sm sm:basis-1/2">
|
|
<CalendarDaysIcon className="h-4 w-4 flex-shrink-0" />
|
|
<p>Start date</p>
|
|
</div>
|
|
<div className="sm:basis-1/2">
|
|
<Controller
|
|
control={control}
|
|
name="start_date"
|
|
render={({ field: { value, onChange } }) => (
|
|
<input
|
|
type="date"
|
|
id="cycleStartDate"
|
|
value={value ?? ""}
|
|
onChange={(e: any) => {
|
|
submitChanges({ start_date: e.target.value });
|
|
onChange(e.target.value);
|
|
}}
|
|
className="w-full cursor-pointer rounded-md border bg-transparent px-2 py-1 text-xs shadow-sm duration-300 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"
|
|
/>
|
|
)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div className="flex flex-wrap items-center py-2">
|
|
<div className="flex items-center gap-x-2 text-sm sm:basis-1/2">
|
|
<CalendarDaysIcon className="h-4 w-4 flex-shrink-0" />
|
|
<p>End date</p>
|
|
</div>
|
|
<div className="sm:basis-1/2">
|
|
<Controller
|
|
control={control}
|
|
name="end_date"
|
|
render={({ field: { value, onChange } }) => (
|
|
<input
|
|
type="date"
|
|
id="moduleEndDate"
|
|
value={value ?? ""}
|
|
onChange={(e: any) => {
|
|
submitChanges({ end_date: e.target.value });
|
|
onChange(e.target.value);
|
|
}}
|
|
className="w-full cursor-pointer rounded-md border bg-transparent px-2 py-1 text-xs shadow-sm duration-300 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"
|
|
/>
|
|
)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="py-1" />
|
|
</div>
|
|
</>
|
|
) : (
|
|
<Loader>
|
|
<div className="space-y-2">
|
|
<Loader.Item height="15px" width="50%" />
|
|
<Loader.Item height="15px" width="30%" />
|
|
</div>
|
|
<div className="mt-8 space-y-3">
|
|
<Loader.Item height="30px" />
|
|
<Loader.Item height="30px" />
|
|
<Loader.Item height="30px" />
|
|
</div>
|
|
</Loader>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default CycleDetailSidebar;
|