2022-08-04 13:57:25 +02:00
|
|
|
|
import { useContext } from 'react';
|
2022-05-09 14:38:12 +02:00
|
|
|
|
import { PageContent } from 'component/common/PageContent/PageContent';
|
2022-03-07 09:26:31 +01:00
|
|
|
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
2022-12-06 09:05:49 +01:00
|
|
|
|
import { Alert, Box, Link, styled } from '@mui/material';
|
2022-05-09 14:38:12 +02:00
|
|
|
|
import { PageHeader } from 'component/common/PageHeader/PageHeader';
|
2022-06-03 08:14:47 +02:00
|
|
|
|
import AccessContext from 'contexts/AccessContext';
|
|
|
|
|
import { UPDATE_PROJECT } from 'component/providers/AccessProvider/permissions';
|
2022-05-05 13:42:18 +02:00
|
|
|
|
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
2022-06-21 09:08:37 +02:00
|
|
|
|
import { usePageTitle } from 'hooks/usePageTitle';
|
2022-07-22 09:31:08 +02:00
|
|
|
|
import { ProjectAccessTable } from 'component/project/ProjectAccess/ProjectAccessTable/ProjectAccessTable';
|
2022-08-04 13:57:25 +02:00
|
|
|
|
import { useProjectNameOrId } from 'hooks/api/getters/useProject/useProject';
|
2022-12-06 09:05:49 +01:00
|
|
|
|
import {
|
|
|
|
|
PlausibleOrigin,
|
|
|
|
|
PremiumFeature,
|
|
|
|
|
} from 'component/common/PremiumFeature/PremiumFeature';
|
|
|
|
|
|
|
|
|
|
const StyledLink = styled(Link)(({ theme }) => ({
|
|
|
|
|
fontSize: theme.fontSizes.smallBody,
|
|
|
|
|
width: 'fit-content',
|
|
|
|
|
}));
|
2021-10-12 13:21:45 +02:00
|
|
|
|
|
2022-08-04 13:57:25 +02:00
|
|
|
|
export const ProjectAccess = () => {
|
2022-05-05 13:42:18 +02:00
|
|
|
|
const projectId = useRequiredPathParam('projectId');
|
2022-08-04 13:57:25 +02:00
|
|
|
|
const projectName = useProjectNameOrId(projectId);
|
2022-06-03 08:14:47 +02:00
|
|
|
|
const { hasAccess } = useContext(AccessContext);
|
2021-10-12 13:21:45 +02:00
|
|
|
|
const { isOss } = useUiConfig();
|
2022-06-21 09:08:37 +02:00
|
|
|
|
usePageTitle(`Project access – ${projectName}`);
|
2022-05-26 10:37:33 +02:00
|
|
|
|
|
|
|
|
|
if (isOss()) {
|
|
|
|
|
return (
|
2022-06-03 08:14:47 +02:00
|
|
|
|
<PageContent header={<PageHeader title="Project access" />}>
|
2022-12-06 09:05:49 +01:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: 'inline-flex',
|
|
|
|
|
maxWidth: '50%',
|
|
|
|
|
margin: '0 25%',
|
|
|
|
|
}}
|
|
|
|
|
alignSelf={'center'}
|
|
|
|
|
>
|
|
|
|
|
<PremiumFeature origin={PlausibleOrigin.ACCESS} center>
|
|
|
|
|
<>
|
|
|
|
|
Controlling access to projects requires a paid
|
|
|
|
|
version of Unleash. Check out{' '}
|
|
|
|
|
<StyledLink
|
|
|
|
|
href="https://www.getunleash.io"
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noreferrer"
|
|
|
|
|
>
|
|
|
|
|
getunleash.io
|
|
|
|
|
</StyledLink>{' '}
|
|
|
|
|
to find out more.
|
|
|
|
|
</>
|
|
|
|
|
</PremiumFeature>
|
|
|
|
|
</Box>
|
2022-05-26 10:37:33 +02:00
|
|
|
|
</PageContent>
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-02-09 12:25:02 +01:00
|
|
|
|
|
2022-06-03 08:14:47 +02:00
|
|
|
|
if (!hasAccess(UPDATE_PROJECT, projectId)) {
|
|
|
|
|
return (
|
|
|
|
|
<PageContent header={<PageHeader title="Project access" />}>
|
|
|
|
|
<Alert severity="error">
|
|
|
|
|
You need project owner permissions to access this section.
|
|
|
|
|
</Alert>
|
|
|
|
|
</PageContent>
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-02-09 12:25:02 +01:00
|
|
|
|
|
2022-07-22 09:31:08 +02:00
|
|
|
|
return <ProjectAccessTable />;
|
2021-03-11 13:59:20 +01:00
|
|
|
|
};
|