summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/modules/pane/actions.js
blob: 7f5d167a14fc260ce09dc0e8e91367c5891865ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import * as types from './mutation_types';

export const toggleOpen = ({ dispatch, state }, view) => {
  if (state.isOpen) {
    dispatch('close');
  } else {
    dispatch('open', view);
  }
};

export const open = ({ commit }, view) => {
  commit(types.SET_OPEN, true);

  if (view) {
    const { name, keepAlive } = view;

    commit(types.SET_CURRENT_VIEW, name);

    if (keepAlive) {
      commit(types.KEEP_ALIVE_VIEW, name);
    }
  }
};

export const close = ({ commit }) => {
  commit(types.SET_OPEN, false);
};

// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};