ohif-viewer/platform/viewer/src/routes/index.js

65 lines
1.5 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { Switch, Route } from 'react-router-dom';
// Route Components
import DataSourceWrapper from './DataSourceWrapper';
2020-05-18 05:27:31 +02:00
import WorkList from './WorkList';
import NotFound from './NotFound';
import buildModeRoutes from './buildModeRoutes';
2020-06-26 19:08:29 +02:00
import { ErrorBoundary } from '@ohif/ui';
// TODO: Make these configurable
// TODO: Include "routes" debug route if dev build
const bakedInRoutes = [
// WORK LIST
{
path: '/',
exact: true,
component: DataSourceWrapper,
2020-05-18 05:27:31 +02:00
props: { children: WorkList },
},
// NOT FOUND (404)
{ component: NotFound },
];
const createRoutes = ({
2020-05-18 17:21:57 +02:00
modes,
dataSources,
extensionManager,
servicesManager,
hotkeysManager,
}) => {
const routes =
buildModeRoutes({
modes,
dataSources,
extensionManager,
servicesManager,
hotkeysManager,
}) || [];
2020-06-05 17:36:11 +02:00
const allRoutes = [...routes, ...bakedInRoutes];
return (
<Switch>
{allRoutes.map((route, i) => {
return (
<Route
key={i}
path={route.path}
exact={route.exact}
strict={route.strict}
render={props => (
// eslint-disable-next-line react/jsx-props-no-spreading
2020-06-26 19:08:29 +02:00
<ErrorBoundary context={`Route ${route.path}`} fallbackRoute="/">
<route.component {...props} {...route.props} route={route} />
</ErrorBoundary>
)}
/>
);
})}
</Switch>
);
};
export default createRoutes;