Commit f2e90bc2 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'ide-pipeline-reset-state' into 'master'

Resets state correctly when switching to merge request in IDE

Closes #47763

See merge request gitlab-org/gitlab-ce!19707
parents 3ec72f51 cf22366d
...@@ -20,7 +20,13 @@ export default { ...@@ -20,7 +20,13 @@ export default {
}, },
}, },
computed: { computed: {
...mapState(['rightPanelCollapsed', 'viewer', 'panelResizing', 'currentActivityView']), ...mapState([
'rightPanelCollapsed',
'viewer',
'panelResizing',
'currentActivityView',
'rightPane',
]),
...mapGetters([ ...mapGetters([
'currentMergeRequest', 'currentMergeRequest',
'getStagedFile', 'getStagedFile',
...@@ -88,6 +94,9 @@ export default { ...@@ -88,6 +94,9 @@ export default {
this.editor.updateDimensions(); this.editor.updateDimensions();
} }
}, },
rightPane() {
this.editor.updateDimensions();
},
}, },
beforeDestroy() { beforeDestroy() {
this.editor.dispose(); this.editor.dispose();
......
...@@ -31,15 +31,16 @@ export const openMergeRequest = ({ commit, dispatch }, { projectPath, id }) => { ...@@ -31,15 +31,16 @@ export const openMergeRequest = ({ commit, dispatch }, { projectPath, id }) => {
commit(rootTypes.CLEAR_PROJECTS, null, { root: true }); commit(rootTypes.CLEAR_PROJECTS, null, { root: true });
commit(rootTypes.SET_CURRENT_MERGE_REQUEST, `${id}`, { root: true }); commit(rootTypes.SET_CURRENT_MERGE_REQUEST, `${id}`, { root: true });
commit(rootTypes.RESET_OPEN_FILES, null, { root: true }); commit(rootTypes.RESET_OPEN_FILES, null, { root: true });
dispatch('pipelines/resetLatestPipeline', null, { root: true });
dispatch('setCurrentBranchId', '', { root: true }); dispatch('setCurrentBranchId', '', { root: true });
dispatch('pipelines/stopPipelinePolling', null, { root: true }) dispatch('pipelines/stopPipelinePolling', null, { root: true })
.then(() => { .then(() => {
dispatch('pipelines/resetLatestPipeline', null, { root: true });
dispatch('pipelines/clearEtagPoll', null, { root: true }); dispatch('pipelines/clearEtagPoll', null, { root: true });
}) })
.catch(e => { .catch(e => {
throw e; throw e;
}); });
dispatch('setRightPane', null, { root: true });
router.push(`/project/${projectPath}/merge_requests/${id}`); router.push(`/project/${projectPath}/merge_requests/${id}`);
}; };
......
...@@ -106,7 +106,9 @@ export const fetchJobTrace = ({ dispatch, state }) => { ...@@ -106,7 +106,9 @@ export const fetchJobTrace = ({ dispatch, state }) => {
.catch(() => dispatch('receiveJobTraceError')); .catch(() => dispatch('receiveJobTraceError'));
}; };
export const resetLatestPipeline = ({ commit }) => export const resetLatestPipeline = ({ commit }) => {
commit(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, null); commit(types.RECEIVE_LASTEST_PIPELINE_SUCCESS, null);
commit(types.SET_DETAIL_JOB, null);
};
export default () => {}; export default () => {};
...@@ -315,6 +315,17 @@ describe('RepoEditor', () => { ...@@ -315,6 +315,17 @@ describe('RepoEditor', () => {
done(); done();
}); });
}); });
it('calls updateDimensions when rightPane is updated', done => {
vm.$store.state.rightPane = 'testing';
vm.$nextTick(() => {
expect(vm.editor.updateDimensions).toHaveBeenCalled();
expect(vm.editor.updateDiffView).toHaveBeenCalled();
done();
});
});
}); });
describe('show tabs', () => { describe('show tabs', () => {
......
...@@ -208,18 +208,19 @@ describe('IDE merge requests actions', () => { ...@@ -208,18 +208,19 @@ describe('IDE merge requests actions', () => {
expect(commit.calls.argsFor(1)).toEqual(['SET_CURRENT_MERGE_REQUEST', '1', { root: true }]); expect(commit.calls.argsFor(1)).toEqual(['SET_CURRENT_MERGE_REQUEST', '1', { root: true }]);
expect(commit.calls.argsFor(2)).toEqual(['RESET_OPEN_FILES', null, { root: true }]); expect(commit.calls.argsFor(2)).toEqual(['RESET_OPEN_FILES', null, { root: true }]);
expect(dispatch.calls.argsFor(0)).toEqual([ expect(dispatch.calls.argsFor(0)).toEqual(['setCurrentBranchId', '', { root: true }]);
'pipelines/resetLatestPipeline', expect(dispatch.calls.argsFor(1)).toEqual([
'pipelines/stopPipelinePolling',
null, null,
{ root: true }, { root: true },
]); ]);
expect(dispatch.calls.argsFor(1)).toEqual(['setCurrentBranchId', '', { root: true }]); expect(dispatch.calls.argsFor(2)).toEqual(['setRightPane', null, { root: true }]);
expect(dispatch.calls.argsFor(2)).toEqual([ expect(dispatch.calls.argsFor(3)).toEqual([
'pipelines/stopPipelinePolling', 'pipelines/resetLatestPipeline',
null, null,
{ root: true }, { root: true },
]); ]);
expect(dispatch.calls.argsFor(3)).toEqual([ expect(dispatch.calls.argsFor(4)).toEqual([
'pipelines/clearEtagPoll', 'pipelines/clearEtagPoll',
null, null,
{ root: true }, { root: true },
......
...@@ -18,6 +18,7 @@ import actions, { ...@@ -18,6 +18,7 @@ import actions, {
receiveJobTraceError, receiveJobTraceError,
receiveJobTraceSuccess, receiveJobTraceSuccess,
fetchJobTrace, fetchJobTrace,
resetLatestPipeline,
} from '~/ide/stores/modules/pipelines/actions'; } from '~/ide/stores/modules/pipelines/actions';
import state from '~/ide/stores/modules/pipelines/state'; import state from '~/ide/stores/modules/pipelines/state';
import * as types from '~/ide/stores/modules/pipelines/mutation_types'; import * as types from '~/ide/stores/modules/pipelines/mutation_types';
...@@ -416,4 +417,20 @@ describe('IDE pipelines actions', () => { ...@@ -416,4 +417,20 @@ describe('IDE pipelines actions', () => {
}); });
}); });
}); });
describe('resetLatestPipeline', () => {
it('commits reset mutations', done => {
testAction(
resetLatestPipeline,
null,
mockedState,
[
{ type: types.RECEIVE_LASTEST_PIPELINE_SUCCESS, payload: null },
{ type: types.SET_DETAIL_JOB, payload: null },
],
[],
done,
);
});
});
}); });
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