synapse-admin/src/common/routeConfig.js
Manuel Stahl 3d9ec623e4 Add feature room-admin
Change-Id: I3bbe7bd7299b56e84ab918d2a8bb22facafecbf1
2019-08-19 17:14:28 +02:00

47 lines
1.4 KiB
JavaScript

import { App } from '../features/home';
import { PageNotFound } from '../features/common';
import _ from 'lodash';
import commonRoute from '../features/common/route';
import homeRoute from '../features/home/route';
import userAdminRoute from '../features/user-admin/route';
import roomAdminRoute from '../features/room-admin/route';
// NOTE: DO NOT CHANGE the 'childRoutes' name and the declaration pattern.
// This is used for Rekit cmds to register routes config for new features, and remove config when remove features, etc.
const childRoutes = [
homeRoute,
commonRoute,
userAdminRoute,
roomAdminRoute,
];
const routes = [{
path: '/',
component: App,
childRoutes: [
...childRoutes,
{ path: '*', name: 'Page not found', component: PageNotFound },
].filter(r => r.component || (r.childRoutes && r.childRoutes.length > 0)),
}];
// Handle isIndex property of route config:
// Dupicate it and put it as the first route rule.
function handleIndexRoute(route) {
if (!route.childRoutes || !route.childRoutes.length) {
return;
}
const indexRoute = _.find(route.childRoutes, (child => child.isIndex));
if (indexRoute) {
const first = { ...indexRoute };
first.path = '';
first.exact = true;
first.autoIndexRoute = true; // mark it so that the simple nav won't show it.
route.childRoutes.unshift(first);
}
route.childRoutes.forEach(handleIndexRoute);
}
routes.forEach(handleIndexRoute);
export default routes;