ohif-viewer/src/connectedComponents/ToolbarRow.js

97 lines
2.5 KiB
JavaScript
Raw Normal View History

2019-05-30 06:46:45 +02:00
import './ToolbarRow.css';
2019-05-30 05:47:26 +02:00
2019-05-30 06:46:45 +02:00
import React, { Component } from 'react';
2019-05-30 05:47:26 +02:00
2019-05-30 06:46:45 +02:00
import ConnectedLayoutButton from './ConnectedLayoutButton';
import ConnectedPluginSwitch from './ConnectedPluginSwitch.js';
2019-06-12 22:09:35 +02:00
import { MODULE_TYPES } from 'ohif-core';
2019-05-30 06:46:45 +02:00
import PropTypes from 'prop-types';
import { RoundedButtonGroup } from 'react-viewerbase';
2019-06-13 15:51:19 +02:00
import { extensionManager } from './../App.js';
2018-12-18 14:15:55 +01:00
class ToolbarRow extends Component {
static propTypes = {
leftSidebarOpen: PropTypes.bool.isRequired,
rightSidebarOpen: PropTypes.bool.isRequired,
setLeftSidebarOpen: PropTypes.func,
setRightSidebarOpen: PropTypes.func,
2019-05-01 19:10:44 +02:00
pluginId: PropTypes.string,
2019-05-30 06:46:45 +02:00
};
2018-12-19 14:53:03 +01:00
static defaultProps = {
leftSidebarOpen: false,
2019-05-01 19:10:44 +02:00
rightSidebarOpen: false,
2019-05-30 06:46:45 +02:00
};
onLeftSidebarValueChanged = value => {
2019-05-30 06:46:45 +02:00
this.props.setLeftSidebarOpen(!!value);
};
2018-12-19 14:53:03 +01:00
onRightSidebarValueChanged = value => {
2019-05-30 06:46:45 +02:00
this.props.setRightSidebarOpen(!!value);
};
2018-12-19 14:53:03 +01:00
render() {
const leftSidebarToggle = [
{
value: 'studies',
2019-05-30 05:47:26 +02:00
icon: 'th-large',
2019-05-01 19:10:44 +02:00
bottomLabel: 'Series',
},
2019-05-30 06:46:45 +02:00
];
const rightSidebarToggle = [
{
value: 'measurements',
2019-05-30 05:47:26 +02:00
icon: 'list',
2019-05-01 19:10:44 +02:00
bottomLabel: 'Measurements',
},
2019-05-30 06:46:45 +02:00
];
2018-12-19 14:53:03 +01:00
const leftSidebarValue = this.props.leftSidebarOpen
? leftSidebarToggle[0].value
2019-05-30 06:46:45 +02:00
: null;
const rightSidebarValue = this.props.rightSidebarOpen
? rightSidebarToggle[0].value
2019-05-30 06:46:45 +02:00
: null;
2019-06-15 02:44:15 +02:00
const availableToolbarModules =
extensionManager.modules[MODULE_TYPES.TOOLBAR];
2019-06-13 15:51:19 +02:00
const toolbarModuleDefinition = availableToolbarModules.find(
moduleDefinition => moduleDefinition.extensionId === this.props.pluginId
);
2019-05-30 06:46:45 +02:00
let pluginComp;
2019-06-13 15:51:19 +02:00
if (toolbarModuleDefinition) {
const PluginComponent = toolbarModuleDefinition.module;
2019-05-30 06:46:45 +02:00
pluginComp = <PluginComponent />;
}
return (
<div className="ToolbarRow">
<div className="pull-left m-t-1 p-y-1" style={{ padding: '10px' }}>
<RoundedButtonGroup
options={leftSidebarToggle}
value={leftSidebarValue}
onValueChanged={this.onLeftSidebarValueChanged}
/>
</div>
{pluginComp}
<ConnectedLayoutButton />
<ConnectedPluginSwitch />
<div className="pull-right m-t-1 rm-x-1" style={{ marginLeft: 'auto' }}>
<RoundedButtonGroup
options={rightSidebarToggle}
value={rightSidebarValue}
onValueChanged={this.onRightSidebarValueChanged}
/>
</div>
</div>
2019-05-30 06:46:45 +02:00
);
}
2018-12-18 14:15:55 +01:00
}
2019-05-30 06:46:45 +02:00
export default ToolbarRow;