mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-27 01:19:00 +02:00
chore: fix missing primary routes for commandbar (#9557)
This commit is contained in:
parent
75bb482c08
commit
33733b64a7
@ -126,7 +126,11 @@ export const CommandBar = () => {
|
|||||||
const [value, setValue] = useState<string>('');
|
const [value, setValue] = useState<string>('');
|
||||||
const { routes } = useRoutes();
|
const { routes } = useRoutes();
|
||||||
const allRoutes: Record<string, IPageRouteInfo> = {};
|
const allRoutes: Record<string, IPageRouteInfo> = {};
|
||||||
for (const route of [...routes.mainNavRoutes, ...routes.adminRoutes]) {
|
for (const route of [
|
||||||
|
...routes.mainNavRoutes,
|
||||||
|
...routes.adminRoutes,
|
||||||
|
...routes.primaryRoutes,
|
||||||
|
]) {
|
||||||
allRoutes[route.path] = {
|
allRoutes[route.path] = {
|
||||||
path: route.path,
|
path: route.path,
|
||||||
route: route.route,
|
route: route.route,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import { getNavRoutes } from 'component/menu/routes';
|
import { getNavRoutes, getPrimaryRoutes } from 'component/menu/routes';
|
||||||
import { useAdminRoutes } from 'component/admin/useAdminRoutes';
|
import { useAdminRoutes } from 'component/admin/useAdminRoutes';
|
||||||
import { filterByConfig, mapRouteLink } from 'component/common/util';
|
import { filterByConfig, mapRouteLink } from 'component/common/util';
|
||||||
|
|
||||||
@ -7,12 +7,16 @@ export const useRoutes = () => {
|
|||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
const routes = getNavRoutes();
|
const routes = getNavRoutes();
|
||||||
const adminRoutes = useAdminRoutes();
|
const adminRoutes = useAdminRoutes();
|
||||||
|
const primaryRoutes = getPrimaryRoutes();
|
||||||
|
|
||||||
const filteredMainRoutes = {
|
const filteredMainRoutes = {
|
||||||
mainNavRoutes: routes
|
mainNavRoutes: routes
|
||||||
.filter(filterByConfig(uiConfig))
|
.filter(filterByConfig(uiConfig))
|
||||||
.map(mapRouteLink),
|
.map(mapRouteLink),
|
||||||
adminRoutes,
|
adminRoutes,
|
||||||
|
primaryRoutes: primaryRoutes
|
||||||
|
.filter(filterByConfig(uiConfig))
|
||||||
|
.map(mapRouteLink),
|
||||||
};
|
};
|
||||||
|
|
||||||
return { routes: filteredMainRoutes };
|
return { routes: filteredMainRoutes };
|
||||||
|
@ -12,7 +12,9 @@ exports[`returns all baseRoutes 1`] = `
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"component": [Function],
|
"component": [Function],
|
||||||
"menu": {},
|
"menu": {
|
||||||
|
"primary": true,
|
||||||
|
},
|
||||||
"path": "/personal",
|
"path": "/personal",
|
||||||
"title": "Dashboard",
|
"title": "Dashboard",
|
||||||
"type": "protected",
|
"type": "protected",
|
||||||
@ -90,7 +92,9 @@ exports[`returns all baseRoutes 1`] = `
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"component": [Function],
|
"component": [Function],
|
||||||
"menu": {},
|
"menu": {
|
||||||
|
"primary": true,
|
||||||
|
},
|
||||||
"path": "/projects",
|
"path": "/projects",
|
||||||
"title": "Projects",
|
"title": "Projects",
|
||||||
"type": "protected",
|
"type": "protected",
|
||||||
@ -104,7 +108,9 @@ exports[`returns all baseRoutes 1`] = `
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"component": [Function],
|
"component": [Function],
|
||||||
"menu": {},
|
"menu": {
|
||||||
|
"primary": true,
|
||||||
|
},
|
||||||
"path": "/search",
|
"path": "/search",
|
||||||
"title": "Search",
|
"title": "Search",
|
||||||
"type": "protected",
|
"type": "protected",
|
||||||
@ -119,7 +125,9 @@ exports[`returns all baseRoutes 1`] = `
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"menu": {},
|
"menu": {
|
||||||
|
"primary": true,
|
||||||
|
},
|
||||||
"path": "/playground",
|
"path": "/playground",
|
||||||
"title": "Playground",
|
"title": "Playground",
|
||||||
"type": "protected",
|
"type": "protected",
|
||||||
@ -127,7 +135,9 @@ exports[`returns all baseRoutes 1`] = `
|
|||||||
{
|
{
|
||||||
"component": [Function],
|
"component": [Function],
|
||||||
"enterprise": true,
|
"enterprise": true,
|
||||||
"menu": {},
|
"menu": {
|
||||||
|
"primary": true,
|
||||||
|
},
|
||||||
"path": "/insights",
|
"path": "/insights",
|
||||||
"title": "Insights",
|
"title": "Insights",
|
||||||
"type": "protected",
|
"type": "protected",
|
||||||
|
@ -68,7 +68,7 @@ export const routes: IRoute[] = [
|
|||||||
title: 'Dashboard',
|
title: 'Dashboard',
|
||||||
component: PersonalDashboard,
|
component: PersonalDashboard,
|
||||||
type: 'protected',
|
type: 'protected',
|
||||||
menu: {},
|
menu: { primary: true },
|
||||||
},
|
},
|
||||||
|
|
||||||
// Project
|
// Project
|
||||||
@ -127,7 +127,7 @@ export const routes: IRoute[] = [
|
|||||||
title: 'Projects',
|
title: 'Projects',
|
||||||
component: ProjectList,
|
component: ProjectList,
|
||||||
type: 'protected',
|
type: 'protected',
|
||||||
menu: {},
|
menu: { primary: true },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/projects-archive',
|
path: '/projects-archive',
|
||||||
@ -143,7 +143,7 @@ export const routes: IRoute[] = [
|
|||||||
title: 'Search',
|
title: 'Search',
|
||||||
component: FeatureToggleListTable,
|
component: FeatureToggleListTable,
|
||||||
type: 'protected',
|
type: 'protected',
|
||||||
menu: {},
|
menu: { primary: true },
|
||||||
},
|
},
|
||||||
|
|
||||||
// Playground
|
// Playground
|
||||||
@ -153,7 +153,7 @@ export const routes: IRoute[] = [
|
|||||||
component: LazyPlayground,
|
component: LazyPlayground,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
type: 'protected',
|
type: 'protected',
|
||||||
menu: {},
|
menu: { primary: true },
|
||||||
},
|
},
|
||||||
|
|
||||||
// Insights
|
// Insights
|
||||||
@ -162,7 +162,7 @@ export const routes: IRoute[] = [
|
|||||||
title: 'Insights',
|
title: 'Insights',
|
||||||
component: Insights,
|
component: Insights,
|
||||||
type: 'protected',
|
type: 'protected',
|
||||||
menu: {},
|
menu: { primary: true },
|
||||||
enterprise: true,
|
enterprise: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -536,3 +536,6 @@ export const baseRoutes = routes.filter((route) => !route.hidden);
|
|||||||
export const getNavRoutes = () => {
|
export const getNavRoutes = () => {
|
||||||
return getCondensedRoutes(baseRoutes.filter((route) => route.menu.main));
|
return getCondensedRoutes(baseRoutes.filter((route) => route.menu.main));
|
||||||
};
|
};
|
||||||
|
export const getPrimaryRoutes = () => {
|
||||||
|
return getCondensedRoutes(baseRoutes.filter((route) => route.menu.primary));
|
||||||
|
};
|
||||||
|
@ -30,6 +30,7 @@ export interface INavigationMenuItem {
|
|||||||
|
|
||||||
interface IRouteMenu {
|
interface IRouteMenu {
|
||||||
main?: boolean;
|
main?: boolean;
|
||||||
|
primary?: boolean;
|
||||||
adminSettings?: boolean;
|
adminSettings?: boolean;
|
||||||
mode?: Array<'pro' | 'enterprise'>;
|
mode?: Array<'pro' | 'enterprise'>;
|
||||||
billing?: boolean;
|
billing?: boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user