2020-04-29 20:15:45 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import { Switch, Route } from 'react-router-dom';
|
2020-04-29 20:44:19 +02:00
|
|
|
// Route Components
|
2020-05-08 05:43:47 +02:00
|
|
|
import DataSourceWrapper from './DataSourceWrapper';
|
2020-05-18 05:27:31 +02:00
|
|
|
import WorkList from './WorkList';
|
2020-04-29 20:15:45 +02:00
|
|
|
import NotFound from './NotFound';
|
2020-05-18 03:42:38 +02:00
|
|
|
import buildModeRoutes from './buildModeRoutes';
|
2020-06-26 19:08:29 +02:00
|
|
|
import { ErrorBoundary } from '@ohif/ui';
|
2020-04-29 20:15:45 +02:00
|
|
|
|
2020-05-18 03:42:38 +02:00
|
|
|
// TODO: Make these configurable
|
2020-05-18 04:18:25 +02:00
|
|
|
// TODO: Include "routes" debug route if dev build
|
2020-05-07 20:02:51 +02:00
|
|
|
const bakedInRoutes = [
|
2020-05-18 03:42:38 +02:00
|
|
|
// WORK LIST
|
2020-05-08 05:43:47 +02:00
|
|
|
{
|
|
|
|
|
path: '/',
|
|
|
|
|
exact: true,
|
|
|
|
|
component: DataSourceWrapper,
|
2020-05-18 05:27:31 +02:00
|
|
|
props: { children: WorkList },
|
2020-05-08 05:43:47 +02:00
|
|
|
},
|
2020-05-18 03:42:38 +02:00
|
|
|
// NOT FOUND (404)
|
2020-04-29 20:15:45 +02:00
|
|
|
{ component: NotFound },
|
|
|
|
|
];
|
|
|
|
|
|
2020-06-29 16:53:46 +02:00
|
|
|
const createRoutes = ({
|
2020-05-18 17:21:57 +02:00
|
|
|
modes,
|
|
|
|
|
dataSources,
|
|
|
|
|
extensionManager,
|
2020-06-29 16:53:46 +02:00
|
|
|
servicesManager,
|
2020-07-03 04:23:42 +02:00
|
|
|
hotkeysManager,
|
2020-06-29 16:53:46 +02:00
|
|
|
}) => {
|
2020-07-03 04:23:42 +02:00
|
|
|
const routes =
|
|
|
|
|
buildModeRoutes({
|
|
|
|
|
modes,
|
|
|
|
|
dataSources,
|
|
|
|
|
extensionManager,
|
|
|
|
|
servicesManager,
|
|
|
|
|
hotkeysManager,
|
|
|
|
|
}) || [];
|
2020-06-29 16:53:46 +02:00
|
|
|
|
2020-06-05 17:36:11 +02:00
|
|
|
const allRoutes = [...routes, ...bakedInRoutes];
|
2020-05-07 20:02:51 +02:00
|
|
|
|
2020-04-29 20:15:45 +02:00
|
|
|
return (
|
|
|
|
|
<Switch>
|
2020-05-07 20:02:51 +02:00
|
|
|
{allRoutes.map((route, i) => {
|
2020-04-29 20:15:45 +02:00
|
|
|
return (
|
|
|
|
|
<Route
|
|
|
|
|
key={i}
|
|
|
|
|
path={route.path}
|
|
|
|
|
exact={route.exact}
|
|
|
|
|
strict={route.strict}
|
2020-05-08 05:43:47 +02:00
|
|
|
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>
|
2020-05-08 05:43:47 +02:00
|
|
|
)}
|
2020-04-29 20:15:45 +02:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</Switch>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2020-05-07 20:02:51 +02:00
|
|
|
export default createRoutes;
|