Split packages into platform and extensions

This commit is contained in:
dannyrb committed 2019-07-08 00:41:25 -04:00
1 parent f175d4b96b
commit e8969fba11
992 files changed
+2 -1

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { applyMiddleware, combineReducers, createStore } from 'redux';
// import { createLogger } from 'redux-logger';
import layoutReducers from './layout/reducers.js';
import { reducer as oidcReducer } from 'redux-oidc';
import { redux } from 'ohif-core';
import thunkMiddleware from 'redux-thunk';
// Combine our ohif-core, ui, and oidc reducers
// Set init data, using values found in localStorage
const { reducers, localStorage } = redux;
// const loggerMiddleware = createLogger();
reducers.ui = layoutReducers;
reducers.oidc = oidcReducer;
const rootReducer = combineReducers(reducers);
const store = createStore(
rootReducer,
localStorage.loadState(), // preloadedState
applyMiddleware(
thunkMiddleware // Lets us dispatch() functions
// loggerMiddleware // neat middleware that logs actions
)
);
// When the store's preferences change,
// Update our cached preferences in localStorage
store.subscribe(() => {
localStorage.saveState({
preferences: store.getState().preferences,
});
});
export default store;
@@ -0,0 +1,33 @@
const defaultState = {
labelling: {},
contextMenu: {},
};
const ui = (state = defaultState, action) => {
switch (action.type) {
case 'SET_LABELLING_FLOW_DATA': {
const labelling = Object.assign({}, action.labellingFlowData);
return Object.assign({}, state, { labelling });
}
case 'SET_TOOL_CONTEXT_MENU_DATA': {
const contextMenu = Object.assign({}, state.contextMenu);
contextMenu[action.viewportIndex] = Object.assign(
{},
action.toolContextMenuData
);
return Object.assign({}, state, { contextMenu });
}
case 'RESET_LABELLING_AND_CONTEXT_MENU':
return Object.assign({}, state, {
labelling: defaultState.labelling,
contextMenu: defaultState.contextMenu,
});
default:
return state;
}
};
export default ui;
@@ -0,0 +1,28 @@
import { createSelector } from 'reselect';
const getActiveViewportIndex = state => state.viewports.activeViewportIndex;
const getLayoutViewports = state => state.viewports.layout.viewports;
const getViewportSpecificData = state => state.viewports.viewportSpecificData;
/**
* Think of this as a computed getter for our store. It lets us watch parts of
* our redux state, and only update/recalculate when those values change.
*/
export const getActiveContexts = createSelector(
[getActiveViewportIndex, getLayoutViewports, getViewportSpecificData],
(activeViewportIndex, layoutViewports, viewportSpecificData) => {
const activeContexts = ['VIEWER'];
const activeLayoutViewport = layoutViewports[activeViewportIndex] || {};
const activeViewportSpecificData =
viewportSpecificData[activeViewportIndex] || {};
const activeViewportPluginName =
activeLayoutViewport.plugin || activeViewportSpecificData.plugin;
if (activeViewportPluginName) {
const activeViewportExtension = `ACTIVE_VIEWPORT::${activeViewportPluginName.toUpperCase()}`;
activeContexts.push(activeViewportExtension);
}
return activeContexts;
}
);