summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repo/stores/mutations.js
blob: 7e6c3d6e2861b3db090ee22269da10f9b01d5405 (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
import * as types from './mutation_types';
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_COMMIT_REF](state, ref) {
    Object.assign(state, {
      currentRef: ref,
    });
  },
  [types.SET_ROOT](state, isRoot) {
    Object.assign(state, {
      isRoot,
      isInitialRoot: isRoot,
    });
  },
  [types.SET_PREVIOUS_URL](state, previousUrl) {
    Object.assign(state, {
      previousUrl,
    });
  },
  [types.SET_LAST_COMMIT_DATA](state, { entry, lastCommit }) {
    Object.assign(entry.lastCommit, {
      url: `${state.project.url}/commit/${lastCommit.commit.id}`,
      message: lastCommit.commit.message,
      updatedAt: lastCommit.commit.authored_date,
    });
  },
  ...fileMutations,
  ...treeMutations,
  ...branchMutations,
};