diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-11-20 20:52:50 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-11-20 20:52:50 +0300 |
commit | ac6673ddcfda0a0229b86f22543d31ddccc1dc55 (patch) | |
tree | db6982096f85f6d304127d3fc9cd7836978ccb46 | |
parent | d179ffc25ceb7ffd9bf241494c03a8d90a0aab58 (diff) | |
parent | b24316b2fe757324b037aea7e06ce52d8dfa53d8 (diff) |
Merge branch 'ide-open-all-mr-files' into 'master'
Open first 10 merge request files in IDE
Closes #51635
See merge request gitlab-org/gitlab-ce!23234
4 files changed, 40 insertions, 6 deletions
diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js index 30dcf7ef4df..a297740bd5f 100644 --- a/app/assets/javascripts/ide/stores/actions/file.js +++ b/app/assets/javascripts/ide/stores/actions/file.js @@ -56,7 +56,10 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => { dispatch('scrollToTab'); }; -export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive = true }) => { +export const getFileData = ( + { state, commit, dispatch }, + { path, makeFileActive = true, openFile = makeFileActive }, +) => { const file = state.entries[path]; if (file.raw || (file.tempFile && !file.prevPath)) return Promise.resolve(); @@ -71,8 +74,8 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive const normalizedHeaders = normalizeHeaders(headers); setPageTitle(decodeURI(normalizedHeaders['PAGE-TITLE'])); - commit(types.SET_FILE_DATA, { data, file }); - if (makeFileActive) commit(types.TOGGLE_FILE_OPEN, path); + if (data) commit(types.SET_FILE_DATA, { data, file }); + if (openFile) commit(types.TOGGLE_FILE_OPEN, path); if (makeFileActive) dispatch('setFileActive', path); commit(types.TOGGLE_LOADING, { entry: file }); }) diff --git a/app/assets/javascripts/ide/stores/actions/merge_request.js b/app/assets/javascripts/ide/stores/actions/merge_request.js index 3ac2f8b3698..8404c6d4f72 100644 --- a/app/assets/javascripts/ide/stores/actions/merge_request.js +++ b/app/assets/javascripts/ide/stores/actions/merge_request.js @@ -161,6 +161,7 @@ export const openMergeRequest = ( dispatch('getFileData', { path: change.new_path, makeFileActive: ind === 0, + openFile: true, }); } } diff --git a/changelogs/unreleased/ide-open-all-mr-files.yml b/changelogs/unreleased/ide-open-all-mr-files.yml new file mode 100644 index 00000000000..6a5ea8908fc --- /dev/null +++ b/changelogs/unreleased/ide-open-all-mr-files.yml @@ -0,0 +1,5 @@ +--- +title: Open first 10 merge request files in IDE +merge_request: +author: +type: fixed diff --git a/spec/javascripts/ide/stores/actions/merge_request_spec.js b/spec/javascripts/ide/stores/actions/merge_request_spec.js index 3a4e0d7507f..d8e9260e932 100644 --- a/spec/javascripts/ide/stores/actions/merge_request_spec.js +++ b/spec/javascripts/ide/stores/actions/merge_request_spec.js @@ -262,16 +262,28 @@ describe('IDE store merge request actions', () => { bar: {}, }; - spyOn(store, 'dispatch').and.callFake(type => { + const originalDispatch = store.dispatch; + + spyOn(store, 'dispatch').and.callFake((type, payload) => { switch (type) { case 'getMergeRequestData': return Promise.resolve(testMergeRequest); case 'getMergeRequestChanges': return Promise.resolve(testMergeRequestChanges); - default: + case 'getFiles': + case 'getMergeRequestVersions': + case 'getBranchData': + case 'setFileMrChange': return Promise.resolve(); + default: + return originalDispatch(type, payload); } }); + spyOn(service, 'getFileData').and.callFake(() => + Promise.resolve({ + headers: {}, + }), + ); }); it('dispatch actions for merge request data', done => { @@ -303,7 +315,17 @@ describe('IDE store merge request actions', () => { }); it('updates activity bar view and gets file data, if changes are found', done => { - testMergeRequestChanges.changes = [{ new_path: 'foo' }, { new_path: 'bar' }]; + store.state.entries.foo = { + url: 'test', + }; + store.state.entries.bar = { + url: 'test', + }; + + testMergeRequestChanges.changes = [ + { new_path: 'foo', path: 'foo' }, + { new_path: 'bar', path: 'bar' }, + ]; openMergeRequest(store, mr) .then(() => { @@ -321,8 +343,11 @@ describe('IDE store merge request actions', () => { expect(store.dispatch).toHaveBeenCalledWith('getFileData', { path: change.new_path, makeFileActive: i === 0, + openFile: true, }); }); + + expect(store.state.openFiles.length).toBe(testMergeRequestChanges.changes.length); }) .then(done) .catch(done.fail); |