2023-01-26 18:12:20 +00:00
|
|
|
import React from "react";
|
2023-05-11 12:08:46 +00:00
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
import Link from "next/link";
|
2023-07-18 06:37:55 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-05-11 12:08:46 +00:00
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
// hooks
|
|
|
|
import useTheme from "hooks/use-theme";
|
2023-07-20 09:44:57 +00:00
|
|
|
// components
|
2023-07-18 06:37:55 +00:00
|
|
|
import { NotificationPopover } from "components/notifications";
|
2023-07-20 09:44:57 +00:00
|
|
|
// ui
|
|
|
|
import { Tooltip } from "components/ui";
|
|
|
|
// icons
|
|
|
|
import {
|
|
|
|
BarChartRounded,
|
|
|
|
GridViewOutlined,
|
|
|
|
TaskAltOutlined,
|
|
|
|
WorkOutlineOutlined,
|
|
|
|
} from "@mui/icons-material";
|
2023-08-08 07:20:27 +00:00
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-07-18 06:37:55 +00:00
|
|
|
|
|
|
|
const workspaceLinks = (workspaceSlug: string) => [
|
|
|
|
{
|
2023-07-20 09:44:57 +00:00
|
|
|
Icon: GridViewOutlined,
|
2023-07-18 06:37:55 +00:00
|
|
|
name: "Dashboard",
|
|
|
|
href: `/${workspaceSlug}`,
|
|
|
|
},
|
|
|
|
{
|
2023-07-20 09:44:57 +00:00
|
|
|
Icon: BarChartRounded,
|
2023-07-18 06:37:55 +00:00
|
|
|
name: "Analytics",
|
|
|
|
href: `/${workspaceSlug}/analytics`,
|
|
|
|
},
|
|
|
|
{
|
2023-07-20 09:44:57 +00:00
|
|
|
Icon: WorkOutlineOutlined,
|
2023-07-18 06:37:55 +00:00
|
|
|
name: "Projects",
|
|
|
|
href: `/${workspaceSlug}/projects`,
|
|
|
|
},
|
|
|
|
{
|
2023-07-20 09:44:57 +00:00
|
|
|
Icon: TaskAltOutlined,
|
2023-07-18 06:37:55 +00:00
|
|
|
name: "My Issues",
|
|
|
|
href: `/${workspaceSlug}/me/my-issues`,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-05-16 05:11:37 +00:00
|
|
|
export const WorkspaceSidebarMenu = () => {
|
2023-08-08 07:20:27 +00:00
|
|
|
const store: any = useMobxStore();
|
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug } = router.query;
|
2023-05-11 12:08:46 +00:00
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
const { collapsed: sidebarCollapse } = useTheme();
|
|
|
|
|
|
|
|
return (
|
2023-08-01 06:54:34 +00:00
|
|
|
<div className="w-full cursor-pointer space-y-2 px-4 mt-5 pb-5">
|
2023-07-10 07:17:00 +00:00
|
|
|
{workspaceLinks(workspaceSlug as string).map((link, index) => {
|
|
|
|
const isActive =
|
|
|
|
link.name === "Settings"
|
|
|
|
? router.asPath.includes(link.href)
|
|
|
|
: router.asPath === link.href;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Link key={index} href={link.href}>
|
2023-07-13 13:05:43 +00:00
|
|
|
<a className="block w-full">
|
|
|
|
<Tooltip
|
|
|
|
tooltipContent={link.name}
|
|
|
|
position="right"
|
|
|
|
className="ml-2"
|
2023-08-08 07:20:27 +00:00
|
|
|
disabled={!store?.theme?.sidebarCollapsed}
|
2023-07-13 13:05:43 +00:00
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium outline-none ${
|
2023-07-10 07:17:00 +00:00
|
|
|
isActive
|
2023-07-13 13:05:43 +00:00
|
|
|
? "bg-custom-primary-100/10 text-custom-primary-100"
|
|
|
|
: "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:bg-custom-sidebar-background-80"
|
2023-08-08 07:20:27 +00:00
|
|
|
} ${store?.theme?.sidebarCollapsed ? "justify-center" : ""}`}
|
2023-07-13 13:05:43 +00:00
|
|
|
>
|
2023-07-20 09:44:57 +00:00
|
|
|
{<link.Icon fontSize="small" />}
|
2023-08-08 07:20:27 +00:00
|
|
|
{!store?.theme?.sidebarCollapsed && link.name}
|
2023-07-13 13:05:43 +00:00
|
|
|
</div>
|
|
|
|
</Tooltip>
|
2023-07-10 07:17:00 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
})}
|
2023-07-18 06:37:55 +00:00
|
|
|
|
|
|
|
<NotificationPopover />
|
2023-01-26 18:12:20 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|