2023-10-17 07:16:38 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-10-23 13:47:42 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2023-11-03 13:47:13 +00:00
|
|
|
import { Plus } from "lucide-react";
|
2023-10-23 13:47:42 +00:00
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
// hooks
|
|
|
|
import useLocalStorage from "hooks/use-local-storage";
|
2023-10-17 07:16:38 +00:00
|
|
|
// ui
|
2023-11-03 12:31:49 +00:00
|
|
|
import { Breadcrumbs, Button, Tooltip, DiceIcon } from "@plane/ui";
|
2023-10-17 07:16:38 +00:00
|
|
|
// helper
|
2023-11-03 12:31:49 +00:00
|
|
|
import { renderEmoji } from "helpers/emoji.helper";
|
2023-11-03 13:47:13 +00:00
|
|
|
// constants
|
|
|
|
import { MODULE_VIEW_LAYOUTS } from "constants/module";
|
2023-10-17 07:16:38 +00:00
|
|
|
|
2023-10-23 13:47:42 +00:00
|
|
|
export const ModulesListHeader: React.FC = observer(() => {
|
2023-10-17 07:16:38 +00:00
|
|
|
// router
|
|
|
|
const router = useRouter();
|
2023-11-01 13:52:10 +00:00
|
|
|
const { workspaceSlug } = router.query;
|
|
|
|
// store
|
2023-10-23 13:47:42 +00:00
|
|
|
const { project: projectStore } = useMobxStore();
|
2023-11-01 13:52:10 +00:00
|
|
|
const { currentProjectDetails } = projectStore;
|
2023-10-23 13:47:42 +00:00
|
|
|
|
|
|
|
const { storedValue: modulesView, setValue: setModulesView } = useLocalStorage("modules_view", "grid");
|
2023-10-17 07:16:38 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2023-10-17 11:55:02 +00:00
|
|
|
className={`relative z-10 flex w-full flex-shrink-0 flex-row items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4`}
|
2023-10-17 07:16:38 +00:00
|
|
|
>
|
2023-10-17 11:55:02 +00:00
|
|
|
<div className="flex w-full flex-grow items-center gap-2 overflow-ellipsis whitespace-nowrap">
|
2023-10-17 07:16:38 +00:00
|
|
|
<div>
|
2023-11-03 12:31:49 +00:00
|
|
|
<Breadcrumbs>
|
|
|
|
<Breadcrumbs.BreadcrumbItem
|
|
|
|
type="text"
|
|
|
|
label={currentProjectDetails?.name ?? "Project"}
|
|
|
|
icon={
|
|
|
|
currentProjectDetails?.emoji ? (
|
|
|
|
renderEmoji(currentProjectDetails.emoji)
|
|
|
|
) : currentProjectDetails?.icon_prop ? (
|
|
|
|
renderEmoji(currentProjectDetails.icon_prop)
|
|
|
|
) : (
|
|
|
|
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded bg-gray-700 uppercase text-white">
|
|
|
|
{currentProjectDetails?.name.charAt(0)}
|
|
|
|
</span>
|
|
|
|
)
|
2023-10-17 11:55:02 +00:00
|
|
|
}
|
2023-11-03 12:31:49 +00:00
|
|
|
link={`/${workspaceSlug}/projects/${currentProjectDetails?.id}/issues`}
|
|
|
|
/>
|
|
|
|
<Breadcrumbs.BreadcrumbItem
|
|
|
|
type="text"
|
|
|
|
icon={<DiceIcon className="h-4 w-4 text-custom-text-300" />}
|
|
|
|
label="Modules"
|
2023-10-17 11:55:02 +00:00
|
|
|
/>
|
2023-10-17 07:16:38 +00:00
|
|
|
</Breadcrumbs>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center gap-2">
|
2023-11-03 13:47:13 +00:00
|
|
|
<div className="flex items-center gap-1 p-1 rounded bg-custom-background-80">
|
|
|
|
{MODULE_VIEW_LAYOUTS.map((layout) => (
|
|
|
|
<Tooltip key={layout.key} tooltipContent={layout.title}>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className={`w-7 h-[22px] rounded grid place-items-center transition-all hover:bg-custom-background-100 overflow-hidden group ${
|
|
|
|
modulesView == layout.key ? "bg-custom-background-100 shadow-custom-shadow-2xs" : ""
|
|
|
|
}`}
|
|
|
|
onClick={() => setModulesView(layout.key)}
|
|
|
|
>
|
|
|
|
<layout.icon
|
|
|
|
strokeWidth={2}
|
|
|
|
className={`h-3.5 w-3.5 ${
|
|
|
|
modulesView == layout.key ? "text-custom-text-100" : "text-custom-text-200"
|
|
|
|
}`}
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
</Tooltip>
|
|
|
|
))}
|
|
|
|
</div>
|
2023-10-17 07:16:38 +00:00
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
prependIcon={<Plus />}
|
|
|
|
onClick={() => {
|
|
|
|
const e = new KeyboardEvent("keydown", { key: "m" });
|
|
|
|
document.dispatchEvent(e);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Add Module
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2023-10-23 13:47:42 +00:00
|
|
|
});
|