Centralize route generation to a single place

This commit is contained in:
dannyrb committed 2020-05-17 21:42:38 -04:00
1 parent eecdb62dda
commit a99badd011
15 files changed
+57 -34

No files matched your search

@@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { MODULE_TYPES } from '@ohif/core';
//
import { appConfig, extensionManager } from '../App.js';
import { appConfig, extensionManager } from '../App.jsx';
/**
* Uses route properties to determine the data source that should be passed
+1 -1
View File
@@ -1,4 +1,4 @@
import React, { useContext, useEffect, useCallback } from 'react';
import React, { useEffect, useCallback } from 'react';
import {
displaySetManager,
ToolBarManager,
+10 -2
View File
@@ -1,23 +1,31 @@
import React from 'react';
import { Switch, Route } from 'react-router-dom';
// Route Components
import DataSourceWrapper from './DataSourceWrapper';
import StudyListContainer from './StudyListContainer';
import NotFound from './NotFound';
import buildModeRoutes from './buildModeRoutes';
// TODO: Make these configurable
const bakedInRoutes = [
// WORK LIST
{
path: '/',
exact: true,
component: DataSourceWrapper,
props: { children: StudyListContainer },
},
// NOT FOUND (404)
{ component: NotFound },
];
const createRoutes = routes => {
const createRoutes = (modes, dataSources, extensionManager, t, t2) => {
console.log('Creating Routes: ', routes, bakedInRoutes);
console.log(modes, dataSources, extensionManager, t, t2);
if (!modes.length) {
modes.push(window.exampleMode);
}
const routes = buildModeRoutes(modes, dataSources, extensionManager) || [];
// TODO: Shouldn't need to guard input routes with an empty array?
const allRoutes = [...(routes || []), ...bakedInRoutes];