Commit d5a24021 authored by Yorick Peterse's avatar Yorick Peterse

Revert "Merge branch 'ide-open-all-mr-files' into 'master'"

This reverts merge request !23234
parent 5ba820ad
...@@ -56,10 +56,7 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => { ...@@ -56,10 +56,7 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => {
dispatch('scrollToTab'); dispatch('scrollToTab');
}; };
export const getFileData = ( export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive = true }) => {
{ state, commit, dispatch },
{ path, makeFileActive = true, openFile = makeFileActive },
) => {
const file = state.entries[path]; const file = state.entries[path];
if (file.raw || (file.tempFile && !file.prevPath)) return Promise.resolve(); if (file.raw || (file.tempFile && !file.prevPath)) return Promise.resolve();
...@@ -74,8 +71,8 @@ export const getFileData = ( ...@@ -74,8 +71,8 @@ export const getFileData = (
const normalizedHeaders = normalizeHeaders(headers); const normalizedHeaders = normalizeHeaders(headers);
setPageTitle(decodeURI(normalizedHeaders['PAGE-TITLE'])); setPageTitle(decodeURI(normalizedHeaders['PAGE-TITLE']));
if (data) commit(types.SET_FILE_DATA, { data, file }); commit(types.SET_FILE_DATA, { data, file });
if (openFile) commit(types.TOGGLE_FILE_OPEN, path); if (makeFileActive) commit(types.TOGGLE_FILE_OPEN, path);
if (makeFileActive) dispatch('setFileActive', path); if (makeFileActive) dispatch('setFileActive', path);
commit(types.TOGGLE_LOADING, { entry: file }); commit(types.TOGGLE_LOADING, { entry: file });
}) })
......
...@@ -161,7 +161,6 @@ export const openMergeRequest = ( ...@@ -161,7 +161,6 @@ export const openMergeRequest = (
dispatch('getFileData', { dispatch('getFileData', {
path: change.new_path, path: change.new_path,
makeFileActive: ind === 0, makeFileActive: ind === 0,
openFile: true,
}); });
} }
} }
......
---
title: Open first 10 merge request files in IDE
merge_request:
author:
type: fixed
...@@ -262,28 +262,16 @@ describe('IDE store merge request actions', () => { ...@@ -262,28 +262,16 @@ describe('IDE store merge request actions', () => {
bar: {}, bar: {},
}; };
const originalDispatch = store.dispatch; spyOn(store, 'dispatch').and.callFake(type => {
spyOn(store, 'dispatch').and.callFake((type, payload) => {
switch (type) { switch (type) {
case 'getMergeRequestData': case 'getMergeRequestData':
return Promise.resolve(testMergeRequest); return Promise.resolve(testMergeRequest);
case 'getMergeRequestChanges': case 'getMergeRequestChanges':
return Promise.resolve(testMergeRequestChanges); return Promise.resolve(testMergeRequestChanges);
case 'getFiles':
case 'getMergeRequestVersions':
case 'getBranchData':
case 'setFileMrChange':
return Promise.resolve();
default: default:
return originalDispatch(type, payload); return Promise.resolve();
} }
}); });
spyOn(service, 'getFileData').and.callFake(() =>
Promise.resolve({
headers: {},
}),
);
}); });
it('dispatch actions for merge request data', done => { it('dispatch actions for merge request data', done => {
...@@ -315,17 +303,7 @@ describe('IDE store merge request actions', () => { ...@@ -315,17 +303,7 @@ describe('IDE store merge request actions', () => {
}); });
it('updates activity bar view and gets file data, if changes are found', done => { it('updates activity bar view and gets file data, if changes are found', done => {
store.state.entries.foo = { testMergeRequestChanges.changes = [{ new_path: 'foo' }, { new_path: 'bar' }];
url: 'test',
};
store.state.entries.bar = {
url: 'test',
};
testMergeRequestChanges.changes = [
{ new_path: 'foo', path: 'foo' },
{ new_path: 'bar', path: 'bar' },
];
openMergeRequest(store, mr) openMergeRequest(store, mr)
.then(() => { .then(() => {
...@@ -343,11 +321,8 @@ describe('IDE store merge request actions', () => { ...@@ -343,11 +321,8 @@ describe('IDE store merge request actions', () => {
expect(store.dispatch).toHaveBeenCalledWith('getFileData', { expect(store.dispatch).toHaveBeenCalledWith('getFileData', {
path: change.new_path, path: change.new_path,
makeFileActive: i === 0, makeFileActive: i === 0,
openFile: true,
}); });
}); });
expect(store.state.openFiles.length).toBe(testMergeRequestChanges.changes.length);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
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