Commit bb59a1f9 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'assign-to-issuable-opener' into 'master'

Issuable can be assigned to author

Closes #9014

The only difference with #9014 is that I thoughed the author should also be
able to assign the issue. If this is unwanted behavior Ill revert it.

/cc @DouweM

See merge request !2765
parents 8b7bf2a0 33f8b06c
...@@ -50,6 +50,7 @@ v 8.7.0 (unreleased) ...@@ -50,6 +50,7 @@ v 8.7.0 (unreleased)
- Fix high CPU usage when PostReceive receives refs/merge-requests/<id> - Fix high CPU usage when PostReceive receives refs/merge-requests/<id>
- Hide `Create a group` help block when creating a new project in a group - Hide `Create a group` help block when creating a new project in a group
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.) - Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Allow issues and merge requests to be assigned to the author !2765
- Gracefully handle notes on deleted commits in merge requests (Stan Hu) - Gracefully handle notes on deleted commits in merge requests (Stan Hu)
- Decouple membership and notifications - Decouple membership and notifications
- Fix creation of merge requests for orphaned branches (Stan Hu) - Fix creation of merge requests for orphaned branches (Stan Hu)
......
...@@ -12,6 +12,7 @@ class @UsersSelect ...@@ -12,6 +12,7 @@ class @UsersSelect
showNullUser = $dropdown.data('null-user') showNullUser = $dropdown.data('null-user')
showAnyUser = $dropdown.data('any-user') showAnyUser = $dropdown.data('any-user')
firstUser = $dropdown.data('first-user') firstUser = $dropdown.data('first-user')
@authorId = $dropdown.data('author-id')
selectedId = $dropdown.data('selected') selectedId = $dropdown.data('selected')
defaultLabel = $dropdown.data('default-label') defaultLabel = $dropdown.data('default-label')
issueURL = $dropdown.data('issueUpdate') issueURL = $dropdown.data('issueUpdate')
...@@ -207,6 +208,7 @@ class @UsersSelect ...@@ -207,6 +208,7 @@ class @UsersSelect
@projectId = $(select).data('project-id') @projectId = $(select).data('project-id')
@groupId = $(select).data('group-id') @groupId = $(select).data('group-id')
@showCurrentUser = $(select).data('current-user') @showCurrentUser = $(select).data('current-user')
@authorId = $(select).data('author-id')
showNullUser = $(select).data('null-user') showNullUser = $(select).data('null-user')
showAnyUser = $(select).data('any-user') showAnyUser = $(select).data('any-user')
showEmailUser = $(select).data('email-user') showEmailUser = $(select).data('email-user')
...@@ -312,6 +314,7 @@ class @UsersSelect ...@@ -312,6 +314,7 @@ class @UsersSelect
project_id: @projectId project_id: @projectId
group_id: @groupId group_id: @groupId
current_user: @showCurrentUser current_user: @showCurrentUser
author_id: @authorId
dataType: "json" dataType: "json"
).done (users) -> ).done (users) ->
callback(users) callback(users)
......
...@@ -12,8 +12,15 @@ class AutocompleteController < ApplicationController ...@@ -12,8 +12,15 @@ class AutocompleteController < ApplicationController
if params[:search].blank? if params[:search].blank?
# Include current user if available to filter by "Me" # Include current user if available to filter by "Me"
if params[:current_user] && current_user if params[:current_user] && current_user
@users = [*@users, current_user].uniq @users = [*@users, current_user]
end end
if params[:author_id].present?
author = User.find_by_id(params[:author_id])
@users = [author, *@users] if author
end
@users.uniq!
end end
render json: @users, only: [:name, :username, :id], methods: [:avatar_url] render json: @users, only: [:name, :username, :id], methods: [:avatar_url]
......
...@@ -11,6 +11,7 @@ module SelectsHelper ...@@ -11,6 +11,7 @@ module SelectsHelper
email_user = opts[:email_user] || false email_user = opts[:email_user] || false
first_user = opts[:first_user] && current_user ? current_user.username : false first_user = opts[:first_user] && current_user ? current_user.username : false
current_user = opts[:current_user] || false current_user = opts[:current_user] || false
author_id = opts[:author_id] || ''
project = opts[:project] || @project project = opts[:project] || @project
html = { html = {
...@@ -21,7 +22,8 @@ module SelectsHelper ...@@ -21,7 +22,8 @@ module SelectsHelper
any_user: any_user, any_user: any_user,
email_user: email_user, email_user: email_user,
first_user: first_user, first_user: first_user,
current_user: current_user current_user: current_user,
author_id: author_id
} }
} }
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
.selectbox.hide-collapsed .selectbox.hide-collapsed
= f.hidden_field 'assignee_id', value: issuable.assignee_id, id: 'issue_assignee_id' = f.hidden_field 'assignee_id', value: issuable.assignee_id, id: 'issue_assignee_id'
= dropdown_tag('Select assignee', options: { toggle_class: 'js-user-search js-author-search', title: 'Assign to', filter: true, dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-author', placeholder: 'Search users', data: { first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), field_name: "#{issuable.to_ability_name}[assignee_id]", issue_update: issuable_json_path(issuable), ability_name: issuable.to_ability_name, null_user: true } }) = dropdown_tag('Select assignee', options: { toggle_class: 'js-user-search js-author-search', title: 'Assign to', filter: true, dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-author', placeholder: 'Search users', data: { first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), author_id: issuable.author_id, field_name: "#{issuable.to_ability_name}[assignee_id]", issue_update: issuable_json_path(issuable), ability_name: issuable.to_ability_name, null_user: true } })
.block.milestone .block.milestone
.sidebar-collapsed-icon .sidebar-collapsed-icon
......
...@@ -12,13 +12,13 @@ describe AutocompleteController do ...@@ -12,13 +12,13 @@ describe AutocompleteController do
project.team << [user, :master] project.team << [user, :master]
end end
let(:body) { JSON.parse(response.body) }
describe 'GET #users with project ID' do describe 'GET #users with project ID' do
before do before do
get(:users, project_id: project.id) get(:users, project_id: project.id)
end end
let(:body) { JSON.parse(response.body) }
it { expect(body).to be_kind_of(Array) } it { expect(body).to be_kind_of(Array) }
it { expect(body.size).to eq 1 } it { expect(body.size).to eq 1 }
it { expect(body.map { |u| u["username"] }).to include(user.username) } it { expect(body.map { |u| u["username"] }).to include(user.username) }
...@@ -143,4 +143,24 @@ describe AutocompleteController do ...@@ -143,4 +143,24 @@ describe AutocompleteController do
it { expect(body.size).to eq 0 } it { expect(body.size).to eq 0 }
end end
end end
context 'author of issuable included' do
before do
sign_in(user)
end
let(:body) { JSON.parse(response.body) }
it 'includes the author' do
get(:users, author_id: non_member.id)
expect(body.first["username"]).to eq non_member.username
end
it 'rejects non existent user ids' do
get(:users, author_id: 99999)
expect(body.collect { |u| u['id'] }).not_to include(99999)
end
end
end end
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