plane/web/layouts/settings-layout/project/layout.tsx
rahulramesha 1257a88089 fix: breaking cycle issues and replacing router.push with Links (#3330)
* fix cycle creation and active cycle map

* minor fix in cycle store

* create cycle breaking fix

* replace last possible bits of router.push with Link

---------

Co-authored-by: Rahul R <rahulr@Rahuls-MacBook-Pro.local>
2024-01-22 13:19:43 +05:30

52 lines
1.5 KiB
TypeScript

import { FC, ReactNode } from "react";
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
import Link from "next/link";
// hooks
import { useUser } from "hooks/store";
// components
import { ProjectSettingsSidebar } from "./sidebar";
import { NotAuthorizedView } from "components/auth-screens";
// ui
import { Button, LayersIcon } from "@plane/ui";
// constants
import { EUserProjectRoles } from "constants/project";
export interface IProjectSettingLayout {
children: ReactNode;
}
export const ProjectSettingLayout: FC<IProjectSettingLayout> = observer((props) => {
const { children } = props;
// router
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
// store hooks
const {
membership: { currentProjectRole },
} = useUser();
const restrictViewSettings = currentProjectRole && currentProjectRole <= EUserProjectRoles.VIEWER;
return restrictViewSettings ? (
<NotAuthorizedView
type="project"
actionButton={
//TODO: Create a new component called Button Link to handle such scenarios
<Link href={`/${workspaceSlug}/projects/${projectId}/issues`}>
<Button variant="primary" size="md" prependIcon={<LayersIcon />}>
Go to issues
</Button>
</Link>
}
/>
) : (
<div className="flex h-full w-full gap-2 overflow-x-hidden overflow-y-scroll">
<div className="w-80 flex-shrink-0 overflow-y-hidden pt-8">
<ProjectSettingsSidebar />
</div>
{children}
</div>
);
});