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
Nuno Góis 4167a60588
feat: biome lint frontend (#4903)
Follows up on https://github.com/Unleash/unleash/pull/4853 to add Biome
to the frontend as well.


![image](https://github.com/Unleash/unleash/assets/14320932/1906faf1-fc29-4172-a4d4-b2716d72cd65)

Added a few `biome-ignore` to speed up the process but we may want to
check and fix them in the future.
2023-10-02 13:25:46 +01:00

104 lines
3.5 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 'component/project/Project/ProjectSettings/ProjectApiAccess/ProjectApiAccess';
import { ProjectSegments } from './ProjectSegments/ProjectSegments';
import { ProjectDefaultStrategySettings } from './ProjectDefaultStrategySettings/ProjectDefaultStrategySettings';
import { Settings } from './Settings/Settings';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { EnterpriseBadge } from 'component/common/EnterpriseBadge/EnterpriseBadge';
import { Box } from '@mui/material';
export const ProjectSettings = () => {
const location = useLocation();
const { isPro, isEnterprise } = useUiConfig();
const navigate = useNavigate();
const tabs: ITab[] = [
...(isPro() || isEnterprise()
? [
{
id: '',
label: 'Settings',
},
{
id: 'access',
label: 'Access',
},
{
id: 'segments',
label: 'Segments',
},
{
id: 'change-requests',
label: 'Change request configuration',
icon: isPro() ? (
<Box sx={{ marginLeft: 'auto' }}>
<EnterpriseBadge />
</Box>
) : undefined,
},
]
: []),
{
id: 'environments',
label: 'Environments',
},
{
id: 'api-access',
label: 'API access',
},
{
id: 'default-strategy',
label: 'Default strategy',
},
];
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='/*' element={<Settings />} />
<Route
path='environments/*'
element={<ProjectEnvironmentList />}
/>
<Route path='access/*' element={<ProjectAccess />} />
<Route path='segments/*' element={<ProjectSegments />} />
<Route
path='change-requests/*'
element={<ChangeRequestConfiguration />}
/>
<Route path='api-access/*' element={<ProjectApiAccess />} />
<Route
path='default-strategy/*'
element={<ProjectDefaultStrategySettings />}
/>
<Route
path='*'
element={<Navigate replace to={tabs[0].id} />}
/>
</Routes>
</VerticalTabs>
);
};