From 6b0ef0904e2e8bca3f06c3e3c565cc978ad65696 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Sun, 2 Jun 2019 22:44:13 -0400 Subject: [PATCH] Shift initialization of OHIF classes to app.js --- src/App.js | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/App.js b/src/App.js index 9c50f99ec..d9a9dad86 100644 --- a/src/App.js +++ b/src/App.js @@ -8,13 +8,20 @@ import { } from './utils/index.js'; import ConnectedToolContextMenu from './connectedComponents/ConnectedToolContextMenu'; -import OHIF from 'ohif-core'; +import { + CommandsManager, + HotkeysManager, + extensions, + redux, + utils, +} from 'ohif-core'; import OHIFCornerstoneExtension from '@ohif/extension-cornerstone'; import OHIFDicomHtmlExtension from 'ohif-dicom-html-extension'; import OHIFDicomMicroscopyExtension from 'ohif-dicom-microscopy-extension'; import OHIFDicomPDFExtension from 'ohif-dicom-pdf-extension'; import OHIFStandaloneViewer from './OHIFStandaloneViewer'; import OHIFVTKExtension from '@ohif/extension-vtk'; +import appCommands from './appCommands'; import { OidcProvider } from 'redux-oidc'; import PropTypes from 'prop-types'; import { Provider } from 'react-redux'; @@ -23,19 +30,21 @@ import WhiteLabellingContext from './WhiteLabellingContext'; import setupTools from './setupTools'; import store from './store'; -// Register all of our commands and hotkeys -import commands from './commands'; +// ~~~~ APP SETUP +const _commandsManager = new CommandsManager(); +const _hotkeysManager = new HotkeysManager(_commandsManager); -const { ExtensionManager } = OHIF.extensions; - -commands.init(); +appCommands.init(_commandsManager); // window.config.userPreferences Object.keys(window.config.hotkeys).forEach(commandName => { const keys = window.config.hotkeys[commandName]; - // OHIF.HotkeysManager.set(); - OHIF.HotkeysManager.registerHotkeys(commandName, keys); + // HotkeysManager.set(); + console.log(`registering hotkey: ${commandName} to binding: ${keys}`); + _hotkeysManager.registerHotkeys(commandName, keys); }); +// ~~~~ END EPP SETUP + setupTools(store); const children = { @@ -43,21 +52,20 @@ const children = { }; /** TODO: extensions should be passed in as prop as soon as we have the extensions as separate packages and then registered by ExtensionsManager */ -const extensions = [ +extensions.ExtensionManager.registerExtensions(store, [ new OHIFCornerstoneExtension({ children }), new OHIFVTKExtension(), new OHIFDicomPDFExtension(), new OHIFDicomHtmlExtension(), new OHIFDicomMicroscopyExtension(), -]; -ExtensionManager.registerExtensions(store, extensions); +]); // TODO[react] Use a provider when the whole tree is React window.store = store; function handleServers(servers) { if (servers) { - OHIF.utils.addServers(servers, store); + utils.addServers(servers, store); } } @@ -80,9 +88,7 @@ class App extends Component { // const defaultButtons = getDefaultToolbarButtons(this.props.routerBasename); - const buttonsAction = OHIF.redux.actions.setAvailableButtons( - defaultButtons - ); + const buttonsAction = redux.actions.setAvailableButtons(defaultButtons); store.dispatch(buttonsAction);