No need for connected user preferences when header can contain info
This commit is contained in:
parent
2d6f9c1a05
commit
e0cbc8ef4d
10
src/App.js
10
src/App.js
@ -36,13 +36,13 @@ const commandsManagerConfig = {
|
|||||||
getActiveContexts: () => store.getState().ui.activeContexts,
|
getActiveContexts: () => store.getState().ui.activeContexts,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _commandsManager = new CommandsManager(commandsManagerConfig);
|
const commandsManager = new CommandsManager(commandsManagerConfig);
|
||||||
const _hotkeysManager = new HotkeysManager(_commandsManager);
|
const hotkeysManager = new HotkeysManager(commandsManager);
|
||||||
|
|
||||||
// TODO: Should be done in extensions w/ commandsModule
|
// TODO: Should be done in extensions w/ commandsModule
|
||||||
// ~~ ADD COMMANDS
|
// ~~ ADD COMMANDS
|
||||||
appCommands.init(_commandsManager);
|
appCommands.init(commandsManager);
|
||||||
_hotkeysManager.setHotkeys(window.config.hotkeys, true);
|
hotkeysManager.setHotkeys(window.config.hotkeys, true);
|
||||||
|
|
||||||
// Force active contexts for now. These should be set in Viewer/ActiveViewer
|
// Force active contexts for now. These should be set in Viewer/ActiveViewer
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
@ -148,3 +148,5 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|
||||||
|
export { commandsManager, hotkeysManager };
|
||||||
|
|||||||
@ -1,16 +1,18 @@
|
|||||||
import React, { Component } from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { Link, withRouter } from 'react-router-dom';
|
|
||||||
import { Dropdown } from 'react-viewerbase';
|
|
||||||
import './Header.css';
|
import './Header.css';
|
||||||
|
|
||||||
|
import { Link, withRouter } from 'react-router-dom';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
|
import { Dropdown } from 'react-viewerbase';
|
||||||
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
|
import OHIFLogo from '../OHIFLogo/OHIFLogo.js';
|
||||||
import ConnectedUserPreferencesModal from '../../connectedComponents/ConnectedUserPreferencesModal.js';
|
import PropTypes from 'prop-types';
|
||||||
|
import { UserPreferencesModal } from 'react-viewerbase';
|
||||||
|
import { hotkeysManager } from './../../App.js';
|
||||||
|
|
||||||
class Header extends Component {
|
class Header extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
home: PropTypes.bool.isRequired,
|
home: PropTypes.bool.isRequired,
|
||||||
location: PropTypes.object.isRequired,
|
location: PropTypes.object.isRequired,
|
||||||
openUserPreferencesModal: PropTypes.func,
|
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -19,12 +21,25 @@ class Header extends Component {
|
|||||||
children: OHIFLogo(),
|
children: OHIFLogo(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// onSave: data => {
|
||||||
|
// const contextName = window.store.getState().commandContext.context;
|
||||||
|
// const preferences = cloneDeep(window.store.getState().preferences);
|
||||||
|
// preferences[contextName] = data;
|
||||||
|
// dispatch(setUserPreferences(preferences));
|
||||||
|
// dispatch(setUserPreferencesModalOpen(false));
|
||||||
|
// OHIF.hotkeysUtil.setHotkeys(data.hotKeysData);
|
||||||
|
// },
|
||||||
|
// onResetToDefaults: () => {
|
||||||
|
// dispatch(setUserPreferences());
|
||||||
|
// dispatch(setUserPreferencesModalOpen(false));
|
||||||
|
// OHIF.hotkeysUtil.setHotkeys();
|
||||||
|
// },
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.state = { isUserPreferencesOpen: false };
|
||||||
|
|
||||||
this.state = {
|
const onClick = this.toggleUserPreferences.bind(this);
|
||||||
userPreferencesOpen: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.options = [
|
this.options = [
|
||||||
{
|
{
|
||||||
@ -32,7 +47,7 @@ class Header extends Component {
|
|||||||
icon: {
|
icon: {
|
||||||
name: 'user',
|
name: 'user',
|
||||||
},
|
},
|
||||||
onClick: this.props.openUserPreferencesModal,
|
onClick: onClick,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'About',
|
title: 'About',
|
||||||
@ -42,6 +57,24 @@ class Header extends Component {
|
|||||||
link: 'http://ohif.org',
|
link: 'http://ohif.org',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
this.hotKeysData = hotkeysManager.hotkeyDefinitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleUserPreferences() {
|
||||||
|
const isOpen = this.state.isUserPreferencesOpen;
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
isUserPreferencesOpen: !isOpen,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onUserPreferencesSave({ windowLevelData, hotKeysData }) {
|
||||||
|
console.log(windowLevelData);
|
||||||
|
console.log(hotKeysData);
|
||||||
|
|
||||||
|
// TODO: Update hotkeysManager
|
||||||
|
// TODO: reset `this.hotKeysData`
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -75,7 +108,14 @@ class Header extends Component {
|
|||||||
<div className="header-menu">
|
<div className="header-menu">
|
||||||
<span className="research-use">INVESTIGATIONAL USE ONLY</span>
|
<span className="research-use">INVESTIGATIONAL USE ONLY</span>
|
||||||
<Dropdown title="Options" list={this.options} align="right" />
|
<Dropdown title="Options" list={this.options} align="right" />
|
||||||
<ConnectedUserPreferencesModal />
|
<UserPreferencesModal
|
||||||
|
isOpen={this.state.isUserPreferencesOpen}
|
||||||
|
onCancel={this.toggleUserPreferences.bind(this)}
|
||||||
|
onSave={this.toggleUserPreferences.bind(this)}
|
||||||
|
onResetToDefaults={this.toggleUserPreferences.bind(this)}
|
||||||
|
windowLevelData={{}}
|
||||||
|
hotKeysData={this.hotKeysData}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import Header from '../components/Header/Header.js';
|
import Header from '../components/Header/Header.js';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { setUserPreferencesModalOpen } from '../store/layout/actions.js';
|
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
@ -8,17 +7,6 @@ const mapStateToProps = state => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const ConnectedHeader = connect(mapStateToProps)(Header);
|
||||||
return {
|
|
||||||
openUserPreferencesModal: () => {
|
|
||||||
dispatch(setUserPreferencesModalOpen(true));
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const ConnectedHeader = connect(
|
|
||||||
mapStateToProps,
|
|
||||||
mapDispatchToProps
|
|
||||||
)(Header);
|
|
||||||
|
|
||||||
export default ConnectedHeader;
|
export default ConnectedHeader;
|
||||||
|
|||||||
@ -1,48 +0,0 @@
|
|||||||
import OHIF from 'ohif-core';
|
|
||||||
import { UserPreferencesModal } from 'react-viewerbase';
|
|
||||||
import cloneDeep from 'lodash.clonedeep';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import { setUserPreferencesModalOpen } from './../store/layout/actions.js';
|
|
||||||
|
|
||||||
const { setUserPreferences } = OHIF.redux.actions;
|
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
|
||||||
const contextName = window.store.getState().commandContext.context;
|
|
||||||
return {
|
|
||||||
isOpen: state.ui.userPreferencesModalOpen,
|
|
||||||
windowLevelData: state.preferences[contextName]
|
|
||||||
? state.preferences[contextName].windowLevelData
|
|
||||||
: {},
|
|
||||||
hotKeysData: state.preferences[contextName]
|
|
||||||
? state.preferences[contextName].hotKeysData
|
|
||||||
: {},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
|
||||||
return {
|
|
||||||
onCancel: () => {
|
|
||||||
dispatch(setUserPreferencesModalOpen(false));
|
|
||||||
},
|
|
||||||
onSave: data => {
|
|
||||||
const contextName = window.store.getState().commandContext.context;
|
|
||||||
const preferences = cloneDeep(window.store.getState().preferences);
|
|
||||||
preferences[contextName] = data;
|
|
||||||
dispatch(setUserPreferences(preferences));
|
|
||||||
dispatch(setUserPreferencesModalOpen(false));
|
|
||||||
OHIF.hotkeysUtil.setHotkeys(data.hotKeysData);
|
|
||||||
},
|
|
||||||
onResetToDefaults: () => {
|
|
||||||
dispatch(setUserPreferences());
|
|
||||||
dispatch(setUserPreferencesModalOpen(false));
|
|
||||||
OHIF.hotkeysUtil.setHotkeys();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const ConnectedUserPreferencesModal = connect(
|
|
||||||
mapStateToProps,
|
|
||||||
mapDispatchToProps
|
|
||||||
)(UserPreferencesModal);
|
|
||||||
|
|
||||||
export default ConnectedUserPreferencesModal;
|
|
||||||
@ -23,11 +23,6 @@ export const setRightSidebarOpen = state => ({
|
|||||||
state,
|
state,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const setUserPreferencesModalOpen = state => ({
|
|
||||||
type: 'SET_USER_PREFERENCES_MODAL_OPEN',
|
|
||||||
state,
|
|
||||||
});
|
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
addActiveContext,
|
addActiveContext,
|
||||||
removeActiveContext,
|
removeActiveContext,
|
||||||
@ -35,7 +30,6 @@ const actions = {
|
|||||||
//
|
//
|
||||||
setLeftSidebarOpen,
|
setLeftSidebarOpen,
|
||||||
setRightSidebarOpen,
|
setRightSidebarOpen,
|
||||||
setUserPreferencesModalOpen,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default actions;
|
export default actions;
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
const defaultState = {
|
const defaultState = {
|
||||||
leftSidebarOpen: true,
|
leftSidebarOpen: true,
|
||||||
rightSidebarOpen: false,
|
rightSidebarOpen: false,
|
||||||
userPreferencesModalOpen: false,
|
|
||||||
labelling: {},
|
labelling: {},
|
||||||
contextMenu: {},
|
contextMenu: {},
|
||||||
activeContexts: [],
|
activeContexts: [],
|
||||||
@ -30,10 +29,6 @@ const ui = (state = defaultState, action) => {
|
|||||||
return Object.assign({}, state, { leftSidebarOpen: action.state });
|
return Object.assign({}, state, { leftSidebarOpen: action.state });
|
||||||
case 'SET_RIGHT_SIDEBAR_OPEN':
|
case 'SET_RIGHT_SIDEBAR_OPEN':
|
||||||
return Object.assign({}, state, { rightSidebarOpen: action.state });
|
return Object.assign({}, state, { rightSidebarOpen: action.state });
|
||||||
case 'SET_USER_PREFERENCES_MODAL_OPEN':
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
userPreferencesModalOpen: action.state,
|
|
||||||
});
|
|
||||||
case 'SET_LABELLING_FLOW_DATA': {
|
case 'SET_LABELLING_FLOW_DATA': {
|
||||||
const labelling = Object.assign({}, action.labellingFlowData);
|
const labelling = Object.assign({}, action.labellingFlowData);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user