mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
48b55ef261
* style: custom scrollbar added * chore: scrollbar added in issue layouts * chore: scrollbar added in sidebar and workspace pages * chore: calendar layout fix * chore: project level scrollbar added * chore: scrollbar added in command k modal * fix: calendar layout alignment fix
93 lines
3.4 KiB
TypeScript
93 lines
3.4 KiB
TypeScript
import { ReactElement } from "react";
|
|
import { useRouter } from "next/router";
|
|
import useSWR from "swr";
|
|
import { observer } from "mobx-react";
|
|
// hooks
|
|
import { useModule, useProject } from "hooks/store";
|
|
import useLocalStorage from "hooks/use-local-storage";
|
|
// layouts
|
|
import { AppLayout } from "layouts/app-layout";
|
|
// components
|
|
import { ModuleDetailsSidebar } from "components/modules";
|
|
import { ModuleLayoutRoot } from "components/issues";
|
|
import { ModuleIssuesHeader } from "components/headers";
|
|
import { PageHead } from "components/core";
|
|
import { EmptyState } from "components/common";
|
|
// assets
|
|
import emptyModule from "public/empty-state/module.svg";
|
|
// types
|
|
import { NextPageWithLayout } from "lib/types";
|
|
|
|
const ModuleIssuesPage: NextPageWithLayout = observer(() => {
|
|
// router
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId, moduleId } = router.query;
|
|
// store hooks
|
|
const { fetchModuleDetails, getModuleById } = useModule();
|
|
const { getProjectById } = useProject();
|
|
// local storage
|
|
const { setValue, storedValue } = useLocalStorage("module_sidebar_collapsed", "false");
|
|
const isSidebarCollapsed = storedValue ? (storedValue === "true" ? true : false) : false;
|
|
// fetching module details
|
|
const { error } = useSWR(
|
|
workspaceSlug && projectId && moduleId ? `CURRENT_MODULE_DETAILS_${moduleId.toString()}` : null,
|
|
workspaceSlug && projectId && moduleId
|
|
? () => fetchModuleDetails(workspaceSlug.toString(), projectId.toString(), moduleId.toString())
|
|
: null
|
|
);
|
|
// derived values
|
|
const projectModule = moduleId ? getModuleById(moduleId.toString()) : undefined;
|
|
const project = projectId ? getProjectById(projectId.toString()) : undefined;
|
|
const pageTitle = project?.name && projectModule?.name ? `${project?.name} - ${projectModule?.name}` : undefined;
|
|
|
|
const toggleSidebar = () => {
|
|
setValue(`${!isSidebarCollapsed}`);
|
|
};
|
|
|
|
if (!workspaceSlug || !projectId || !moduleId) return <></>;
|
|
|
|
return (
|
|
<>
|
|
<PageHead title={pageTitle} />
|
|
{error ? (
|
|
<EmptyState
|
|
image={emptyModule}
|
|
title="Module does not exist"
|
|
description="The module you are looking for does not exist or has been deleted."
|
|
primaryButton={{
|
|
text: "View other modules",
|
|
onClick: () => router.push(`/${workspaceSlug}/projects/${projectId}/modules`),
|
|
}}
|
|
/>
|
|
) : (
|
|
<div className="flex h-full w-full">
|
|
<div className="h-full w-full overflow-hidden">
|
|
<ModuleLayoutRoot />
|
|
</div>
|
|
{moduleId && !isSidebarCollapsed && (
|
|
<div
|
|
className="flex h-full w-[24rem] flex-shrink-0 flex-col gap-3.5 overflow-y-auto border-l border-custom-border-100 bg-custom-sidebar-background-100 px-6 py-3.5 duration-300 vertical-scrollbar scrollbar-sm"
|
|
style={{
|
|
boxShadow:
|
|
"0px 1px 4px 0px rgba(0, 0, 0, 0.06), 0px 2px 4px 0px rgba(16, 24, 40, 0.06), 0px 1px 8px -1px rgba(16, 24, 40, 0.06)",
|
|
}}
|
|
>
|
|
<ModuleDetailsSidebar moduleId={moduleId.toString()} handleClose={toggleSidebar} />
|
|
</div>
|
|
)}
|
|
</div>
|
|
)}
|
|
</>
|
|
);
|
|
});
|
|
|
|
ModuleIssuesPage.getLayout = function getLayout(page: ReactElement) {
|
|
return (
|
|
<AppLayout header={<ModuleIssuesHeader />} withProjectWrapper>
|
|
{page}
|
|
</AppLayout>
|
|
);
|
|
};
|
|
|
|
export default ModuleIssuesPage;
|