fix connected layout manager to use extensionManager
This commit is contained in:
parent
4f6cee8960
commit
b052930123
@ -1,32 +1,29 @@
|
|||||||
import { LayoutManager } from 'react-viewerbase';
|
import { LayoutManager } from 'react-viewerbase';
|
||||||
import { MODULE_TYPES } from 'ohif-core';
|
import { MODULE_TYPES } from 'ohif-core';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { extensionManager } from './../App.js';
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
const viewportPluginIds = state.plugins.availablePlugins
|
const availableViewportModules = {};
|
||||||
.filter(plugin => plugin.type === MODULE_TYPES.VIEWPORT)
|
const viewportModules = extensionManager.modules[MODULE_TYPES.VIEWPORT];
|
||||||
.map(plugin => plugin.id);
|
|
||||||
|
|
||||||
const availablePlugins = {};
|
viewportModules.forEach(moduleDefinition => {
|
||||||
viewportPluginIds.forEach(id => {
|
availableViewportModules[moduleDefinition.extensionId] =
|
||||||
const plugin = OHIF.plugins.availablePlugins.find(
|
moduleDefinition.module;
|
||||||
plugin => plugin.id === id
|
|
||||||
);
|
|
||||||
if (plugin) {
|
|
||||||
availablePlugins[id] = plugin.component;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO Use something like state.plugins.defaultPlugin[MODULE_TYPES.VIEWPORT]
|
// TODO: Use something like state.plugins.defaultPlugin[MODULE_TYPES.VIEWPORT]
|
||||||
let defaultPlugin;
|
let defaultPlugin;
|
||||||
if (viewportPluginIds && viewportPluginIds.length) {
|
if (viewportModules.length) {
|
||||||
defaultPlugin = viewportPluginIds[0];
|
defaultPlugin = viewportModules[0].extensionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
layout: state.viewports.layout,
|
layout: state.viewports.layout,
|
||||||
activeViewportIndex: state.viewports.activeViewportIndex,
|
activeViewportIndex: state.viewports.activeViewportIndex,
|
||||||
availablePlugins,
|
// TODO: rename `availableViewportModules`
|
||||||
|
availablePlugins: availableViewportModules,
|
||||||
|
// TODO: rename `defaultViewportModule`
|
||||||
defaultPlugin,
|
defaultPlugin,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user