Skip to content

Commit 8ab1a49

Browse files
authored
chore: clean up frontend routes (#9533)
1 parent 0d0530b commit 8ab1a49

File tree

7 files changed

+38
-102
lines changed

7 files changed

+38
-102
lines changed

frontend/src/component/commandBar/CommandBar.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@ export const CommandBar = () => {
115115
const [value, setValue] = useState<string>('');
116116
const { routes } = useRoutes();
117117
const allRoutes: Record<string, IPageRouteInfo> = {};
118-
for (const route of [
119-
...routes.mainNavRoutes,
120-
...routes.adminRoutes,
121-
...routes.mobileRoutes,
122-
]) {
118+
for (const route of [...routes.mainNavRoutes, ...routes.adminRoutes]) {
123119
allRoutes[route.path] = {
124120
path: route.path,
125121
route: route.route,

frontend/src/component/layout/MainLayout/NavigationSidebar/useRoutes.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
2-
import { getCondensedRoutes, getRoutes } from 'component/menu/routes';
2+
import { getNavRoutes } from 'component/menu/routes';
33
import { useAdminRoutes } from 'component/admin/useAdminRoutes';
44
import { filterByConfig, mapRouteLink } from 'component/common/util';
55

66
export const useRoutes = () => {
77
const { uiConfig } = useUiConfig();
8-
const routes = getRoutes();
8+
const routes = getNavRoutes();
99
const adminRoutes = useAdminRoutes();
1010

1111
const filteredMainRoutes = {
12-
mainNavRoutes: getCondensedRoutes(routes.mainNavRoutes)
13-
.filter(filterByConfig(uiConfig))
14-
.map(mapRouteLink),
15-
mobileRoutes: getCondensedRoutes(routes.mobileRoutes)
12+
mainNavRoutes: routes
1613
.filter(filterByConfig(uiConfig))
1714
.map(mapRouteLink),
1815
adminRoutes,

frontend/src/component/menu/Header/DrawerMenu/DrawerMenu.tsx

-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Link } from 'react-router-dom';
33
import { Divider, Drawer, styled } from '@mui/material';
44
import { ReactComponent as UnleashLogo } from 'assets/img/logoDarkWithText.svg';
55
import { ReactComponent as UnleashLogoWhite } from 'assets/img/logoWithWhiteText.svg';
6-
import type { INavigationMenuItem } from 'interfaces/route';
76
import styles from './DrawerMenu.module.scss'; // FIXME: useStyle - theme
87
import theme from 'themes/theme';
98
import { ThemeMode } from 'component/common/ThemeMode/ThemeMode';
@@ -32,18 +31,12 @@ interface IDrawerMenuProps {
3231
href: string;
3332
title: string;
3433
}>;
35-
routes: {
36-
mainNavRoutes: INavigationMenuItem[];
37-
mobileRoutes: INavigationMenuItem[];
38-
adminRoutes: INavigationMenuItem[];
39-
};
4034
}
4135

4236
export const DrawerMenu: VFC<IDrawerMenuProps> = ({
4337
links = [],
4438
open = false,
4539
toggleDrawer,
46-
routes,
4740
}) => {
4841
return (
4942
<Drawer

frontend/src/component/menu/Header/Header.tsx

-17
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ import { ReactComponent as CelebatoryUnleashLogo } from 'assets/img/unleashHolid
2121
import { DrawerMenu } from './DrawerMenu/DrawerMenu';
2222
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
2323
import { focusable } from 'themes/themeStyles';
24-
import { getCondensedRoutes, getRoutes } from 'component/menu/routes';
2524
import DarkModeOutlined from '@mui/icons-material/DarkModeOutlined';
2625
import LightModeOutlined from '@mui/icons-material/LightModeOutlined';
27-
import { filterByConfig, mapRouteLink } from 'component/common/util';
2826
import { useThemeMode } from 'hooks/useThemeMode';
2927
import { Notifications } from 'component/common/Notifications/Notifications';
30-
import { useAdminRoutes } from 'component/admin/useAdminRoutes';
3128
import InviteLinkButton from './InviteLink/InviteLinkButton/InviteLinkButton';
3229
import { useUiFlag } from 'hooks/useUiFlag';
3330
import { CommandBar } from 'component/commandBar/CommandBar';
@@ -105,19 +102,6 @@ const Header = () => {
105102
const toggleDrawer = () => setOpenDrawer((prev) => !prev);
106103
const celebatoryUnleash = useUiFlag('celebrateUnleash');
107104

108-
const routes = getRoutes();
109-
const adminRoutes = useAdminRoutes();
110-
111-
const filteredMainRoutes = {
112-
mainNavRoutes: getCondensedRoutes(routes.mainNavRoutes)
113-
.filter(filterByConfig(uiConfig))
114-
.map(mapRouteLink),
115-
mobileRoutes: getCondensedRoutes(routes.mobileRoutes)
116-
.filter(filterByConfig(uiConfig))
117-
.map(mapRouteLink),
118-
adminRoutes,
119-
};
120-
121105
if (smallScreen) {
122106
return (
123107
<HeaderComponent position='static'>
@@ -139,7 +123,6 @@ const Header = () => {
139123
links={uiConfig.links}
140124
open={openDrawer}
141125
toggleDrawer={toggleDrawer}
142-
routes={filteredMainRoutes}
143126
/>
144127
<StyledUserContainer>
145128
<UserProfile />

frontend/src/component/menu/__tests__/__snapshots__/routes.test.tsx.snap

+14-32
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ exports[`returns all baseRoutes 1`] = `
1212
},
1313
{
1414
"component": [Function],
15-
"menu": {
16-
"mobile": true,
17-
},
15+
"menu": {},
1816
"path": "/personal",
1917
"title": "Dashboard",
2018
"type": "protected",
@@ -92,9 +90,7 @@ exports[`returns all baseRoutes 1`] = `
9290
},
9391
{
9492
"component": [Function],
95-
"menu": {
96-
"mobile": true,
97-
},
93+
"menu": {},
9894
"path": "/projects",
9995
"title": "Projects",
10096
"type": "protected",
@@ -108,9 +104,7 @@ exports[`returns all baseRoutes 1`] = `
108104
},
109105
{
110106
"component": [Function],
111-
"menu": {
112-
"mobile": true,
113-
},
107+
"menu": {},
114108
"path": "/search",
115109
"title": "Search",
116110
"type": "protected",
@@ -125,19 +119,15 @@ exports[`returns all baseRoutes 1`] = `
125119
},
126120
},
127121
"hidden": false,
128-
"menu": {
129-
"mobile": true,
130-
},
122+
"menu": {},
131123
"path": "/playground",
132124
"title": "Playground",
133125
"type": "protected",
134126
},
135127
{
136128
"component": [Function],
137129
"enterprise": true,
138-
"menu": {
139-
"mobile": true,
140-
},
130+
"menu": {},
141131
"path": "/insights",
142132
"title": "Insights",
143133
"type": "protected",
@@ -153,8 +143,7 @@ exports[`returns all baseRoutes 1`] = `
153143
{
154144
"component": [Function],
155145
"menu": {
156-
"advanced": true,
157-
"mobile": true,
146+
"main": true,
158147
},
159148
"path": "/applications",
160149
"title": "Applications",
@@ -179,8 +168,7 @@ exports[`returns all baseRoutes 1`] = `
179168
{
180169
"component": [Function],
181170
"menu": {
182-
"advanced": true,
183-
"mobile": true,
171+
"main": true,
184172
},
185173
"path": "/context",
186174
"title": "Context fields",
@@ -189,8 +177,7 @@ exports[`returns all baseRoutes 1`] = `
189177
{
190178
"component": [Function],
191179
"menu": {
192-
"advanced": true,
193-
"mobile": true,
180+
"main": true,
194181
},
195182
"path": "/feature-toggle-type/*",
196183
"title": "Feature flag types",
@@ -223,8 +210,7 @@ exports[`returns all baseRoutes 1`] = `
223210
{
224211
"component": [Function],
225212
"menu": {
226-
"advanced": true,
227-
"mobile": true,
213+
"main": true,
228214
},
229215
"path": "/strategies",
230216
"title": "Strategy types",
@@ -249,8 +235,7 @@ exports[`returns all baseRoutes 1`] = `
249235
"component": [Function],
250236
"enterprise": true,
251237
"menu": {
252-
"advanced": true,
253-
"mobile": true,
238+
"main": true,
254239
},
255240
"path": "/environments",
256241
"title": "Environments",
@@ -268,7 +253,7 @@ exports[`returns all baseRoutes 1`] = `
268253
"component": [Function],
269254
"flag": "releasePlans",
270255
"menu": {
271-
"advanced": true,
256+
"main": true,
272257
"mode": [
273258
"enterprise",
274259
],
@@ -324,8 +309,7 @@ exports[`returns all baseRoutes 1`] = `
324309
{
325310
"component": [Function],
326311
"menu": {
327-
"advanced": true,
328-
"mobile": true,
312+
"main": true,
329313
},
330314
"path": "/tag-types",
331315
"title": "Tag types",
@@ -383,8 +367,7 @@ exports[`returns all baseRoutes 1`] = `
383367
"component": [Function],
384368
"hidden": false,
385369
"menu": {
386-
"advanced": true,
387-
"mobile": true,
370+
"main": true,
388371
},
389372
"path": "/integrations",
390373
"title": "Integrations",
@@ -412,8 +395,7 @@ exports[`returns all baseRoutes 1`] = `
412395
"component": [Function],
413396
"hidden": false,
414397
"menu": {
415-
"advanced": true,
416-
"mobile": true,
398+
"main": true,
417399
},
418400
"path": "/segments",
419401
"title": "Segments",

0 commit comments

Comments
 (0)