Commit 0e5d669b authored by Phil Hughes's avatar Phil Hughes

Merge branch 'approval-rules-code-owners' into 'master'

Approval rules code owners

See merge request gitlab-org/gitlab!49437
parents 0a9309ff f291d707
......@@ -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
......@@ -6907,6 +6907,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