Commit 16db4c96 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'reviewer-filter-frontend' into 'master'

Add support for Reviewer filter

See merge request gitlab-org/gitlab!47605
parents ccc73d1e 16b5b991
......@@ -91,7 +91,7 @@ export default (IssuableTokenKeys, disableTargetBranchFilter = false) => {
],
};
const tokenPosition = 2;
const tokenPosition = 3;
IssuableTokenKeys.tokenKeys.splice(tokenPosition, 0, ...[approvedBy.token]);
IssuableTokenKeys.tokenKeysWithAlternative.splice(tokenPosition, 0, ...[approvedBy.token]);
IssuableTokenKeys.conditions.push(...approvedBy.condition);
......
......@@ -71,6 +71,11 @@ export default class AvailableDropdownMappings {
gl: DropdownUser,
element: this.container.querySelector('#js-dropdown-assignee'),
},
reviewer: {
reference: null,
gl: DropdownUser,
element: this.container.querySelector('#js-dropdown-reviewer'),
},
'approved-by': {
reference: null,
gl: DropdownUser,
......
export const USER_TOKEN_TYPES = ['author', 'assignee', 'approved-by'];
export const USER_TOKEN_TYPES = ['author', 'assignee', 'approved-by', 'reviewer'];
export const DROPDOWN_TYPE = {
hint: 'hint',
......
......@@ -21,6 +21,15 @@ export const tokenKeys = [
icon: 'user',
tag: '@assignee',
},
{
formattedKey: __('Reviewer'),
key: 'reviewer',
type: 'string',
param: 'username',
symbol: '@',
icon: 'user',
tag: '@reviewer',
},
{
formattedKey: __('Milestone'),
key: 'milestone',
......@@ -85,6 +94,16 @@ export const conditions = flattenDeep(
tokenKey: 'assignee',
value: __('Any'),
},
{
url: 'reviewer_id=None',
tokenKey: 'reviewer',
value: __('None'),
},
{
url: 'reviewer_id=Any',
tokenKey: 'reviewer',
value: __('Any'),
},
{
url: 'author_username=support-bot',
tokenKey: 'author',
......
......@@ -249,6 +249,10 @@ export class SearchAutocomplete {
text: s__('SearchAutocomplete|Merge requests assigned to me'),
url: `${mrPath}/?assignee_username=${userName}`,
},
{
text: s__("SearchAutocomplete|Merge requests that I'm a reviewer"),
url: `${mrPath}/?reviewer_username=${userName}`,
},
{
text: s__("SearchAutocomplete|Merge requests I've created"),
url: `${mrPath}/?author_username=${userName}`,
......
......@@ -75,6 +75,22 @@
= render 'shared/issuable/user_dropdown_item',
user: User.new(username: '{{username}}', name: '{{name}}'),
avatar: { lazy: true, url: '{{avatar_url}}' }
#js-dropdown-reviewer.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'None' } }
%button.btn.btn-link{ type: 'button' }
= _('None')
%li.filter-dropdown-item{ data: { value: 'Any' } }
%button.btn.btn-link{ type: 'button' }
= _('Any')
%li.divider.droplab-item-ignore
- if current_user
= render 'shared/issuable/user_dropdown_item',
user: current_user
%ul.filter-dropdown{ data: { dynamic: true, dropdown: true } }
= render 'shared/issuable/user_dropdown_item',
user: User.new(username: '{{username}}', name: '{{name}}'),
avatar: { lazy: true, url: '{{avatar_url}}' }
= render_if_exists 'shared/issuable/approver_dropdown'
= render_if_exists 'shared/issuable/approved_by_dropdown'
#js-dropdown-milestone.filtered-search-input-dropdown-menu.dropdown-menu
......
......@@ -41,7 +41,7 @@ const approvers = {
export default (IssuableTokenKeys, disableTargetBranchFilter = false) => {
addExtraTokensForMergeRequests(IssuableTokenKeys, disableTargetBranchFilter);
const tokenPosition = 2;
const tokenPosition = 3;
IssuableTokenKeys.tokenKeys.splice(tokenPosition, 0, ...[approvers.token]);
IssuableTokenKeys.tokenKeysWithAlternative.splice(tokenPosition, 0, ...[approvers.token]);
......
......@@ -24067,6 +24067,9 @@ msgstr ""
msgid "SearchAutocomplete|Merge requests assigned to me"
msgstr ""
msgid "SearchAutocomplete|Merge requests that I'm a reviewer"
msgstr ""
msgid "SearchAutocomplete|in all GitLab"
msgstr ""
......
......@@ -172,4 +172,25 @@ RSpec.describe 'Dashboard Merge Requests' do
expect(find('.issues-filters')).to have_content('Created date')
end
end
context 'merge request review', :js do
let_it_be(:author_user) { create(:user) }
let!(:review_requested_merge_request) do
create(:merge_request,
reviewers: [current_user],
source_branch: 'review',
source_project: project,
author: author_user)
end
before do
visit merge_requests_dashboard_path(reviewer_username: current_user.username)
end
it 'displays review requested merge requests' do
expect(page).to have_content(review_requested_merge_request.title)
expect_tokens([reviewer_token(current_user.name)])
end
end
end
......@@ -113,6 +113,10 @@ module FilteredSearchHelpers
create_token('Assignee', assignee_name)
end
def reviewer_token(reviewer_name = nil)
create_token('Reviewer', reviewer_name)
end
def milestone_token(milestone_name = nil, has_symbol = true, operator = '=')
symbol = has_symbol ? '%' : nil
create_token('Milestone', milestone_name, symbol, operator)
......
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