message: add togglePhase method, where we can show the panel if needed
  without needing to resort to redispatching the original action
diff: @@ -40,14 +40,36 @@ export default class HeaderButtons extends React.Component {
  dis.unregister(this.dispatcherRef);
  }
  + componentDidUpdate(prevProps) {
  + if (!prevProps.collapsedRhs && this.props.collapsedRhs) {
  + this.setState({
  + phase: null,
  + });
  + }
  + }
  +
  setPhase(phase, extras) {
  - // TODO: delay?
  + if (this.props.collapsedRhs) {
  + dis.dispatch({
  + action: 'show_right_panel',
  + });
  + }
  dis.dispatch(Object.assign({
  action: 'view_right_panel_phase',
  phase: phase,
  }, extras));
  }
  + togglePhase(phase) {
  + if (this.state.phase === phase) {
  + dis.dispatch({
  + action: 'hide_right_panel',
  + });
  + } else {
  + this.setPhase(phase);
  + }
  + }
  +
  isPhase(phases) {
  if (this.props.collapsedRhs) {
  return false;
  @@ -61,30 +83,11 @@ export default class HeaderButtons extends React.Component {
  onAction(payload) {
  if (payload.action === "view_right_panel_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.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,
  });
  }
  }
  - }
  render() {
  // inline style as this will be swapped around in future commits
  