summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/mutations.js
blob: 03d81be10a1b4abacc6d74a5bb145278cdc88fe7 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import * as types from './mutation_types';
import projectMutations from './mutations/project';
import fileMutations from './mutations/file';
import treeMutations from './mutations/tree';
import branchMutations from './mutations/branch';

export default {
  [types.SET_INITIAL_DATA](state, data) {
    Object.assign(state, data);
  },
  [types.SET_PREVIEW_MODE](state) {
    Object.assign(state, {
      currentBlobView: 'repo-preview',
    });
  },
  [types.SET_EDIT_MODE](state) {
    Object.assign(state, {
      currentBlobView: 'repo-editor',
    });
  },
  [types.TOGGLE_LOADING](state, entry) {
    Object.assign(entry, {
      loading: !entry.loading,
    });
  },
  [types.TOGGLE_EDIT_MODE](state) {
    Object.assign(state, {
      editMode: !state.editMode,
    });
  },
  [types.TOGGLE_DISCARD_POPUP](state, discardPopupOpen) {
    Object.assign(state, {
      discardPopupOpen,
    });
  },
  [types.SET_ROOT](state, isRoot) {
    Object.assign(state, {
      isRoot,
      isInitialRoot: isRoot,
    });
  },
  [types.SET_LEFT_PANEL_COLLAPSED](state, collapsed) {
    Object.assign(state, {
      leftPanelCollapsed: collapsed,
    });
  },
  [types.SET_RIGHT_PANEL_COLLAPSED](state, collapsed) {
    Object.assign(state, {
      rightPanelCollapsed: collapsed,
    });
  },
  [types.SET_RESIZING_STATUS](state, resizing) {
    Object.assign(state, {
      panelResizing: resizing,
    });
  },
  [types.SET_LAST_COMMIT_DATA](state, { entry, lastCommit }) {
    Object.assign(entry.lastCommit, {
      id: lastCommit.commit.id,
      url: lastCommit.commit_path,
      message: lastCommit.commit.message,
      author: lastCommit.commit.author_name,
      updatedAt: lastCommit.commit.authored_date,
    });
  },
  ...projectMutations,
  ...fileMutations,
  ...treeMutations,
  ...branchMutations,
};