diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb index 797213e2600..e46b269ea35 100644 --- a/app/serializers/merge_request_widget_entity.rb +++ b/app/serializers/merge_request_widget_entity.rb @@ -151,6 +151,10 @@ class MergeRequestWidgetEntity < Grape::Entity can?(current_user, :create_pipeline, merge_request.source_project) end + def use_merge_base_with_merged_results? + object.actual_head_pipeline&.merge_request_event_type == :merged_result + end + def head_pipeline_downloadable_path_for_report_type(file_type) object.head_pipeline&.present(current_user: current_user) &.downloadable_path_for_report_type(file_type) @@ -161,11 +165,6 @@ class MergeRequestWidgetEntity < Grape::Entity &.downloadable_path_for_report_type(file_type) end - def use_merge_base_with_merged_results? - Feature.enabled?(:merge_base_pipelines, object.target_project) && - object.actual_head_pipeline&.merge_request_event_type == :merged_result - end - def merge_base_pipeline_downloadable_path_for_report_type(file_type) object.merge_base_pipeline&.present(current_user: current_user) &.downloadable_path_for_report_type(file_type) diff --git a/app/views/projects/merge_requests/_mr_title.html.haml b/app/views/projects/merge_requests/_mr_title.html.haml index b56e2c3f985..7fe91fb6560 100644 --- a/app/views/projects/merge_requests/_mr_title.html.haml +++ b/app/views/projects/merge_requests/_mr_title.html.haml @@ -41,7 +41,7 @@ - if can_reopen_merge_request %li{ class: merge_request_button_visibility(@merge_request, false) } = link_to 'Reopen', merge_request_path(@merge_request, merge_request: { state_event: :reopen }), method: :put, class: 'reopen-mr-link', title: 'Reopen merge request' - - unless current_user == @merge_request.author + - unless @merge_request.merged? || current_user == @merge_request.author %li= link_to 'Report abuse', new_abuse_report_path(user_id: @merge_request.author.id, ref_url: merge_request_url(@merge_request)) - if can_update_merge_request diff --git a/app/views/shared/issuable/_close_reopen_button.html.haml b/app/views/shared/issuable/_close_reopen_button.html.haml index 8365bc6f863..3453db9f209 100644 --- a/app/views/shared/issuable/_close_reopen_button.html.haml +++ b/app/views/shared/issuable/_close_reopen_button.html.haml @@ -21,5 +21,6 @@ - else = render 'shared/issuable/close_reopen_report_toggle', issuable: issuable, warn_before_close: add_blocked_class - else - = link_to _('Report abuse'), new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)), - class: 'd-none d-md-block btn btn-grouped btn-close-color', title: _('Report abuse') + - unless issuable.is_a?(MergeRequest) && issuable.merged? + = link_to _('Report abuse'), new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)), + class: 'd-none d-md-block btn btn-grouped btn-close-color', title: _('Report abuse') diff --git a/changelogs/unreleased/271589-report-abuse-on-merged-mr.yml b/changelogs/unreleased/271589-report-abuse-on-merged-mr.yml new file mode 100644 index 00000000000..aef591da54a --- /dev/null +++ b/changelogs/unreleased/271589-report-abuse-on-merged-mr.yml @@ -0,0 +1,5 @@ +--- +title: Remove "Report abuse" button from a merged Merge Request +merge_request: 46031 +author: Takuya Noguchi +type: fixed diff --git a/changelogs/unreleased/remove-merge-base-pipelines-feature-flag.yml b/changelogs/unreleased/remove-merge-base-pipelines-feature-flag.yml new file mode 100644 index 00000000000..1f39fe81000 --- /dev/null +++ b/changelogs/unreleased/remove-merge-base-pipelines-feature-flag.yml @@ -0,0 +1,5 @@ +--- +title: Use updated base report for CodeQuality MergeRequest widdget +merge_request: 46384 +author: +type: changed diff --git a/config/feature_flags/development/merge_base_pipelines.yml b/config/feature_flags/development/merge_base_pipelines.yml deleted file mode 100644 index 4f57ca556f1..00000000000 --- a/config/feature_flags/development/merge_base_pipelines.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -name: merge_base_pipelines -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/44648 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/263724 -type: development -group: group::testing -default_enabled: false diff --git a/doc/.vale/gitlab/AlertBoxCaution.yml b/doc/.vale/gitlab/AlertBoxCaution.yml index 9e3bbeaa4e0..49d4dc62ab5 100644 --- a/doc/.vale/gitlab/AlertBoxCaution.yml +++ b/doc/.vale/gitlab/AlertBoxCaution.yml @@ -1,7 +1,7 @@ --- # Error: gitlab.AlertBoxCaution # -# Makes sure DANGER: alert boxes follow standard formatting. +# Makes sure CAUTION: alert boxes follow standard formatting. # # For a list of all options, see https://errata-ai.gitbook.io/vale/getting-started/styles extends: substitution diff --git a/doc/.vale/gitlab/CurlStringsQuoted.yml b/doc/.vale/gitlab/CurlStringsQuoted.yml index af7f85e2a4d..a09c3fbfb51 100644 --- a/doc/.vale/gitlab/CurlStringsQuoted.yml +++ b/doc/.vale/gitlab/CurlStringsQuoted.yml @@ -1,7 +1,7 @@ --- # Warning: gitlab.CurlStringsQuoted # -# Ensures all codeblocks using curl quote any URL strings. +# Ensures all code blocks using curl quote any URL strings. # # For a list of all options, see https://errata-ai.gitbook.io/vale/getting-started/styles extends: existence diff --git a/doc/.vale/gitlab/VersionText.yml b/doc/.vale/gitlab/VersionText.yml index e0180a3965c..e59b936ae3f 100644 --- a/doc/.vale/gitlab/VersionText.yml +++ b/doc/.vale/gitlab/VersionText.yml @@ -1,8 +1,17 @@ --- # Error: gitlab.VersionText # -# Checks for use of some of the top misused terms at GitLab. -# For substitutions only flagged as warnings, see SubstitutionWarning.yml +# Checks that version text is formatted correctly. +# +# Specifically looks for either of the following that is immediately followed on the next line +# by content, which will break rendering: +# +# - `> Introduced` (version text without a link) +# - `> [Introduced` (version text with a link) +# +# Because it excludes `-`, it doesn't look for multi-line version text, for which content +# immediately on the next line is ok. However, this will often highlight where multi-line version +# text is attempted without `-` characters. # # For a list of all options, see https://errata-ai.gitbook.io/vale/getting-started/styles extends: existence diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 22ae8ffbc6c..2bb773aa13e 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -4853,9 +4853,6 @@ msgstr "" msgid "Cannot enable shared runners because parent group does not allow it" msgstr "" -msgid "Cannot find user key." -msgstr "" - msgid "Cannot have multiple Jira imports running at the same time" msgstr "" diff --git a/spec/features/issuables/close_reopen_report_toggle_spec.rb b/spec/features/issuables/close_reopen_report_toggle_spec.rb index f0c994420ac..867d2ff7aae 100644 --- a/spec/features/issuables/close_reopen_report_toggle_spec.rb +++ b/spec/features/issuables/close_reopen_report_toggle_spec.rb @@ -105,6 +105,7 @@ RSpec.describe 'Issuables Close/Reopen/Report toggle' do end context 'on a merge request' do + let(:container) { find('.detail-page-header-actions') } let(:project) { create(:project, :repository) } let(:issuable) { create(:merge_request, source_project: project) } @@ -120,24 +121,47 @@ RSpec.describe 'Issuables Close/Reopen/Report toggle' do it_behaves_like 'an issuable close/reopen/report toggle' + context 'when the merge request is closed' do + let(:issuable) { create(:merge_request, :closed, source_project: project) } + + it 'shows both the `Edit` and `Reopen` button' do + expect(container).to have_link('Edit') + expect(container).not_to have_button('Report abuse') + expect(container).not_to have_button('Close merge request') + expect(container).to have_link('Reopen merge request') + end + + context 'when the merge request author is the current user' do + let(:issuable) { create(:merge_request, :closed, source_project: project, author: user) } + + it 'shows both the `Edit` and `Reopen` button' do + expect(container).to have_link('Edit') + expect(container).not_to have_link('Report abuse') + expect(container).not_to have_selector('button.dropdown-toggle') + expect(container).not_to have_button('Close merge request') + expect(container).to have_link('Reopen merge request') + end + end + end + context 'when the merge request is merged' do let(:issuable) { create(:merge_request, :merged, source_project: project) } - it 'shows only the `Report abuse` and `Edit` button' do - expect(page).to have_link('Report abuse') - expect(page).to have_link(exact_text: 'Edit') - expect(page).not_to have_button('Close merge request') - expect(page).not_to have_button('Reopen merge request') + it 'shows only the `Edit` button' do + expect(container).to have_link(exact_text: 'Edit') + expect(container).not_to have_link('Report abuse') + expect(container).not_to have_button('Close merge request') + expect(container).not_to have_button('Reopen merge request') end context 'when the merge request author is the current user' do let(:issuable) { create(:merge_request, :merged, source_project: project, author: user) } it 'shows only the `Edit` button' do - expect(page).to have_link('Report abuse') - expect(page).to have_link(exact_text: 'Edit') - expect(page).not_to have_button('Close merge request') - expect(page).not_to have_button('Reopen merge request') + expect(container).to have_link(exact_text: 'Edit') + expect(container).not_to have_link('Report abuse') + expect(container).not_to have_button('Close merge request') + expect(container).not_to have_button('Reopen merge request') end end end @@ -154,10 +178,10 @@ RSpec.describe 'Issuables Close/Reopen/Report toggle' do end it 'only shows a `Report abuse` button' do - expect(page).to have_link('Report abuse') - expect(page).not_to have_button('Close merge request') - expect(page).not_to have_button('Reopen merge request') - expect(page).not_to have_link(exact_text: 'Edit') + expect(container).to have_link('Report abuse') + expect(container).not_to have_button('Close merge request') + expect(container).not_to have_button('Reopen merge request') + expect(container).not_to have_link(exact_text: 'Edit') end end end diff --git a/spec/serializers/merge_request_widget_entity_spec.rb b/spec/serializers/merge_request_widget_entity_spec.rb index 7179ce08896..3f7d5542ae8 100644 --- a/spec/serializers/merge_request_widget_entity_spec.rb +++ b/spec/serializers/merge_request_widget_entity_spec.rb @@ -106,29 +106,16 @@ RSpec.describe MergeRequestWidgetEntity do let(:merge_base_job_id) { merge_base_pipeline.builds.first.id } it 'has head_path and base_path entries' do - expect(subject[:codeclimate][:head_path]).to be_present - expect(subject[:codeclimate][:base_path]).to be_present + expect(subject[:codeclimate][:head_path]).to include("/jobs/#{generic_job_id}/artifacts/download?file_type=codequality") + expect(subject[:codeclimate][:base_path]).to include("/jobs/#{generic_job_id}/artifacts/download?file_type=codequality") end context 'on pipelines for merged results' do let(:pipeline) { create(:ci_pipeline, :merged_result_pipeline, :with_codequality_report, project: project) } - context 'with merge_base_pipelines enabled' do - it 'returns URLs from the head_pipeline and merge_base_pipeline' do - expect(subject[:codeclimate][:head_path]).to include("/jobs/#{generic_job_id}/artifacts/download?file_type=codequality") - expect(subject[:codeclimate][:base_path]).to include("/jobs/#{merge_base_job_id}/artifacts/download?file_type=codequality") - end - end - - context 'with merge_base_pipelines disabled' do - before do - stub_feature_flags(merge_base_pipelines: false) - end - - it 'returns URLs from the head_pipeline and base_pipeline' do - expect(subject[:codeclimate][:head_path]).to include("/jobs/#{generic_job_id}/artifacts/download?file_type=codequality") - expect(subject[:codeclimate][:base_path]).to include("/jobs/#{generic_job_id}/artifacts/download?file_type=codequality") - end + it 'returns URLs from the head_pipeline and merge_base_pipeline' do + expect(subject[:codeclimate][:head_path]).to include("/jobs/#{generic_job_id}/artifacts/download?file_type=codequality") + expect(subject[:codeclimate][:base_path]).to include("/jobs/#{merge_base_job_id}/artifacts/download?file_type=codequality") end end end