Commit ef89ff91 authored by Samantha Ming's avatar Samantha Ming

Address reviewer & attempt to solve confusing code

parent d94ffb92
...@@ -754,16 +754,17 @@ UsersSelect.prototype.users = function(query, options, callback) { ...@@ -754,16 +754,17 @@ UsersSelect.prototype.users = function(query, options, callback) {
...getAjaxUsersSelectParams(options, AJAX_USERS_SELECT_PARAMS_MAP), ...getAjaxUsersSelectParams(options, AJAX_USERS_SELECT_PARAMS_MAP),
}; };
if ( const isMergeRequest = options.issuableType === 'merge_request';
options.issuableType === 'merge_request' || const isEditMergeRequest = !options.issuableType && (options.iid && options.targetBranch);
(!options.issuableType && (options.iid || options.targetBranch)) const isNewMergeRequest = !options.issuableType && (!options.iid && options.targetBranch);
) {
if (isMergeRequest || isEditMergeRequest || isNewMergeRequest) {
params.merge_request_iid = options.iid || null; params.merge_request_iid = options.iid || null;
params.approval_rules = true; params.approval_rules = true;
}
if (!options.iid) { if (isNewMergeRequest) {
params.target_branch = options.targetBranch || null; params.target_branch = options.targetBranch || null;
}
} }
return axios.get(url, { params }).then(({ data }) => { return axios.get(url, { params }).then(({ data }) => {
...@@ -804,7 +805,7 @@ UsersSelect.prototype.renderRow = function( ...@@ -804,7 +805,7 @@ UsersSelect.prototype.renderRow = function(
</strong> </strong>
${ ${
username username
? `<span class="dropdown-menu-user-username text gl-text-gray-400">${username}</span>` ? `<span class="dropdown-menu-user-username gl-text-gray-400">${username}</span>`
: '' : ''
} }
${this.renderApprovalRules(elsClassName, user.applicable_approval_rules)} ${this.renderApprovalRules(elsClassName, user.applicable_approval_rules)}
...@@ -834,6 +835,7 @@ UsersSelect.prototype.renderApprovalRules = function(elsClassName, approvalRules ...@@ -834,6 +835,7 @@ UsersSelect.prototype.renderApprovalRules = function(elsClassName, approvalRules
if (!gon.features?.reviewerApprovalRules || !elsClassName?.includes('reviewer')) { if (!gon.features?.reviewerApprovalRules || !elsClassName?.includes('reviewer')) {
return ''; return '';
} }
const count = approvalRules.length; const count = approvalRules.length;
const [rule] = approvalRules; const [rule] = approvalRules;
const countText = sprintf(__('(+%{count}&nbsp;rules)'), { count }); const countText = sprintf(__('(+%{count}&nbsp;rules)'), { count });
......
---
title: Display approval rules in reviewer dropdown
merge_request: 46738
author:
type: added
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