Commit 0ef3cf20 authored by Imre Farkas's avatar Imre Farkas

Merge branch 'id-remove-merge-ref-head-comments-ff' into 'master'

Remove merge_ref_head_comments FF

See merge request gitlab-org/gitlab!44433
parents f085ce62 64a05074
import { getParameterByName, parseBoolean } from '~/lib/utils/common_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { import {
MATCH_LINE_TYPE, MATCH_LINE_TYPE,
...@@ -23,21 +22,8 @@ export const isMatchLine = type => type === MATCH_LINE_TYPE; ...@@ -23,21 +22,8 @@ export const isMatchLine = type => type === MATCH_LINE_TYPE;
export const isMetaLine = type => export const isMetaLine = type =>
[OLD_NO_NEW_LINE_TYPE, NEW_NO_NEW_LINE_TYPE, EMPTY_CELL_TYPE].includes(type); [OLD_NO_NEW_LINE_TYPE, NEW_NO_NEW_LINE_TYPE, EMPTY_CELL_TYPE].includes(type);
export const shouldRenderCommentButton = ( export const shouldRenderCommentButton = (isLoggedIn, isCommentButtonRendered) => {
isLoggedIn, return isCommentButtonRendered && isLoggedIn;
isCommentButtonRendered,
featureMergeRefHeadComments = false,
) => {
if (!isCommentButtonRendered) {
return false;
}
if (isLoggedIn) {
const isDiffHead = parseBoolean(getParameterByName('diff_head'));
return !isDiffHead || featureMergeRefHeadComments;
}
return false;
}; };
export const hasDiscussions = line => line?.discussions?.length > 0; export const hasDiscussions = line => line?.discussions?.length > 0;
......
...@@ -81,11 +81,7 @@ export default { ...@@ -81,11 +81,7 @@ export default {
return utils.addCommentTooltip(this.line); return utils.addCommentTooltip(this.line);
}, },
shouldRenderCommentButton() { shouldRenderCommentButton() {
return utils.shouldRenderCommentButton( return utils.shouldRenderCommentButton(this.isLoggedIn, true);
this.isLoggedIn,
true,
gon.features?.mergeRefHeadComments,
);
}, },
shouldShowCommentButton() { shouldShowCommentButton() {
return utils.shouldShowCommentButton( return utils.shouldShowCommentButton(
......
...@@ -102,11 +102,7 @@ export default { ...@@ -102,11 +102,7 @@ export default {
return utils.addCommentTooltip(this.line.right); return utils.addCommentTooltip(this.line.right);
}, },
shouldRenderCommentButton() { shouldRenderCommentButton() {
return utils.shouldRenderCommentButton( return utils.shouldRenderCommentButton(this.isLoggedIn, this.isCommentButtonRendered);
this.isLoggedIn,
this.isCommentButtonRendered,
gon.features?.mergeRefHeadComments,
);
}, },
shouldShowCommentButtonLeft() { shouldShowCommentButtonLeft() {
return utils.shouldShowCommentButton( return utils.shouldShowCommentButton(
......
...@@ -173,7 +173,6 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic ...@@ -173,7 +173,6 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
end end
def update_diff_discussion_positions! def update_diff_discussion_positions!
return unless Feature.enabled?(:merge_ref_head_comments, @merge_request.target_project, default_enabled: true)
return unless Feature.enabled?(:merge_red_head_comments_position_on_demand, @merge_request.target_project, default_enabled: true) return unless Feature.enabled?(:merge_red_head_comments_position_on_demand, @merge_request.target_project, default_enabled: true)
return if @merge_request.has_any_diff_note_positions? return if @merge_request.has_any_diff_note_positions?
......
...@@ -29,7 +29,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -29,7 +29,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
before_action only: [:show] do before_action only: [:show] do
push_frontend_experiment(:suggest_pipeline) push_frontend_experiment(:suggest_pipeline)
push_frontend_feature_flag(:widget_visibility_polling, @project, default_enabled: true) push_frontend_feature_flag(:widget_visibility_polling, @project, default_enabled: true)
push_frontend_feature_flag(:merge_ref_head_comments, @project, default_enabled: true)
push_frontend_feature_flag(:mr_commit_neighbor_nav, @project, default_enabled: true) push_frontend_feature_flag(:mr_commit_neighbor_nav, @project, default_enabled: true)
push_frontend_feature_flag(:multiline_comments, @project, default_enabled: true) push_frontend_feature_flag(:multiline_comments, @project, default_enabled: true)
push_frontend_feature_flag(:file_identifier_hash) push_frontend_feature_flag(:file_identifier_hash)
......
...@@ -69,9 +69,6 @@ class DiscussionEntity < Grape::Entity ...@@ -69,9 +69,6 @@ class DiscussionEntity < Grape::Entity
end end
def display_merge_ref_discussions?(discussion) def display_merge_ref_discussions?(discussion)
return unless discussion.diff_discussion? discussion.diff_discussion? && !discussion.legacy_diff_discussion?
return if discussion.legacy_diff_discussion?
Feature.enabled?(:merge_ref_head_comments, discussion.project, default_enabled: true)
end end
end end
...@@ -125,8 +125,6 @@ module MergeRequests ...@@ -125,8 +125,6 @@ module MergeRequests
end end
def update_diff_discussion_positions! def update_diff_discussion_positions!
return if Feature.disabled?(:merge_ref_head_comments, merge_request.target_project, default_enabled: true)
Discussions::CaptureDiffNotePositionsService.new(merge_request).execute Discussions::CaptureDiffNotePositionsService.new(merge_request).execute
end end
......
...@@ -70,7 +70,7 @@ module Notes ...@@ -70,7 +70,7 @@ module Notes
Gitlab::Tracking.event('Notes::CreateService', 'execute', tracking_data_for(note)) Gitlab::Tracking.event('Notes::CreateService', 'execute', tracking_data_for(note))
end end
if Feature.enabled?(:merge_ref_head_comments, project, default_enabled: true) && note.for_merge_request? && note.diff_note? && note.start_of_discussion? if note.for_merge_request? && note.diff_note? && note.start_of_discussion?
Discussions::CaptureDiffNotePositionService.new(note.noteable, note.diff_file&.paths).execute(note.discussion) Discussions::CaptureDiffNotePositionService.new(note.noteable, note.diff_file&.paths).execute(note.discussion)
end end
end end
......
---
name: merge_ref_head_comments
introduced_by_url:
rollout_issue_url:
group:
type: development
default_enabled: true
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { TEST_HOST } from 'helpers/test_constants';
import { createStore } from '~/mr_notes/stores'; import { createStore } from '~/mr_notes/stores';
import InlineDiffTableRow from '~/diffs/components/inline_diff_table_row.vue'; import InlineDiffTableRow from '~/diffs/components/inline_diff_table_row.vue';
import DiffGutterAvatars from '~/diffs/components/diff_gutter_avatars.vue'; import DiffGutterAvatars from '~/diffs/components/diff_gutter_avatars.vue';
...@@ -28,13 +27,6 @@ describe('InlineDiffTableRow', () => { ...@@ -28,13 +27,6 @@ describe('InlineDiffTableRow', () => {
}); });
}; };
const setWindowLocation = value => {
Object.defineProperty(window, 'location', {
writable: true,
value,
});
};
beforeEach(() => { beforeEach(() => {
store = createStore(); store = createStore();
store.state.notes.userData = TEST_USER; store.state.notes.userData = TEST_USER;
...@@ -122,22 +114,15 @@ describe('InlineDiffTableRow', () => { ...@@ -122,22 +114,15 @@ describe('InlineDiffTableRow', () => {
const findNoteButton = () => wrapper.find({ ref: 'addDiffNoteButton' }); const findNoteButton = () => wrapper.find({ ref: 'addDiffNoteButton' });
it.each` it.each`
userData | query | mergeRefHeadComments | expectation userData | expectation
${TEST_USER} | ${'diff_head=false'} | ${false} | ${true} ${TEST_USER} | ${true}
${TEST_USER} | ${'diff_head=true'} | ${true} | ${true} ${null} | ${false}
${TEST_USER} | ${'diff_head=true'} | ${false} | ${false} `('exists is $expectation - with userData ($userData)', ({ userData, expectation }) => {
${null} | ${''} | ${true} | ${false}
`(
'exists is $expectation - with userData ($userData) query ($query)',
({ userData, query, mergeRefHeadComments, expectation }) => {
store.state.notes.userData = userData; store.state.notes.userData = userData;
gon.features = { mergeRefHeadComments };
setWindowLocation({ href: `${TEST_HOST}?${query}` });
createComponent({}, store); createComponent({}, store);
expect(findNoteButton().exists()).toBe(expectation); expect(findNoteButton().exists()).toBe(expectation);
}, });
);
it.each` it.each`
isHover | line | expectation isHover | line | expectation
......
import Vue from 'vue'; import Vue from 'vue';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper';
import { TEST_HOST } from 'helpers/test_constants';
import { createStore } from '~/mr_notes/stores'; import { createStore } from '~/mr_notes/stores';
import ParallelDiffTableRow from '~/diffs/components/parallel_diff_table_row.vue'; import ParallelDiffTableRow from '~/diffs/components/parallel_diff_table_row.vue';
import diffFileMockData from '../mock_data/diff_file'; import diffFileMockData from '../mock_data/diff_file';
...@@ -186,13 +185,6 @@ describe('ParallelDiffTableRow', () => { ...@@ -186,13 +185,6 @@ describe('ParallelDiffTableRow', () => {
}); });
}; };
const setWindowLocation = value => {
Object.defineProperty(window, 'location', {
writable: true,
value,
});
};
beforeEach(() => { beforeEach(() => {
// eslint-disable-next-line prefer-destructuring // eslint-disable-next-line prefer-destructuring
thisLine = diffFileMockData.parallel_diff_lines[2]; thisLine = diffFileMockData.parallel_diff_lines[2];
...@@ -228,19 +220,15 @@ describe('ParallelDiffTableRow', () => { ...@@ -228,19 +220,15 @@ describe('ParallelDiffTableRow', () => {
const findNoteButton = () => wrapper.find({ ref: 'addDiffNoteButtonLeft' }); const findNoteButton = () => wrapper.find({ ref: 'addDiffNoteButtonLeft' });
it.each` it.each`
hover | line | userData | query | mergeRefHeadComments | expectation hover | line | userData | expectation
${true} | ${{}} | ${TEST_USER} | ${'diff_head=false'} | ${false} | ${true} ${true} | ${{}} | ${TEST_USER} | ${true}
${true} | ${{ line: { left: null } }} | ${TEST_USER} | ${'diff_head=false'} | ${false} | ${false} ${true} | ${{ line: { left: null } }} | ${TEST_USER} | ${false}
${true} | ${{}} | ${TEST_USER} | ${'diff_head=true'} | ${true} | ${true} ${true} | ${{}} | ${null} | ${false}
${true} | ${{}} | ${TEST_USER} | ${'diff_head=true'} | ${false} | ${false} ${false} | ${{}} | ${TEST_USER} | ${false}
${true} | ${{}} | ${null} | ${''} | ${true} | ${false}
${false} | ${{}} | ${TEST_USER} | ${'diff_head=false'} | ${false} | ${false}
`( `(
'exists is $expectation - with userData ($userData) query ($query)', 'exists is $expectation - with userData ($userData)',
async ({ hover, line, userData, query, mergeRefHeadComments, expectation }) => { async ({ hover, line, userData, expectation }) => {
store.state.notes.userData = userData; store.state.notes.userData = userData;
gon.features = { mergeRefHeadComments };
setWindowLocation({ href: `${TEST_HOST}?${query}` });
createComponent(line, store); createComponent(line, store);
if (hover) await wrapper.find('.line_holder').trigger('mouseover'); if (hover) await wrapper.find('.line_holder').trigger('mouseover');
......
...@@ -79,13 +79,5 @@ RSpec.describe DiscussionEntity do ...@@ -79,13 +79,5 @@ RSpec.describe DiscussionEntity do
:active :active
) )
end end
context 'diff_head_compare feature is disabled' do
it 'does not expose positions and line_codes attributes' do
stub_feature_flags(merge_ref_head_comments: false)
expect(subject.keys).not_to include(:positions, :line_codes)
end
end
end end
end end
...@@ -41,16 +41,6 @@ RSpec.describe MergeRequests::MergeabilityCheckService, :clean_gitlab_redis_shar ...@@ -41,16 +41,6 @@ RSpec.describe MergeRequests::MergeabilityCheckService, :clean_gitlab_redis_shar
subject subject
end end
context 'when merge_ref_head_comments is disabled' do
it 'does not update diff discussion positions' do
stub_feature_flags(merge_ref_head_comments: false)
expect(Discussions::CaptureDiffNotePositionsService).not_to receive(:new)
subject
end
end
it 'updates the merge ref' do it 'updates the merge ref' do
expect { subject }.to change(merge_request, :merge_ref_head).from(nil) expect { subject }.to change(merge_request, :merge_ref_head).from(nil)
end end
......
...@@ -163,14 +163,6 @@ RSpec.describe Notes::CreateService do ...@@ -163,14 +163,6 @@ RSpec.describe Notes::CreateService do
expect(note.note_diff_file).to be_present expect(note.note_diff_file).to be_present
expect(note.diff_note_positions).to be_present expect(note.diff_note_positions).to be_present
end end
it 'does not create diff positions merge_ref_head_comments is disabled' do
stub_feature_flags(merge_ref_head_comments: false)
expect(Discussions::CaptureDiffNotePositionService).not_to receive(:new)
described_class.new(project_with_repo, user, new_opts).execute
end
end end
context 'when DiffNote is a reply' do context 'when DiffNote is a reply' do
......
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