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>
207 lines
7.9 KiB
TypeScript
207 lines
7.9 KiB
TypeScript
import React from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
// hooks
|
|
import useIssuesProperties from "hooks/use-issue-properties";
|
|
import useIssueView from "hooks/use-issue-view";
|
|
// headless ui
|
|
import { Popover, Transition } from "@headlessui/react";
|
|
// ui
|
|
import { CustomMenu } from "components/ui";
|
|
// icons
|
|
import { ChevronDownIcon, ListBulletIcon } from "@heroicons/react/24/outline";
|
|
import { Squares2X2Icon } from "@heroicons/react/20/solid";
|
|
// helpers
|
|
import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper";
|
|
// types
|
|
import { IIssue, Properties } from "types";
|
|
// common
|
|
import { filterIssueOptions, groupByOptions, orderByOptions } from "constants/";
|
|
|
|
type Props = {
|
|
issues?: IIssue[];
|
|
};
|
|
|
|
const View: React.FC<Props> = ({ issues }) => {
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
const {
|
|
issueView,
|
|
setIssueViewToList,
|
|
setIssueViewToKanban,
|
|
groupByProperty,
|
|
setGroupByProperty,
|
|
setOrderBy,
|
|
setFilterIssue,
|
|
orderBy,
|
|
filterIssue,
|
|
resetFilterToDefault,
|
|
setNewFilterDefaultView,
|
|
} = useIssueView(issues ?? []);
|
|
|
|
const [properties, setProperties] = useIssuesProperties(
|
|
workspaceSlug as string,
|
|
projectId as string
|
|
);
|
|
|
|
return (
|
|
<div className="flex items-center gap-2">
|
|
<div className="flex items-center gap-x-1">
|
|
{issues && (
|
|
<>
|
|
<button
|
|
type="button"
|
|
className={`grid h-7 w-7 place-items-center rounded p-1 outline-none duration-300 hover:bg-gray-200 ${
|
|
issueView === "list" ? "bg-gray-200" : ""
|
|
}`}
|
|
onClick={() => setIssueViewToList()}
|
|
>
|
|
<ListBulletIcon className="h-4 w-4" />
|
|
</button>
|
|
<button
|
|
type="button"
|
|
className={`grid h-7 w-7 place-items-center rounded p-1 outline-none duration-300 hover:bg-gray-200 ${
|
|
issueView === "kanban" ? "bg-gray-200" : ""
|
|
}`}
|
|
onClick={() => setIssueViewToKanban()}
|
|
>
|
|
<Squares2X2Icon className="h-4 w-4" />
|
|
</button>
|
|
</>
|
|
)}
|
|
</div>
|
|
<Popover className="relative">
|
|
{({ open }) => (
|
|
<>
|
|
<Popover.Button
|
|
className={`group flex items-center gap-2 rounded-md border bg-transparent p-2 text-xs font-medium hover:bg-gray-100 hover:text-gray-900 focus:outline-none ${
|
|
open ? "bg-gray-100 text-gray-900" : "text-gray-500"
|
|
}`}
|
|
>
|
|
<span>View</span>
|
|
<ChevronDownIcon className="h-4 w-4" aria-hidden="true" />
|
|
</Popover.Button>
|
|
|
|
<Transition
|
|
as={React.Fragment}
|
|
enter="transition ease-out duration-200"
|
|
enterFrom="opacity-0 translate-y-1"
|
|
enterTo="opacity-100 translate-y-0"
|
|
leave="transition ease-in duration-150"
|
|
leaveFrom="opacity-100 translate-y-0"
|
|
leaveTo="opacity-0 translate-y-1"
|
|
>
|
|
<Popover.Panel className="absolute right-0 z-20 mt-1 w-screen max-w-xs transform overflow-hidden rounded-lg bg-white p-3 shadow-lg">
|
|
<div className="relative divide-y-2">
|
|
{issues && (
|
|
<div className="space-y-4 pb-3">
|
|
<div className="flex items-center justify-between">
|
|
<h4 className="text-sm text-gray-600">Group by</h4>
|
|
<CustomMenu
|
|
label={
|
|
groupByOptions.find((option) => option.key === groupByProperty)?.name ??
|
|
"Select"
|
|
}
|
|
width="lg"
|
|
>
|
|
{groupByOptions.map((option) => (
|
|
<CustomMenu.MenuItem
|
|
key={option.key}
|
|
onClick={() => setGroupByProperty(option.key)}
|
|
>
|
|
{option.name}
|
|
</CustomMenu.MenuItem>
|
|
))}
|
|
</CustomMenu>
|
|
</div>
|
|
<div className="flex items-center justify-between">
|
|
<h4 className="text-sm text-gray-600">Order by</h4>
|
|
<CustomMenu
|
|
label={
|
|
orderByOptions.find((option) => option.key === orderBy)?.name ??
|
|
"Select"
|
|
}
|
|
width="lg"
|
|
>
|
|
{orderByOptions.map((option) =>
|
|
groupByProperty === "priority" && option.key === "priority" ? null : (
|
|
<CustomMenu.MenuItem
|
|
key={option.key}
|
|
onClick={() => setOrderBy(option.key)}
|
|
>
|
|
{option.name}
|
|
</CustomMenu.MenuItem>
|
|
)
|
|
)}
|
|
</CustomMenu>
|
|
</div>
|
|
<div className="flex items-center justify-between">
|
|
<h4 className="text-sm text-gray-600">Issue type</h4>
|
|
<CustomMenu
|
|
label={
|
|
filterIssueOptions.find((option) => option.key === filterIssue)?.name ??
|
|
"Select"
|
|
}
|
|
width="lg"
|
|
>
|
|
{filterIssueOptions.map((option) => (
|
|
<CustomMenu.MenuItem
|
|
key={option.key}
|
|
onClick={() => setFilterIssue(option.key)}
|
|
>
|
|
{option.name}
|
|
</CustomMenu.MenuItem>
|
|
))}
|
|
</CustomMenu>
|
|
</div>
|
|
<div className="relative flex justify-end gap-x-3">
|
|
<button
|
|
type="button"
|
|
className="text-xs"
|
|
onClick={() => resetFilterToDefault()}
|
|
>
|
|
Reset to default
|
|
</button>
|
|
<button
|
|
type="button"
|
|
className="text-xs font-medium text-theme"
|
|
onClick={() => setNewFilterDefaultView()}
|
|
>
|
|
Set as default
|
|
</button>
|
|
</div>
|
|
</div>
|
|
)}
|
|
<div className="space-y-2 py-3">
|
|
<h4 className="text-sm text-gray-600">Display Properties</h4>
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
{Object.keys(properties).map((key) => (
|
|
<button
|
|
key={key}
|
|
type="button"
|
|
className={`rounded border px-2 py-1 text-xs capitalize ${
|
|
properties[key as keyof Properties]
|
|
? "border-theme bg-theme text-white"
|
|
: "border-gray-300"
|
|
}`}
|
|
onClick={() => setProperties(key as keyof Properties)}
|
|
>
|
|
{replaceUnderscoreIfSnakeCase(key)}
|
|
</button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Popover.Panel>
|
|
</Transition>
|
|
</>
|
|
)}
|
|
</Popover>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default View;
|