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-08 12:42:54 +01:00
|
|
|
|
import { Alert } 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';
|
2024-01-22 15:34:10 +01:00
|
|
|
|
import {
|
|
|
|
|
PROJECT_USER_ACCESS_READ,
|
|
|
|
|
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-12-08 12:42:54 +01:00
|
|
|
|
import { PremiumFeature } from 'component/common/PremiumFeature/PremiumFeature';
|
2024-05-20 14:20:13 +02:00
|
|
|
|
import { useProjectOverviewNameOrId } from 'hooks/api/getters/useProjectOverview/useProjectOverview';
|
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');
|
2024-05-20 14:20:13 +02:00
|
|
|
|
const projectName = useProjectOverviewNameOrId(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-12-08 12:42:54 +01:00
|
|
|
|
<PageContent
|
2023-10-02 14:25:46 +02:00
|
|
|
|
header={<PageHeader title='Access' />}
|
2022-12-08 12:42:54 +01:00
|
|
|
|
sx={{ justifyContent: 'center' }}
|
|
|
|
|
>
|
2023-10-02 14:25:46 +02:00
|
|
|
|
<PremiumFeature feature='access' />
|
2022-05-26 10:37:33 +02:00
|
|
|
|
</PageContent>
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-02-09 12:25:02 +01:00
|
|
|
|
|
2024-01-22 15:34:10 +01:00
|
|
|
|
if (!hasAccess([UPDATE_PROJECT, PROJECT_USER_ACCESS_READ], projectId)) {
|
2022-06-03 08:14:47 +02:00
|
|
|
|
return (
|
2023-10-02 14:25:46 +02:00
|
|
|
|
<PageContent header={<PageHeader title='Access' />}>
|
|
|
|
|
<Alert severity='error'>
|
2022-06-03 08:14:47 +02:00
|
|
|
|
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
|
|
|
|
};
|