Commit a0de16c7 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '33183-integrate-with-feature-flag' into 'master'

Integrate the frontend with the `single_mr_diff_view` feature flag

See merge request gitlab-org/gitlab!21366
parents 65e476a8 6ea00689
...@@ -177,6 +177,7 @@ export default { ...@@ -177,6 +177,7 @@ export default {
projectPath: this.projectPath, projectPath: this.projectPath,
dismissEndpoint: this.dismissEndpoint, dismissEndpoint: this.dismissEndpoint,
showSuggestPopover: this.showSuggestPopover, showSuggestPopover: this.showSuggestPopover,
useSingleDiffStyle: this.glFeatures.singleMrDiffView,
}); });
if (this.shouldShow) { if (this.shouldShow) {
......
...@@ -46,6 +46,7 @@ export const setBaseConfig = ({ commit }, options) => { ...@@ -46,6 +46,7 @@ export const setBaseConfig = ({ commit }, options) => {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
} = options; } = options;
commit(types.SET_BASE_CONFIG, { commit(types.SET_BASE_CONFIG, {
endpoint, endpoint,
...@@ -54,11 +55,15 @@ export const setBaseConfig = ({ commit }, options) => { ...@@ -54,11 +55,15 @@ export const setBaseConfig = ({ commit }, options) => {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
}); });
}; };
export const fetchDiffFiles = ({ state, commit }) => { export const fetchDiffFiles = ({ state, commit }) => {
const worker = new TreeWorker(); const worker = new TreeWorker();
const urlParams = {
w: state.showWhitespace ? '0' : '1',
};
commit(types.SET_LOADING, true); commit(types.SET_LOADING, true);
...@@ -69,9 +74,10 @@ export const fetchDiffFiles = ({ state, commit }) => { ...@@ -69,9 +74,10 @@ export const fetchDiffFiles = ({ state, commit }) => {
}); });
return axios return axios
.get(mergeUrlParams({ w: state.showWhitespace ? '0' : '1' }, state.endpoint)) .get(mergeUrlParams(urlParams, state.endpoint))
.then(res => { .then(res => {
commit(types.SET_LOADING, false); commit(types.SET_LOADING, false);
commit(types.SET_MERGE_REQUEST_DIFFS, res.data.merge_request_diffs || []); commit(types.SET_MERGE_REQUEST_DIFFS, res.data.merge_request_diffs || []);
commit(types.SET_DIFF_DATA, res.data); commit(types.SET_DIFF_DATA, res.data);
......
...@@ -31,4 +31,5 @@ export default () => ({ ...@@ -31,4 +31,5 @@ export default () => ({
fileFinderVisible: false, fileFinderVisible: false,
dismissEndpoint: '', dismissEndpoint: '',
showSuggestPopover: true, showSuggestPopover: true,
useSingleDiffStyle: false,
}); });
...@@ -19,6 +19,7 @@ export default { ...@@ -19,6 +19,7 @@ export default {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
} = options; } = options;
Object.assign(state, { Object.assign(state, {
endpoint, endpoint,
...@@ -27,6 +28,7 @@ export default { ...@@ -27,6 +28,7 @@ export default {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
}); });
}, },
......
...@@ -20,6 +20,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -20,6 +20,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
before_action :check_user_can_push_to_source_branch!, only: [:rebase] before_action :check_user_can_push_to_source_branch!, only: [:rebase]
before_action only: [:show] do before_action only: [:show] do
push_frontend_feature_flag(:diffs_batch_load, @project) push_frontend_feature_flag(:diffs_batch_load, @project)
push_frontend_feature_flag(:single_mr_diff_view, @project)
end end
before_action do before_action do
......
...@@ -41,6 +41,7 @@ describe('diffs/components/app', () => { ...@@ -41,6 +41,7 @@ describe('diffs/components/app', () => {
changesEmptyStateIllustration: '', changesEmptyStateIllustration: '',
dismissEndpoint: '', dismissEndpoint: '',
showSuggestPopover: true, showSuggestPopover: true,
useSingleDiffStyle: false,
...props, ...props,
}, },
store, store,
......
...@@ -75,6 +75,7 @@ describe('DiffsStoreActions', () => { ...@@ -75,6 +75,7 @@ describe('DiffsStoreActions', () => {
const projectPath = '/root/project'; const projectPath = '/root/project';
const dismissEndpoint = '/-/user_callouts'; const dismissEndpoint = '/-/user_callouts';
const showSuggestPopover = false; const showSuggestPopover = false;
const useSingleDiffStyle = false;
testAction( testAction(
setBaseConfig, setBaseConfig,
...@@ -85,6 +86,7 @@ describe('DiffsStoreActions', () => { ...@@ -85,6 +86,7 @@ describe('DiffsStoreActions', () => {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
}, },
{ {
endpoint: '', endpoint: '',
...@@ -93,6 +95,7 @@ describe('DiffsStoreActions', () => { ...@@ -93,6 +95,7 @@ describe('DiffsStoreActions', () => {
projectPath: '', projectPath: '',
dismissEndpoint: '', dismissEndpoint: '',
showSuggestPopover: true, showSuggestPopover: true,
useSingleDiffStyle: true,
}, },
[ [
{ {
...@@ -104,6 +107,7 @@ describe('DiffsStoreActions', () => { ...@@ -104,6 +107,7 @@ describe('DiffsStoreActions', () => {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
}, },
}, },
], ],
......
...@@ -10,11 +10,13 @@ describe('DiffsStoreMutations', () => { ...@@ -10,11 +10,13 @@ describe('DiffsStoreMutations', () => {
const state = {}; const state = {};
const endpoint = '/diffs/endpoint'; const endpoint = '/diffs/endpoint';
const projectPath = '/root/project'; const projectPath = '/root/project';
const useSingleDiffStyle = false;
mutations[types.SET_BASE_CONFIG](state, { endpoint, projectPath }); mutations[types.SET_BASE_CONFIG](state, { endpoint, projectPath, useSingleDiffStyle });
expect(state.endpoint).toEqual(endpoint); expect(state.endpoint).toEqual(endpoint);
expect(state.projectPath).toEqual(projectPath); expect(state.projectPath).toEqual(projectPath);
expect(state.useSingleDiffStyle).toEqual(useSingleDiffStyle);
}); });
}); });
......
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