From 2a00427c903a9115e8638021be91d47de6374590 Mon Sep 17 00:00:00 2001 From: Rodrigo Antinarelli Date: Thu, 7 May 2020 11:55:13 -0300 Subject: [PATCH] initializing appConfig --- platform/viewer/src/App.js | 50 +++++++++----------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/platform/viewer/src/App.js b/platform/viewer/src/App.js index c5b0885aa..3e425dd97 100644 --- a/platform/viewer/src/App.js +++ b/platform/viewer/src/App.js @@ -1,20 +1,11 @@ +// External import React from 'react'; import PropTypes from 'prop-types'; import { BrowserRouter, HashRouter } from 'react-router-dom'; import { ThemeWrapper } from '@ohif/ui'; -import { - CommandsManager, - ExtensionManager, - ServicesManager, - HotkeysManager, - UINotificationService, - UIModalService, - UIDialogService, - MeasurementService, - utils, - redux as reduxOHIF, -} from '@ohif/core'; +// Viewer Project import routes from './routes'; +import appInit from './appInit.js'; /** * ENV Variable to determine routing behavior @@ -23,33 +14,16 @@ const Router = JSON.parse(process.env.USE_HASH_ROUTER) ? HashRouter : BrowserRouter; -const commandsManagerConfig = { - /** Used by commands to inject `viewports` from "redux" */ - getAppState: () => store.getState(), - /** Used by commands to determine active context */ - getActiveContexts: () => getActiveContexts(store.getState()), -}; -const commandsManager = new CommandsManager(commandsManagerConfig); -const servicesManager = new ServicesManager(); -// const hotkeysManager = new HotkeysManager(commandsManager, servicesManager); -const extensionManager = new ExtensionManager({ - commandsManager, - servicesManager, - appConfig, - api: { - contexts: CONTEXTS, - hooks: { - useAppContext, - }, - }, -}); - -extensionManager.registerExtensions(/* Array of Extensions */); - function App({ config, defaultExtensions }) { - const appConfig = { - ...(typeof config === 'function' ? config({ servicesManager }) : config), - }; + const { + appConfig, + commandsManager, + extensionManager, + servicesManager, + } = appInit(config, defaultExtensions); + + // TODO: Expose configuration w/ context? + // See: `setConfiguration` in master return (