import React from 'react'; import { Routes, Route, Link } from 'react-router-dom'; import { ErrorBoundary } from '@ohif/ui-next'; // Route Components import DataSourceWrapper from './DataSourceWrapper'; import WorkList from './WorkList'; import Local from './Local'; import Debug from './Debug'; import NotFound from './NotFound'; import buildModeRoutes from './buildModeRoutes'; import PrivateRoute from './PrivateRoute'; import PropTypes from 'prop-types'; import { routerBase, routerBasename } from '../utils/publicUrl'; const NotFoundServer = ({ message = 'Unable to query for studies at this time. Check your data source configuration or network connection', }) => { return (

{message}

); }; NotFoundServer.propTypes = { message: PropTypes.string, }; const NotFoundStudy = () => { return (

One or more of the requested studies are not available at this time. Return to the{' '} study list {' '} to select a different study to view.

); }; NotFoundStudy.propTypes = { message: PropTypes.string, }; // TODO: Include "routes" debug route if dev build const bakedInRoutes = [ { path: `/notfoundserver`, children: NotFoundServer, }, { path: `/notfoundstudy`, children: NotFoundStudy, }, { path: `/debug`, children: Debug, }, { path: `/local`, children: Local.bind(null, { modePath: '' }), // navigate to the worklist }, { path: `/localbasic`, children: Local.bind(null, { modePath: 'viewer/dicomlocal' }), }, ]; // NOT FOUND (404) const notFoundRoute = { component: NotFound }; const createRoutes = ({ modes, dataSources, extensionManager, servicesManager, commandsManager, hotkeysManager, showStudyList, }: withAppTypes) => { const routes = buildModeRoutes({ modes, dataSources, extensionManager, servicesManager, commandsManager, hotkeysManager, }) || []; const { customizationService } = servicesManager.services; const path = routerBasename.length > 1 && routerBasename.endsWith('/') ? routerBasename.substring(0, routerBasename.length - 1) : routerBasename; console.log('Registering worklist route', routerBasename, path); const WorkListRoute = { path: '/', children: DataSourceWrapper, private: true, props: { children: WorkList, servicesManager, extensionManager }, }; const customRoutes = customizationService.getCustomization('routes.customRoutes'); const allRoutes = [ ...routes, ...(showStudyList ? [WorkListRoute] : []), ...(customRoutes?.routes || []), ...bakedInRoutes, customRoutes?.notFoundRoute || notFoundRoute, ]; function RouteWithErrorBoundary({ route, ...rest }) { // eslint-disable-next-line react/jsx-props-no-spreading return ( ); } const { userAuthenticationService } = servicesManager.services; // All routes are private by default and then we let the user auth service // to check if it is enabled or not // Todo: I think we can remove the second public return below return ( {allRoutes.map((route, i) => { return route.private === true ? ( userAuthenticationService.handleUnauthenticated()} > } > ) : ( } /> ); })} ); }; export default createRoutes;