mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
045973a432
This PR decouples the forms for creating API tokens and project level API tokens. The point of having a hook that provides the functionality for the form is that we can create specific forms that take care of implementing the logic needed for that form instead of having one form serving multiple use cases.
78 lines
2.3 KiB
TypeScript
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/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>
|
|
);
|
|
};
|