Commit 385ebb6c authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'ph/removeSingleDiffViewFeatureFlag' into 'master'

Removes the single diff view feature flag

See merge request gitlab-org/gitlab!40406
parents 9699f0d7 1a454362
...@@ -229,7 +229,6 @@ export default { ...@@ -229,7 +229,6 @@ export default {
projectPath: this.projectPath, projectPath: this.projectPath,
dismissEndpoint: this.dismissEndpoint, dismissEndpoint: this.dismissEndpoint,
showSuggestPopover: this.showSuggestPopover, showSuggestPopover: this.showSuggestPopover,
useSingleDiffStyle: this.glFeatures.singleMrDiffView,
viewDiffsFileByFile: this.viewDiffsFileByFile, viewDiffsFileByFile: this.viewDiffsFileByFile,
}); });
...@@ -306,14 +305,10 @@ export default { ...@@ -306,14 +305,10 @@ export default {
); );
}, },
needsReload() { needsReload() {
return ( return this.diffFiles.length && isSingleViewStyle(this.diffFiles[0]);
this.glFeatures.singleMrDiffView &&
this.diffFiles.length &&
isSingleViewStyle(this.diffFiles[0])
);
}, },
needsFirstLoad() { needsFirstLoad() {
return this.glFeatures.singleMrDiffView && !this.diffFiles.length; return !this.diffFiles.length;
}, },
fetchData(toggleTree = true) { fetchData(toggleTree = true) {
if (this.glFeatures.diffsBatchLoad) { if (this.glFeatures.diffsBatchLoad) {
......
...@@ -52,7 +52,6 @@ export const setBaseConfig = ({ commit }, options) => { ...@@ -52,7 +52,6 @@ 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,
...@@ -62,7 +61,6 @@ export const setBaseConfig = ({ commit }, options) => { ...@@ -62,7 +61,6 @@ export const setBaseConfig = ({ commit }, options) => {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
}); });
}; };
...@@ -70,13 +68,10 @@ export const fetchDiffFiles = ({ state, commit }) => { ...@@ -70,13 +68,10 @@ export const fetchDiffFiles = ({ state, commit }) => {
const worker = new TreeWorker(); const worker = new TreeWorker();
const urlParams = { const urlParams = {
w: state.showWhitespace ? '0' : '1', w: state.showWhitespace ? '0' : '1',
view: window.gon?.features?.unifiedDiffLines ? 'inline' : state.diffViewType,
}; };
let returnData; let returnData;
if (state.useSingleDiffStyle) {
urlParams.view = window.gon?.features?.unifiedDiffLines ? 'inline' : state.diffViewType;
}
commit(types.SET_LOADING, true); commit(types.SET_LOADING, true);
worker.addEventListener('message', ({ data }) => { worker.addEventListener('message', ({ data }) => {
...@@ -111,12 +106,9 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => { ...@@ -111,12 +106,9 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => {
const urlParams = { const urlParams = {
per_page: DIFFS_PER_PAGE, per_page: DIFFS_PER_PAGE,
w: state.showWhitespace ? '0' : '1', w: state.showWhitespace ? '0' : '1',
view: window.gon?.features?.unifiedDiffLines ? 'inline' : state.diffViewType,
}; };
if (state.useSingleDiffStyle) {
urlParams.view = window.gon?.features?.unifiedDiffLines ? 'inline' : state.diffViewType;
}
commit(types.SET_BATCH_LOADING, true); commit(types.SET_BATCH_LOADING, true);
commit(types.SET_RETRIEVING_BATCHES, true); commit(types.SET_RETRIEVING_BATCHES, true);
...@@ -175,11 +167,9 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => { ...@@ -175,11 +167,9 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => {
export const fetchDiffFilesMeta = ({ commit, state }) => { export const fetchDiffFilesMeta = ({ commit, state }) => {
const worker = new TreeWorker(); const worker = new TreeWorker();
const urlParams = {}; const urlParams = {
view: window.gon?.features?.unifiedDiffLines ? 'inline' : state.diffViewType,
if (state.useSingleDiffStyle) { };
urlParams.view = window.gon?.features?.unifiedDiffLines ? 'inline' : state.diffViewType;
}
commit(types.SET_LOADING, true); commit(types.SET_LOADING, true);
...@@ -240,10 +230,7 @@ export const assignDiscussionsToDiff = ( ...@@ -240,10 +230,7 @@ export const assignDiscussionsToDiff = (
) => { ) => {
const id = window?.location?.hash; const id = window?.location?.hash;
const isNoteLink = id.indexOf('#note') === 0; const isNoteLink = id.indexOf('#note') === 0;
const diffPositionByLineCode = getDiffPositionByLineCode( const diffPositionByLineCode = getDiffPositionByLineCode(state.diffFiles);
state.diffFiles,
state.useSingleDiffStyle,
);
const hash = getLocationHash(); const hash = getLocationHash();
discussions discussions
......
...@@ -41,5 +41,4 @@ export default () => ({ ...@@ -41,5 +41,4 @@ export default () => ({
fileFinderVisible: false, fileFinderVisible: false,
dismissEndpoint: '', dismissEndpoint: '',
showSuggestPopover: true, showSuggestPopover: true,
useSingleDiffStyle: false,
}); });
...@@ -25,7 +25,6 @@ export default { ...@@ -25,7 +25,6 @@ export default {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
} = options; } = options;
Object.assign(state, { Object.assign(state, {
endpoint, endpoint,
...@@ -35,7 +34,6 @@ export default { ...@@ -35,7 +34,6 @@ export default {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
}); });
}, },
......
...@@ -495,11 +495,11 @@ export function prepareDiffData(diff, priorFiles = []) { ...@@ -495,11 +495,11 @@ export function prepareDiffData(diff, priorFiles = []) {
return deduplicateFilesList([...priorFiles, ...cleanedFiles]); return deduplicateFilesList([...priorFiles, ...cleanedFiles]);
} }
export function getDiffPositionByLineCode(diffFiles, useSingleDiffStyle) { export function getDiffPositionByLineCode(diffFiles) {
let lines = []; let lines = [];
const hasInlineDiffs = diffFiles.some(file => file.highlighted_diff_lines.length > 0); const hasInlineDiffs = diffFiles.some(file => file.highlighted_diff_lines.length > 0);
if (!useSingleDiffStyle || hasInlineDiffs) { if (hasInlineDiffs) {
// In either of these cases, we can use `highlighted_diff_lines` because // In either of these cases, we can use `highlighted_diff_lines` because
// that will include all of the parallel diff lines, too // that will include all of the parallel diff lines, too
......
...@@ -27,7 +27,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -27,7 +27,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
before_action only: [:show] do before_action only: [:show] do
push_frontend_feature_flag(:diffs_batch_load, @project, default_enabled: true) push_frontend_feature_flag(:diffs_batch_load, @project, default_enabled: true)
push_frontend_feature_flag(:deploy_from_footer, @project, default_enabled: true) push_frontend_feature_flag(:deploy_from_footer, @project, default_enabled: true)
push_frontend_feature_flag(:single_mr_diff_view, @project, default_enabled: true)
push_frontend_feature_flag(:suggest_pipeline) if experiment_enabled?(:suggest_pipeline) push_frontend_feature_flag(:suggest_pipeline) if experiment_enabled?(:suggest_pipeline)
push_frontend_feature_flag(:code_navigation, @project, default_enabled: true) push_frontend_feature_flag(:code_navigation, @project, default_enabled: true)
push_frontend_feature_flag(:widget_visibility_polling, @project, default_enabled: true) push_frontend_feature_flag(:widget_visibility_polling, @project, default_enabled: true)
......
...@@ -71,15 +71,11 @@ class DiffFileEntity < DiffFileBaseEntity ...@@ -71,15 +71,11 @@ class DiffFileEntity < DiffFileBaseEntity
private private
def parallel_diff_view?(options, diff_file) def parallel_diff_view?(options, diff_file)
return true unless Feature.enabled?(:single_mr_diff_view, diff_file.repository.project, default_enabled: true)
# If we're not rendering inline, we must be rendering parallel # If we're not rendering inline, we must be rendering parallel
!inline_diff_view?(options, diff_file) !inline_diff_view?(options, diff_file)
end end
def inline_diff_view?(options, diff_file) def inline_diff_view?(options, diff_file)
return true unless Feature.enabled?(:single_mr_diff_view, diff_file.repository.project, default_enabled: true)
# If nothing is present, inline will be the default. # If nothing is present, inline will be the default.
options.fetch(:diff_view, :inline).to_sym == :inline options.fetch(:diff_view, :inline).to_sym == :inline
end end
......
...@@ -20,8 +20,6 @@ RSpec.describe 'a maintainer edits files on a source-branch of an MR from a fork ...@@ -20,8 +20,6 @@ RSpec.describe 'a maintainer edits files on a source-branch of an MR from a fork
end end
before do before do
stub_feature_flags(single_mr_diff_view: false)
target_project.add_maintainer(user) target_project.add_maintainer(user)
sign_in(user) sign_in(user)
......
...@@ -10,7 +10,6 @@ RSpec.describe 'Batch diffs', :js do ...@@ -10,7 +10,6 @@ RSpec.describe 'Batch diffs', :js do
let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'master', target_branch: 'empty-branch') } let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'master', target_branch: 'empty-branch') }
before do before do
stub_feature_flags(single_mr_diff_view: project)
stub_feature_flags(diffs_batch_load: true) stub_feature_flags(diffs_batch_load: true)
sign_in(project.owner) sign_in(project.owner)
......
...@@ -160,10 +160,6 @@ describe('diffs/components/app', () => { ...@@ -160,10 +160,6 @@ describe('diffs/components/app', () => {
}); });
} }
beforeEach(() => {
wrapper.vm.glFeatures.singleMrDiffView = true;
});
it('fetches diffs if it has none', done => { it('fetches diffs if it has none', done => {
wrapper.vm.isLatestVersion = () => false; wrapper.vm.isLatestVersion = () => false;
......
...@@ -101,7 +101,6 @@ describe('DiffsStoreActions', () => { ...@@ -101,7 +101,6 @@ 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,
...@@ -113,7 +112,6 @@ describe('DiffsStoreActions', () => { ...@@ -113,7 +112,6 @@ describe('DiffsStoreActions', () => {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
}, },
{ {
endpoint: '', endpoint: '',
...@@ -123,7 +121,6 @@ describe('DiffsStoreActions', () => { ...@@ -123,7 +121,6 @@ describe('DiffsStoreActions', () => {
projectPath: '', projectPath: '',
dismissEndpoint: '', dismissEndpoint: '',
showSuggestPopover: true, showSuggestPopover: true,
useSingleDiffStyle: true,
}, },
[ [
{ {
...@@ -136,7 +133,6 @@ describe('DiffsStoreActions', () => { ...@@ -136,7 +133,6 @@ describe('DiffsStoreActions', () => {
projectPath, projectPath,
dismissEndpoint, dismissEndpoint,
showSuggestPopover, showSuggestPopover,
useSingleDiffStyle,
}, },
}, },
], ],
...@@ -169,13 +165,6 @@ describe('DiffsStoreActions', () => { ...@@ -169,13 +165,6 @@ describe('DiffsStoreActions', () => {
done(); done();
}, },
); );
fetchDiffFiles({ state: { endpoint }, commit: () => null })
.then(data => {
expect(data).toEqual(res);
done();
})
.catch(done.fail);
}); });
}); });
...@@ -223,7 +212,7 @@ describe('DiffsStoreActions', () => { ...@@ -223,7 +212,7 @@ describe('DiffsStoreActions', () => {
testAction( testAction(
fetchDiffFilesBatch, fetchDiffFilesBatch,
{}, {},
{ endpointBatch, useSingleDiffStyle: true, diffViewType: 'inline' }, { endpointBatch, diffViewType: 'inline' },
[ [
{ type: types.SET_BATCH_LOADING, payload: true }, { type: types.SET_BATCH_LOADING, payload: true },
{ type: types.SET_RETRIEVING_BATCHES, payload: true }, { type: types.SET_RETRIEVING_BATCHES, payload: true },
...@@ -253,7 +242,6 @@ describe('DiffsStoreActions', () => { ...@@ -253,7 +242,6 @@ describe('DiffsStoreActions', () => {
commit: () => {}, commit: () => {},
state: { state: {
endpointBatch: `${endpointBatch}?view=${otherView}`, endpointBatch: `${endpointBatch}?view=${otherView}`,
useSingleDiffStyle: true,
diffViewType: viewStyle, diffViewType: viewStyle,
}, },
}) })
...@@ -283,146 +271,7 @@ describe('DiffsStoreActions', () => { ...@@ -283,146 +271,7 @@ describe('DiffsStoreActions', () => {
testAction( testAction(
fetchDiffFilesMeta, fetchDiffFilesMeta,
{}, {},
{ endpointMetadata }, { endpointMetadata, diffViewType: 'inline' },
[
{ type: types.SET_LOADING, payload: true },
{ type: types.SET_LOADING, payload: false },
{ type: types.SET_MERGE_REQUEST_DIFFS, payload: diffMetadata.merge_request_diffs },
{ type: types.SET_DIFF_DATA, payload: noFilesData },
],
[],
() => {
mock.restore();
done();
},
);
});
});
describe('when the single diff view feature flag is off', () => {
describe('fetchDiffFiles', () => {
it('should fetch diff files', done => {
const endpoint = '/fetch/diff/files?w=1';
const mock = new MockAdapter(axios);
const res = { diff_files: 1, merge_request_diffs: [] };
mock.onGet(endpoint).reply(200, res);
testAction(
fetchDiffFiles,
{},
{
endpoint,
diffFiles: [],
showWhitespace: false,
diffViewType: 'inline',
useSingleDiffStyle: false,
currentDiffFileId: null,
},
[
{ type: types.SET_LOADING, payload: true },
{ type: types.SET_LOADING, payload: false },
{ type: types.SET_MERGE_REQUEST_DIFFS, payload: res.merge_request_diffs },
{ type: types.SET_DIFF_DATA, payload: res },
],
[],
() => {
mock.restore();
done();
},
);
fetchDiffFiles({ state: { endpoint }, commit: () => null })
.then(data => {
expect(data).toEqual(res);
done();
})
.catch(done.fail);
});
});
describe('fetchDiffFilesBatch', () => {
let mock;
beforeEach(() => {
mock = new MockAdapter(axios);
});
afterEach(() => {
mock.restore();
});
it('should fetch batch diff files', done => {
const endpointBatch = '/fetch/diffs_batch';
const res1 = { diff_files: [{ file_hash: 'test' }], pagination: { next_page: 2 } };
const res2 = { diff_files: [{ file_hash: 'test2' }], pagination: {} };
mock
.onGet(mergeUrlParams({ per_page: DIFFS_PER_PAGE, w: '1', page: 1 }, endpointBatch))
.reply(200, res1)
.onGet(mergeUrlParams({ per_page: DIFFS_PER_PAGE, w: '1', page: 2 }, endpointBatch))
.reply(200, res2);
testAction(
fetchDiffFilesBatch,
{},
{ endpointBatch, useSingleDiffStyle: false, currentDiffFileId: null },
[
{ type: types.SET_BATCH_LOADING, payload: true },
{ type: types.SET_RETRIEVING_BATCHES, payload: true },
{ type: types.SET_DIFF_DATA_BATCH, payload: { diff_files: res1.diff_files } },
{ type: types.SET_BATCH_LOADING, payload: false },
{ type: types.UPDATE_CURRENT_DIFF_FILE_ID, payload: 'test' },
{ type: types.SET_DIFF_DATA_BATCH, payload: { diff_files: res2.diff_files } },
{ type: types.SET_BATCH_LOADING, payload: false },
{ type: types.UPDATE_CURRENT_DIFF_FILE_ID, payload: 'test2' },
{ type: types.SET_RETRIEVING_BATCHES, payload: false },
],
[],
done,
);
});
it.each`
querystrings | requestUrl
${'?view=parallel'} | ${'/fetch/diffs_batch?view=parallel'}
${'?view=inline'} | ${'/fetch/diffs_batch?view=inline'}
${''} | ${'/fetch/diffs_batch'}
`(
'should use the endpoint $requestUrl if the endpointBatch in state includes `$querystrings` as a querystring',
({ querystrings, requestUrl }) => {
const endpointBatch = '/fetch/diffs_batch';
fetchDiffFilesBatch({
commit: () => {},
state: {
endpointBatch: `${endpointBatch}${querystrings}`,
diffViewType: 'inline',
},
})
.then(() => {
expect(mock.history.get[0].url).toEqual(requestUrl);
})
.catch(() => {});
},
);
});
describe('fetchDiffFilesMeta', () => {
const endpointMetadata = '/fetch/diffs_metadata.json';
const noFilesData = { ...diffMetadata };
let mock;
beforeEach(() => {
mock = new MockAdapter(axios);
delete noFilesData.diff_files;
mock.onGet(endpointMetadata).reply(200, diffMetadata);
});
it('should fetch diff meta information', done => {
testAction(
fetchDiffFilesMeta,
{},
{ endpointMetadata, useSingleDiffStyle: false },
[ [
{ type: types.SET_LOADING, payload: true }, { type: types.SET_LOADING, payload: true },
{ type: types.SET_LOADING, payload: false }, { type: types.SET_LOADING, payload: false },
...@@ -437,7 +286,6 @@ describe('DiffsStoreActions', () => { ...@@ -437,7 +286,6 @@ describe('DiffsStoreActions', () => {
); );
}); });
}); });
});
describe('fetchCoverageFiles', () => { describe('fetchCoverageFiles', () => {
let mock; let mock;
...@@ -589,7 +437,7 @@ describe('DiffsStoreActions', () => { ...@@ -589,7 +437,7 @@ describe('DiffsStoreActions', () => {
testAction( testAction(
assignDiscussionsToDiff, assignDiscussionsToDiff,
[], [],
{ diffFiles: [], useSingleDiffStyle: true }, { diffFiles: [] },
[], [],
[{ type: 'setCurrentDiffFileIdFromNote', payload: '123' }], [{ type: 'setCurrentDiffFileIdFromNote', payload: '123' }],
done, done,
......
...@@ -11,13 +11,11 @@ describe('DiffsStoreMutations', () => { ...@@ -11,13 +11,11 @@ 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, useSingleDiffStyle }); mutations[types.SET_BASE_CONFIG](state, { endpoint, projectPath });
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);
}); });
}); });
......
...@@ -57,16 +57,6 @@ RSpec.shared_examples 'diff file entity' do ...@@ -57,16 +57,6 @@ RSpec.shared_examples 'diff file entity' do
expect(subject).to include(:highlighted_diff_lines) expect(subject).to include(:highlighted_diff_lines)
end end
end end
context 'when the `single_mr_diff_view` feature is disabled' do
before do
stub_feature_flags(single_mr_diff_view: false)
end
it 'contains both kinds of diffs' do
expect(subject).to include(:highlighted_diff_lines, :parallel_diff_lines)
end
end
end end
end end
......
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