toggle right panel when clicking already active header button

This commit is contained in:
Bruno Windels 2018-12-17 15:22:02 +01:00
parent 4264f915a2
commit bbafd8c2d3
2 changed files with 19 additions and 3 deletions

View file

@ -36,6 +36,7 @@ export default class HeaderButton extends React.Component {
dis.dispatch({
action: 'view_right_panel_phase',
phase: this.props.clickPhase,
fromHeader: true,
});
}

View file

@ -49,9 +49,24 @@ export default class HeaderButtons extends React.Component {
onAction(payload) {
if (payload.action === "view_right_panel_phase") {
this.setState({
phase: payload.phase,
});
// only actions coming from header buttons should collapse the right panel
if (this.state.phase === payload.phase && payload.fromHeader) {
dis.dispatch({
action: 'hide_right_panel',
});
this.setState({
phase: null,
});
} else {
if (!this.state.phase) {
dis.dispatch({
action: 'show_right_panel',
});
}
this.setState({
phase: payload.phase,
});
}
}
}