All files / app/assets/javascripts/merge_conflicts/store mutations.js

100% Statements 10/10
100% Branches 0/0
100% Functions 8/8
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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          14x     1x     1x 1x     3x 3x     1x     13x                 1x           2x      
import { VIEW_TYPES } from '../constants';
import * as types from './mutation_types';
 
export default {
  [types.SET_LOADING_STATE]: (state, value) => {
    state.isLoading = value;
  },
  [types.SET_ERROR_STATE]: (state, value) => {
    state.hasError = value;
  },
  [types.SET_FAILED_REQUEST]: (state, value) => {
    state.hasError = true;
    state.conflictsData.errorMessage = value;
  },
  [types.SET_VIEW_TYPE]: (state, value) => {
    state.diffView = value;
    state.isParallel = value === VIEW_TYPES.PARALLEL;
  },
  [types.SET_SUBMIT_STATE]: (state, value) => {
    state.isSubmitting = value;
  },
  [types.SET_CONFLICTS_DATA]: (state, data) => {
    state.conflictsData = {
      files: data.files,
      commitMessage: data.commit_message,
      sourceBranch: data.source_branch,
      targetBranch: data.target_branch,
      shortCommitSha: data.commit_sha.slice(0, 7),
    };
  },
  [types.UPDATE_CONFLICTS_DATA]: (state, payload) => {
    state.conflictsData = {
      ...state.conflictsData,
      ...payload,
    };
  },
  [types.UPDATE_FILE]: (state, { file, index }) => {
    state.conflictsData.files.splice(index, 1, file);
  },
};