add togglePhase method, where we can show the panel if needed
without needing to resort to redispatching the original actionpull/21833/head
parent
04710e6ca0
commit
5fb9276ef3
|
@ -40,14 +40,36 @@ export default class HeaderButtons extends React.Component {
|
||||||
dis.unregister(this.dispatcherRef);
|
dis.unregister(this.dispatcherRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if (!prevProps.collapsedRhs && this.props.collapsedRhs) {
|
||||||
|
this.setState({
|
||||||
|
phase: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setPhase(phase, extras) {
|
setPhase(phase, extras) {
|
||||||
// TODO: delay?
|
if (this.props.collapsedRhs) {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'show_right_panel',
|
||||||
|
});
|
||||||
|
}
|
||||||
dis.dispatch(Object.assign({
|
dis.dispatch(Object.assign({
|
||||||
action: 'view_right_panel_phase',
|
action: 'view_right_panel_phase',
|
||||||
phase: phase,
|
phase: phase,
|
||||||
}, extras));
|
}, extras));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
togglePhase(phase) {
|
||||||
|
if (this.state.phase === phase) {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'hide_right_panel',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setPhase(phase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isPhase(phases) {
|
isPhase(phases) {
|
||||||
if (this.props.collapsedRhs) {
|
if (this.props.collapsedRhs) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -61,28 +83,9 @@ export default class HeaderButtons extends React.Component {
|
||||||
|
|
||||||
onAction(payload) {
|
onAction(payload) {
|
||||||
if (payload.action === "view_right_panel_phase") {
|
if (payload.action === "view_right_panel_phase") {
|
||||||
// only actions coming from header buttons should collapse the right panel
|
this.setState({
|
||||||
if (this.state.phase === payload.phase && payload.fromHeader) {
|
phase: payload.phase,
|
||||||
dis.dispatch({
|
});
|
||||||
action: 'hide_right_panel',
|
|
||||||
});
|
|
||||||
this.setState({
|
|
||||||
phase: null,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (this.props.collapsedRhs && payload.fromHeader) {
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'show_right_panel',
|
|
||||||
});
|
|
||||||
// emit payload again as the RightPanel didn't exist up
|
|
||||||
// till show_right_panel, just without the fromHeader flag
|
|
||||||
// as that would hide the right panel again
|
|
||||||
dis.dispatch(Object.assign({}, payload, {fromHeader: false}));
|
|
||||||
}
|
|
||||||
this.setState({
|
|
||||||
phase: payload.phase,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue