Commit cc26580c authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '246905-only-allow-multiple-reviewers-in-paid-tiers' into 'master'

Only allow multiple reviewers in paid tiers

See merge request gitlab-org/gitlab!44097
parents 9cbbfab1 4ad86a7b
...@@ -75,9 +75,9 @@ export default { ...@@ -75,9 +75,9 @@ export default {
:root-path="rootPath" :root-path="rootPath"
:issuable-type="issuableType" :issuable-type="issuableType"
> >
<div class="ml-2"> <div class="gl-ml-3 gl-line-height-normal">
<span class="author"> {{ user.name }} </span> <div class="author">{{ user.name }}</div>
<span class="username"> {{ username }} </span> <div class="username">{{ username }}</div>
</div> </div>
</reviewer-avatar-link> </reviewer-avatar-link>
<div v-else> <div v-else>
......
...@@ -56,7 +56,7 @@ module FormHelper ...@@ -56,7 +56,7 @@ module FormHelper
end end
def reviewers_dropdown_options(issuable_type) def reviewers_dropdown_options(issuable_type)
{ dropdown_data = {
toggle_class: 'js-reviewer-search js-multiselect js-save-user-data', toggle_class: 'js-reviewer-search js-multiselect js-save-user-data',
title: 'Request review from', title: 'Request review from',
filter: true, filter: true,
...@@ -69,13 +69,20 @@ module FormHelper ...@@ -69,13 +69,20 @@ module FormHelper
project_id: (@target_project || @project)&.id, project_id: (@target_project || @project)&.id,
field_name: "#{issuable_type}[reviewer_ids][]", field_name: "#{issuable_type}[reviewer_ids][]",
default_label: 'Unassigned', default_label: 'Unassigned',
'dropdown-header': 'Reviewer(s)', 'max-select': 1,
'dropdown-header': 'Reviewer',
multi_select: true, multi_select: true,
'input-meta': 'name', 'input-meta': 'name',
'always-show-selectbox': true, 'always-show-selectbox': true,
current_user_info: UserSerializer.new.represent(current_user) current_user_info: UserSerializer.new.represent(current_user)
} }
} }
if merge_request_supports_multiple_reviewers?
dropdown_data = multiple_reviewers_dropdown_options(dropdown_data)
end
dropdown_data
end end
# Overwritten # Overwritten
...@@ -88,6 +95,11 @@ module FormHelper ...@@ -88,6 +95,11 @@ module FormHelper
false false
end end
# Overwritten
def merge_request_supports_multiple_reviewers?
false
end
private private
def multiple_assignees_dropdown_options(options) def multiple_assignees_dropdown_options(options)
...@@ -99,6 +111,16 @@ module FormHelper ...@@ -99,6 +111,16 @@ module FormHelper
new_options new_options
end end
def multiple_reviewers_dropdown_options(options)
new_options = options.dup
new_options[:title] = _('Select reviewer(s)')
new_options[:data][:'dropdown-header'] = _('Reviewer(s)')
new_options[:data].delete(:'max-select')
new_options
end
end end
FormHelper.prepend_if_ee('::EE::FormHelper') FormHelper.prepend_if_ee('::EE::FormHelper')
...@@ -9,5 +9,9 @@ module EE ...@@ -9,5 +9,9 @@ module EE
def merge_request_supports_multiple_assignees? def merge_request_supports_multiple_assignees?
@merge_request&.allows_multiple_assignees? @merge_request&.allows_multiple_assignees?
end end
def merge_request_supports_multiple_reviewers?
@merge_request&.allows_multiple_reviewers?
end
end end
end end
---
title: Only allow multiple reviewers in paid tiers
merge_request: 44097
author:
type: changed
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Merge request > User creates MR with multiple reviewers' do
include_context 'merge request create context'
before do
stub_licensed_features(multiple_merge_request_reviewers: true)
end
it_behaves_like 'multiple reviewers merge request', 'creates', 'Submit merge request'
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Merge request > User edits MR with multiple reviewers' do
include_context 'merge request edit context'
before do
stub_licensed_features(multiple_merge_request_reviewers: true)
end
it_behaves_like 'multiple reviewers merge request', 'updates', 'Save changes'
end
...@@ -23218,6 +23218,9 @@ msgstr "" ...@@ -23218,6 +23218,9 @@ msgstr ""
msgid "Select required regulatory standard" msgid "Select required regulatory standard"
msgstr "" msgstr ""
msgid "Select reviewer(s)"
msgstr ""
msgid "Select shards to replicate" msgid "Select shards to replicate"
msgstr "" msgstr ""
......
# frozen_string_literal: true
RSpec.shared_examples 'multiple reviewers merge request' do |action, save_button_title|
it "#{action} a MR with multiple reviewers", :js do
find('.js-reviewer-search').click
page.within '.dropdown-menu-user' do
click_link user.name
click_link user2.name
end
# Extra click needed in order to toggle the dropdown
find('.js-reviewer-search').click
expect(all('input[name="merge_request[reviewer_ids][]"]', visible: false).map(&:value))
.to match_array([user.id.to_s, user2.id.to_s])
page.within '.js-reviewer-search' do
expect(page).to have_content "#{user2.name} + 1 more"
end
click_button save_button_title
page.within '.issuable-sidebar' do
page.within '.reviewer' do
expect(page).to have_content '2 Reviewers'
click_link 'Edit'
expect(page).to have_content user.name
expect(page).to have_content user2.name
end
end
page.within '.dropdown-menu-user' do
click_link user.name
end
page.within '.issuable-sidebar' do
page.within '.reviewer' do
# Closing dropdown to persist
click_link 'Edit'
expect(page).to have_content user2.name
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