2022-11-10 10:46:23 +01:00
|
|
|
import {
|
2022-12-06 09:05:49 +01:00
|
|
|
Navigate,
|
2022-11-10 10:46:23 +01:00
|
|
|
Route,
|
|
|
|
Routes,
|
|
|
|
useLocation,
|
|
|
|
useNavigate,
|
|
|
|
} from 'react-router-dom';
|
|
|
|
import { ITab, VerticalTabs } from 'component/common/VerticalTabs/VerticalTabs';
|
|
|
|
import { ProjectAccess } from 'component/project/ProjectAccess/ProjectAccess';
|
|
|
|
import ProjectEnvironmentList from 'component/project/ProjectEnvironment/ProjectEnvironment';
|
|
|
|
import { ChangeRequestConfiguration } from './ChangeRequestConfiguration/ChangeRequestConfiguration';
|
2023-02-07 12:01:45 +01:00
|
|
|
import { ProjectApiAccess } from './ProjectApiAccess';
|
|
|
|
import useUiConfig from '../../../../hooks/api/getters/useUiConfig/useUiConfig';
|
2022-11-10 10:46:23 +01:00
|
|
|
|
|
|
|
export const ProjectSettings = () => {
|
|
|
|
const location = useLocation();
|
|
|
|
const navigate = useNavigate();
|
2023-02-07 12:01:45 +01:00
|
|
|
const { uiConfig } = useUiConfig();
|
|
|
|
const { showProjectApiAccess } = uiConfig.flags;
|
2022-11-10 10:46:23 +01:00
|
|
|
|
2022-12-06 09:05:49 +01:00
|
|
|
const tabs: ITab[] = [
|
|
|
|
{
|
|
|
|
id: 'environments',
|
|
|
|
label: 'Environments',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'access',
|
|
|
|
label: 'Access',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'change-requests',
|
|
|
|
label: 'Change request configuration',
|
|
|
|
},
|
2022-11-10 10:46:23 +01:00
|
|
|
];
|
|
|
|
|
2023-02-07 12:01:45 +01:00
|
|
|
if (Boolean(showProjectApiAccess)) {
|
|
|
|
tabs.push({
|
|
|
|
id: 'api-access',
|
|
|
|
label: 'API access',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-11-10 10:46:23 +01:00
|
|
|
const onChange = (tab: ITab) => {
|
|
|
|
navigate(tab.id);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<VerticalTabs
|
|
|
|
tabs={tabs}
|
|
|
|
value={
|
|
|
|
tabs.find(
|
|
|
|
({ id }) => id && location.pathname?.includes(`/${id}`)
|
|
|
|
)?.id || tabs[0].id
|
|
|
|
}
|
|
|
|
onChange={onChange}
|
|
|
|
>
|
|
|
|
<Routes>
|
|
|
|
<Route
|
2022-12-06 09:05:49 +01:00
|
|
|
path="environments/*"
|
2022-11-10 10:46:23 +01:00
|
|
|
element={<ProjectEnvironmentList />}
|
|
|
|
/>
|
2022-12-06 09:05:49 +01:00
|
|
|
<Route path="access/*" element={<ProjectAccess />} />
|
2022-11-10 10:46:23 +01:00
|
|
|
<Route
|
2022-12-06 09:05:49 +01:00
|
|
|
path="change-requests/*"
|
2022-11-10 10:46:23 +01:00
|
|
|
element={<ChangeRequestConfiguration />}
|
|
|
|
/>
|
2023-02-07 12:01:45 +01:00
|
|
|
{Boolean(showProjectApiAccess) && (
|
|
|
|
<Route path="api-access/*" element={<ProjectApiAccess />} />
|
|
|
|
)}
|
2022-11-10 10:46:23 +01:00
|
|
|
<Route
|
|
|
|
path="*"
|
|
|
|
element={<Navigate replace to={tabs[0].id} />}
|
|
|
|
/>
|
|
|
|
</Routes>
|
|
|
|
</VerticalTabs>
|
|
|
|
);
|
|
|
|
};
|