1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/frontend/src/component/project/Project/ProjectSettings/ProjectSettings.tsx
andreas-unleash d14072ff74
show api access screen in projet settings (#3056)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #
[1-612](https://linear.app/unleash/issue/1-612/first-iteration-of-project-token-management)

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-02-07 13:01:45 +02:00

78 lines
2.3 KiB
TypeScript

import {
Navigate,
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';
import { ProjectApiAccess } from './ProjectApiAccess';
import useUiConfig from '../../../../hooks/api/getters/useUiConfig/useUiConfig';
export const ProjectSettings = () => {
const location = useLocation();
const navigate = useNavigate();
const { uiConfig } = useUiConfig();
const { showProjectApiAccess } = uiConfig.flags;
const tabs: ITab[] = [
{
id: 'environments',
label: 'Environments',
},
{
id: 'access',
label: 'Access',
},
{
id: 'change-requests',
label: 'Change request configuration',
},
];
if (Boolean(showProjectApiAccess)) {
tabs.push({
id: 'api-access',
label: 'API access',
});
}
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
path="environments/*"
element={<ProjectEnvironmentList />}
/>
<Route path="access/*" element={<ProjectAccess />} />
<Route
path="change-requests/*"
element={<ChangeRequestConfiguration />}
/>
{Boolean(showProjectApiAccess) && (
<Route path="api-access/*" element={<ProjectApiAccess />} />
)}
<Route
path="*"
element={<Navigate replace to={tabs[0].id} />}
/>
</Routes>
</VerticalTabs>
);
};