2023-10-18 13:47:02 +00:00
|
|
|
import { FC, ReactNode } from "react";
|
2023-12-06 08:52:06 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-10-18 13:47:02 +00:00
|
|
|
// components
|
|
|
|
import { ProjectSettingsSidebar } from "./sidebar";
|
2023-12-04 14:33:23 +00:00
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
|
|
|
import { NotAuthorizedView } from "components/auth-screens";
|
|
|
|
import { observer } from "mobx-react-lite";
|
2023-12-06 08:52:06 +00:00
|
|
|
import { Button, LayersIcon } from "@plane/ui";
|
2023-10-18 13:47:02 +00:00
|
|
|
|
|
|
|
export interface IProjectSettingLayout {
|
|
|
|
children: ReactNode;
|
|
|
|
}
|
|
|
|
|
2023-12-04 14:33:23 +00:00
|
|
|
export const ProjectSettingLayout: FC<IProjectSettingLayout> = observer((props) => {
|
2023-10-25 10:18:57 +00:00
|
|
|
const { children } = props;
|
2023-10-18 13:47:02 +00:00
|
|
|
|
2023-12-06 08:52:06 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
|
2023-12-04 14:33:23 +00:00
|
|
|
const {
|
|
|
|
user: { currentProjectRole },
|
|
|
|
} = useMobxStore();
|
|
|
|
|
|
|
|
const restrictViewSettings = currentProjectRole && currentProjectRole <= EUserWorkspaceRoles.VIEWER;
|
|
|
|
|
|
|
|
return restrictViewSettings ? (
|
2023-12-06 08:52:06 +00:00
|
|
|
<NotAuthorizedView
|
|
|
|
type="project"
|
|
|
|
actionButton={
|
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
size="md"
|
|
|
|
prependIcon={<LayersIcon />}
|
|
|
|
onClick={() => router.push(`/${workspaceSlug}/projects/${projectId}/issues`)}
|
|
|
|
>
|
|
|
|
Go to issues
|
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
/>
|
2023-12-04 14:33:23 +00:00
|
|
|
) : (
|
2023-12-10 10:18:10 +00:00
|
|
|
<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">
|
2023-10-25 10:18:57 +00:00
|
|
|
<ProjectSettingsSidebar />
|
|
|
|
</div>
|
|
|
|
{children}
|
|
|
|
</div>
|
2023-10-18 13:47:02 +00:00
|
|
|
);
|
2023-12-04 14:33:23 +00:00
|
|
|
});
|