2018-12-31 13:26:38 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import ToolbarRow from './ToolbarRow';
|
|
|
|
|
import { setLeftSidebarOpen, setRightSidebarOpen } from '../redux/actions.js';
|
|
|
|
|
|
2019-02-24 15:26:50 +01:00
|
|
|
const defaultPlugin = 'cornerstone';
|
|
|
|
|
|
2018-12-31 13:26:38 +01:00
|
|
|
const mapStateToProps = state => {
|
2019-05-29 08:39:54 -04:00
|
|
|
const { layout, viewportSpecificData, activeViewportIndex } = state.viewports;
|
|
|
|
|
const pluginInLayout =
|
|
|
|
|
layout.viewports[activeViewportIndex] &&
|
|
|
|
|
layout.viewports[activeViewportIndex].plugin;
|
|
|
|
|
const pluginInViewportData =
|
|
|
|
|
viewportSpecificData[activeViewportIndex] &&
|
|
|
|
|
viewportSpecificData[activeViewportIndex].plugin;
|
|
|
|
|
const pluginInActiveViewport =
|
|
|
|
|
pluginInLayout || pluginInViewportData || defaultPlugin;
|
|
|
|
|
// const extensionData = state.extensions[pluginInActiveViewport];
|
2019-02-24 15:26:50 +01:00
|
|
|
|
2019-05-29 08:39:54 -04:00
|
|
|
return {
|
|
|
|
|
pluginId: pluginInActiveViewport,
|
|
|
|
|
leftSidebarOpen: state.ui.leftSidebarOpen,
|
|
|
|
|
rightSidebarOpen: state.ui.rightSidebarOpen,
|
|
|
|
|
};
|
2018-12-31 13:26:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => {
|
2019-05-29 08:39:54 -04:00
|
|
|
return {
|
|
|
|
|
setLeftSidebarOpen: state => {
|
|
|
|
|
dispatch(setLeftSidebarOpen(state));
|
|
|
|
|
},
|
|
|
|
|
setRightSidebarOpen: state => {
|
|
|
|
|
dispatch(setRightSidebarOpen(state));
|
|
|
|
|
},
|
|
|
|
|
};
|
2018-12-31 13:26:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ConnectedToolbarRow = connect(
|
2019-05-29 08:39:54 -04:00
|
|
|
mapStateToProps,
|
|
|
|
|
mapDispatchToProps
|
2018-12-31 13:26:38 +01:00
|
|
|
)(ToolbarRow);
|
|
|
|
|
|
|
|
|
|
export default ConnectedToolbarRow;
|