Commit 015889ef authored by Kushal Pandya's avatar Kushal Pandya

Merge branch...

Merge branch '18140-add-to-next-and-previous-commit-buttons-when-viewing-commits-in-merge-request' into 'master'

Allow changing only the diffFiles in state without touching other state values

See merge request gitlab-org/gitlab!28962
parents a51cb94c a5b955de
......@@ -2,8 +2,11 @@ export const SET_BASE_CONFIG = 'SET_BASE_CONFIG';
export const SET_LOADING = 'SET_LOADING';
export const SET_BATCH_LOADING = 'SET_BATCH_LOADING';
export const SET_RETRIEVING_BATCHES = 'SET_RETRIEVING_BATCHES';
export const SET_DIFF_DATA = 'SET_DIFF_DATA';
export const SET_DIFF_DATA_BATCH = 'SET_DIFF_DATA_BATCH';
export const SET_DIFF_FILES = 'SET_DIFF_FILES';
export const SET_DIFF_VIEW_TYPE = 'SET_DIFF_VIEW_TYPE';
export const SET_COVERAGE_DATA = 'SET_COVERAGE_DATA';
export const SET_MERGE_REQUEST_DIFFS = 'SET_MERGE_REQUEST_DIFFS';
......
......@@ -10,6 +10,10 @@ import {
} from './utils';
import * as types from './mutation_types';
function updateDiffFilesInState(state, files) {
return Object.assign(state, { diffFiles: files });
}
export default {
[types.SET_BASE_CONFIG](state, options) {
const {
......@@ -46,6 +50,10 @@ export default {
Object.assign(state, { retrievingBatches });
},
[types.SET_DIFF_FILES](state, files) {
updateDiffFilesInState(state, files);
},
[types.SET_DIFF_DATA](state, data) {
let files = state.diffFiles;
......@@ -58,8 +66,8 @@ export default {
Object.assign(state, {
...convertObjectPropsToCamelCase(data),
diffFiles: files,
});
updateDiffFilesInState(state, files);
},
[types.SET_DIFF_DATA_BATCH](state, data) {
......@@ -67,8 +75,8 @@ export default {
Object.assign(state, {
...convertObjectPropsToCamelCase(data),
diffFiles: files,
});
updateDiffFilesInState(state, files);
},
[types.SET_COVERAGE_DATA](state, coverageFiles) {
......
......@@ -51,6 +51,24 @@ describe('DiffsStoreMutations', () => {
});
});
describe('SET_DIFF_FILES', () => {
it('should set diffFiles in state', () => {
const state = {};
mutations[types.SET_DIFF_FILES](state, ['file', 'another file']);
expect(state.diffFiles.length).toEqual(2);
});
it('should not set anything except diffFiles in state', () => {
const state = {};
mutations[types.SET_DIFF_FILES](state, ['file', 'another file']);
expect(Object.keys(state)).toEqual(['diffFiles']);
});
});
describe('SET_DIFF_DATA', () => {
it('should set diff data type properly', () => {
const state = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment