Commit f291d707 authored by Samantha Ming's avatar Samantha Ming

Display Code Owner as approval rules in reviewer

Part 2 of issue: https://gitlab.com/gitlab-org/gitlab/-/issues/233736
parent 22a0aa4f
......@@ -832,21 +832,21 @@ UsersSelect.prototype.renderRowAvatar = function(issuableType, user, img) {
};
UsersSelect.prototype.renderApprovalRules = function(elsClassName, approvalRules = []) {
if (!gon.features?.reviewerApprovalRules || !elsClassName?.includes('reviewer')) {
const count = approvalRules.length;
if (!gon.features?.reviewerApprovalRules || !elsClassName?.includes('reviewer') || !count) {
return '';
}
const count = approvalRules.length;
const [rule] = approvalRules;
const countText = sprintf(__('(+%{count} rules)'), { count });
const renderApprovalRulesCount = count > 1 ? `<span class="ml-1">${countText}</span>` : '';
const ruleName = rule.rule_type === 'code_owner' ? __('Code Owner') : rule.name;
return count
? `<div class="gl-display-flex gl-font-sm">
<span class="gl-text-truncate" title="${rule.name}">${rule.name}</span>
${renderApprovalRulesCount}
</div>`
: '';
return `<div class="gl-display-flex gl-font-sm">
<span class="gl-text-truncate" title="${ruleName}">${ruleName}</span>
${renderApprovalRulesCount}
</div>`;
};
export default UsersSelect;
......@@ -51,4 +51,20 @@ RSpec.describe 'Merge request > User edits MR with multiple reviewers' do
end
end
end
context 'code owner approval rules', :js do
let(:code_owner_pattern) { '*' }
let!(:code_owner_rule) {create(:code_owner_rule, name: code_owner_pattern, merge_request: merge_request, users: [user])}
let!(:mr_rule) { create(:approval_merge_request_rule, merge_request: merge_request )}
it 'displays "Code Owner" text in reviewer dropdown' do
find('.js-reviewer-search').click
wait_for_requests
page.within '.dropdown-menu-reviewer' do
expect(page).to have_content('Code Owner')
expect(page).not_to have_content(code_owner_pattern)
end
end
end
end
......@@ -6910,6 +6910,9 @@ msgstr ""
msgid "Code Coverage|Couldn't fetch the code coverage data"
msgstr ""
msgid "Code Owner"
msgstr ""
msgid "Code Owners"
msgstr ""
......
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