2019-01-17 17:00:21 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { LayoutManager } from 'react-viewerbase';
|
|
|
|
|
import OHIF from 'ohif-core';
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
2019-04-19 12:42:26 -04:00
|
|
|
const viewportPluginIds = state.plugins.availablePlugins
|
|
|
|
|
.filter(plugin => plugin.type === OHIF.plugins.PLUGIN_TYPES.VIEWPORT)
|
|
|
|
|
.map(plugin => plugin.id);
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-04-19 12:42:26 -04:00
|
|
|
const availablePlugins = {};
|
|
|
|
|
viewportPluginIds.forEach(id => {
|
|
|
|
|
const plugin = OHIF.plugins.availablePlugins.find(
|
|
|
|
|
plugin => plugin.id === id
|
|
|
|
|
);
|
|
|
|
|
if (plugin) {
|
|
|
|
|
availablePlugins[id] = plugin.component;
|
2019-01-17 17:00:21 +01:00
|
|
|
}
|
2019-04-19 12:42:26 -04:00
|
|
|
});
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-04-19 12:42:26 -04:00
|
|
|
// TODO Use something like state.plugins.defaultPlugin[OHIF.plugins.PLUGIN_TYPES.VIEWPORT]
|
|
|
|
|
let defaultPlugin;
|
|
|
|
|
if (viewportPluginIds && viewportPluginIds.length) {
|
|
|
|
|
defaultPlugin = viewportPluginIds[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
layout: state.viewports.layout,
|
|
|
|
|
activeViewportIndex: state.viewports.activeViewportIndex,
|
|
|
|
|
availablePlugins,
|
|
|
|
|
defaultPlugin
|
|
|
|
|
};
|
2019-01-17 17:00:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ConnectedLayoutManager = connect(
|
2019-04-19 12:42:26 -04:00
|
|
|
mapStateToProps,
|
|
|
|
|
null
|
2019-01-17 17:00:21 +01:00
|
|
|
)(LayoutManager);
|
|
|
|
|
|
|
|
|
|
export default ConnectedLayoutManager;
|