mutations.js 1.8 KB
Newer Older
1
import * as types from './mutation_types';
2
import projectMutations from './mutations/project';
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
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,
    });
  },
42 43 44 45 46 47
  [types.SET_LEFT_PANEL_COLLAPSED](state, collapsed) {
    Object.assign(state, {
      leftPanelCollapsed: collapsed,
    });
  },
  [types.SET_RIGHT_PANEL_COLLAPSED](state, collapsed) {
48
    Object.assign(state, {
49
      rightPanelCollapsed: collapsed,
50 51
    });
  },
52 53 54 55 56
  [types.SET_RESIZING_STATUS](state, resizing) {
    Object.assign(state, {
      panelResizing: resizing,
    });
  },
57 58
  [types.SET_LAST_COMMIT_DATA](state, { entry, lastCommit }) {
    Object.assign(entry.lastCommit, {
59
      id: lastCommit.commit.id,
60
      url: lastCommit.commit_path,
61
      message: lastCommit.commit.message,
62
      author: lastCommit.commit.author_name,
63 64 65
      updatedAt: lastCommit.commit.authored_date,
    });
  },
66
  ...projectMutations,
67 68 69 70
  ...fileMutations,
  ...treeMutations,
  ...branchMutations,
};