Commit 16b5b991 authored by David Kim's avatar David Kim Committed by Kushal Pandya

Added feature spec for reviewers

Added spec to check review requested merge requests
get rendered and also the visual token gets rendered
parent eb94430f
...@@ -91,7 +91,7 @@ export default (IssuableTokenKeys, disableTargetBranchFilter = false) => { ...@@ -91,7 +91,7 @@ export default (IssuableTokenKeys, disableTargetBranchFilter = false) => {
], ],
}; };
const tokenPosition = 2; const tokenPosition = 3;
IssuableTokenKeys.tokenKeys.splice(tokenPosition, 0, ...[approvedBy.token]); IssuableTokenKeys.tokenKeys.splice(tokenPosition, 0, ...[approvedBy.token]);
IssuableTokenKeys.tokenKeysWithAlternative.splice(tokenPosition, 0, ...[approvedBy.token]); IssuableTokenKeys.tokenKeysWithAlternative.splice(tokenPosition, 0, ...[approvedBy.token]);
IssuableTokenKeys.conditions.push(...approvedBy.condition); IssuableTokenKeys.conditions.push(...approvedBy.condition);
......
...@@ -71,6 +71,11 @@ export default class AvailableDropdownMappings { ...@@ -71,6 +71,11 @@ export default class AvailableDropdownMappings {
gl: DropdownUser, gl: DropdownUser,
element: this.container.querySelector('#js-dropdown-assignee'), element: this.container.querySelector('#js-dropdown-assignee'),
}, },
reviewer: {
reference: null,
gl: DropdownUser,
element: this.container.querySelector('#js-dropdown-reviewer'),
},
'approved-by': { 'approved-by': {
reference: null, reference: null,
gl: DropdownUser, 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 = { export const DROPDOWN_TYPE = {
hint: 'hint', hint: 'hint',
......
...@@ -21,6 +21,15 @@ export const tokenKeys = [ ...@@ -21,6 +21,15 @@ export const tokenKeys = [
icon: 'user', icon: 'user',
tag: '@assignee', tag: '@assignee',
}, },
{
formattedKey: __('Reviewer'),
key: 'reviewer',
type: 'string',
param: 'username',
symbol: '@',
icon: 'user',
tag: '@reviewer',
},
{ {
formattedKey: __('Milestone'), formattedKey: __('Milestone'),
key: 'milestone', key: 'milestone',
...@@ -85,6 +94,16 @@ export const conditions = flattenDeep( ...@@ -85,6 +94,16 @@ export const conditions = flattenDeep(
tokenKey: 'assignee', tokenKey: 'assignee',
value: __('Any'), value: __('Any'),
}, },
{
url: 'reviewer_id=None',
tokenKey: 'reviewer',
value: __('None'),
},
{
url: 'reviewer_id=Any',
tokenKey: 'reviewer',
value: __('Any'),
},
{ {
url: 'author_username=support-bot', url: 'author_username=support-bot',
tokenKey: 'author', tokenKey: 'author',
......
...@@ -249,6 +249,10 @@ export class SearchAutocomplete { ...@@ -249,6 +249,10 @@ export class SearchAutocomplete {
text: s__('SearchAutocomplete|Merge requests assigned to me'), text: s__('SearchAutocomplete|Merge requests assigned to me'),
url: `${mrPath}/?assignee_username=${userName}`, 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"), text: s__("SearchAutocomplete|Merge requests I've created"),
url: `${mrPath}/?author_username=${userName}`, url: `${mrPath}/?author_username=${userName}`,
......
...@@ -75,6 +75,22 @@ ...@@ -75,6 +75,22 @@
= render 'shared/issuable/user_dropdown_item', = render 'shared/issuable/user_dropdown_item',
user: User.new(username: '{{username}}', name: '{{name}}'), user: User.new(username: '{{username}}', name: '{{name}}'),
avatar: { lazy: true, url: '{{avatar_url}}' } 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/approver_dropdown'
= render_if_exists 'shared/issuable/approved_by_dropdown' = render_if_exists 'shared/issuable/approved_by_dropdown'
#js-dropdown-milestone.filtered-search-input-dropdown-menu.dropdown-menu #js-dropdown-milestone.filtered-search-input-dropdown-menu.dropdown-menu
......
...@@ -41,7 +41,7 @@ const approvers = { ...@@ -41,7 +41,7 @@ const approvers = {
export default (IssuableTokenKeys, disableTargetBranchFilter = false) => { export default (IssuableTokenKeys, disableTargetBranchFilter = false) => {
addExtraTokensForMergeRequests(IssuableTokenKeys, disableTargetBranchFilter); addExtraTokensForMergeRequests(IssuableTokenKeys, disableTargetBranchFilter);
const tokenPosition = 2; const tokenPosition = 3;
IssuableTokenKeys.tokenKeys.splice(tokenPosition, 0, ...[approvers.token]); IssuableTokenKeys.tokenKeys.splice(tokenPosition, 0, ...[approvers.token]);
IssuableTokenKeys.tokenKeysWithAlternative.splice(tokenPosition, 0, ...[approvers.token]); IssuableTokenKeys.tokenKeysWithAlternative.splice(tokenPosition, 0, ...[approvers.token]);
......
...@@ -23995,6 +23995,9 @@ msgstr "" ...@@ -23995,6 +23995,9 @@ msgstr ""
msgid "SearchAutocomplete|Merge requests assigned to me" msgid "SearchAutocomplete|Merge requests assigned to me"
msgstr "" msgstr ""
msgid "SearchAutocomplete|Merge requests that I'm a reviewer"
msgstr ""
msgid "SearchAutocomplete|in all GitLab" msgid "SearchAutocomplete|in all GitLab"
msgstr "" msgstr ""
......
...@@ -172,4 +172,25 @@ RSpec.describe 'Dashboard Merge Requests' do ...@@ -172,4 +172,25 @@ RSpec.describe 'Dashboard Merge Requests' do
expect(find('.issues-filters')).to have_content('Created date') expect(find('.issues-filters')).to have_content('Created date')
end end
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 end
...@@ -113,6 +113,10 @@ module FilteredSearchHelpers ...@@ -113,6 +113,10 @@ module FilteredSearchHelpers
create_token('Assignee', assignee_name) create_token('Assignee', assignee_name)
end end
def reviewer_token(reviewer_name = nil)
create_token('Reviewer', reviewer_name)
end
def milestone_token(milestone_name = nil, has_symbol = true, operator = '=') def milestone_token(milestone_name = nil, has_symbol = true, operator = '=')
symbol = has_symbol ? '%' : nil symbol = has_symbol ? '%' : nil
create_token('Milestone', milestone_name, symbol, operator) 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