summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2017-05-04 15:11:15 +0300
committerValery Sizov <valery@gitlab.com>2017-05-04 17:11:53 +0300
commit387c4b2c21a44360386a9b8ce6849e7f1b8a3de9 (patch)
tree446b8338efe8ad22ca03b00b2dc72b22c4174e02 /lib
parent68c12e15cc236548918f91393ebef3c06c124814 (diff)
downloadgitlab-ce-387c4b2c21a44360386a9b8ce6849e7f1b8a3de9.tar.gz
Backport of multiple_assignees_feature [ci skip]
Diffstat (limited to 'lib')
-rw-r--r--lib/api/api.rb2
-rw-r--r--lib/api/entities.rb6
-rw-r--r--lib/api/helpers/common_helpers.rb13
-rw-r--r--lib/api/issues.rb9
-rw-r--r--lib/api/v3/entities.rb7
-rw-r--r--lib/api/v3/issues.rb33
-rw-r--r--lib/api/v3/merge_requests.rb2
-rw-r--r--lib/api/v3/milestones.rb4
-rw-r--r--lib/banzai/reference_parser/issue_parser.rb2
-rw-r--r--lib/gitlab/chat_commands/presenters/issue_base.rb2
-rw-r--r--lib/gitlab/fogbugz_import/importer.rb18
-rw-r--r--lib/gitlab/github_import/issue_formatter.rb2
-rw-r--r--lib/gitlab/google_code_import/importer.rb14
13 files changed, 76 insertions, 38 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb
index 1bf20f76ad6..842c7301a66 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -6,6 +6,7 @@ module API
version 'v3', using: :path do
helpers ::API::V3::Helpers
+ helpers ::API::Helpers::CommonHelpers
mount ::API::V3::AwardEmoji
mount ::API::V3::Boards
@@ -77,6 +78,7 @@ module API
# Ensure the namespace is right, otherwise we might load Grape::API::Helpers
helpers ::SentryHelper
helpers ::API::Helpers
+ helpers ::API::Helpers::CommonHelpers
# Keep in alphabetical order
mount ::API::AccessRequests
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 6d6ccefe877..f8f5548d23d 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -256,7 +256,11 @@ module API
class IssueBasic < ProjectEntity
expose :label_names, as: :labels
expose :milestone, using: Entities::Milestone
- expose :assignee, :author, using: Entities::UserBasic
+ expose :assignees, :author, using: Entities::UserBasic
+
+ expose :assignee, using: ::API::Entities::UserBasic do |issue, options|
+ issue.assignees.first
+ end
expose :user_notes_count
expose :upvotes, :downvotes
diff --git a/lib/api/helpers/common_helpers.rb b/lib/api/helpers/common_helpers.rb
new file mode 100644
index 00000000000..6236fdd43ca
--- /dev/null
+++ b/lib/api/helpers/common_helpers.rb
@@ -0,0 +1,13 @@
+module API
+ module Helpers
+ module CommonHelpers
+ def convert_parameters_from_legacy_format(params)
+ if params[:assignee_id].present?
+ params[:assignee_ids] = [params.delete(:assignee_id)]
+ end
+
+ params
+ end
+ end
+ end
+end
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index 522f0f3be92..78db960ae28 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -32,7 +32,8 @@ module API
params :issue_params_ce do
optional :description, type: String, desc: 'The description of an issue'
- optional :assignee_id, type: Integer, desc: 'The ID of a user to assign issue'
+ optional :assignee_ids, type: Array[Integer], desc: 'The array of user IDs to assign issue'
+ optional :assignee_id, type: Integer, desc: '[Deprecated] The ID of a user to assign issue'
optional :milestone_id, type: Integer, desc: 'The ID of a milestone to assign issue'
optional :labels, type: String, desc: 'Comma-separated list of label names'
optional :due_date, type: String, desc: 'Date string in the format YEAR-MONTH-DAY'
@@ -135,6 +136,8 @@ module API
issue_params = declared_params(include_missing: false)
+ issue_params = convert_parameters_from_legacy_format(issue_params)
+
issue = ::Issues::CreateService.new(user_project,
current_user,
issue_params.merge(request: request, api: true)).execute
@@ -159,7 +162,7 @@ module API
desc: 'Date time when the issue was updated. Available only for admins and project owners.'
optional :state_event, type: String, values: %w[reopen close], desc: 'State of the issue'
use :issue_params
- at_least_one_of :title, :description, :assignee_id, :milestone_id,
+ at_least_one_of :title, :description, :assignee_ids, :assignee_id, :milestone_id,
:labels, :created_at, :due_date, :confidential, :state_event
end
put ':id/issues/:issue_iid' do
@@ -173,6 +176,8 @@ module API
update_params = declared_params(include_missing: false).merge(request: request, api: true)
+ update_params = convert_parameters_from_legacy_format(update_params)
+
issue = ::Issues::UpdateService.new(user_project,
current_user,
update_params).execute(issue)
diff --git a/lib/api/v3/entities.rb b/lib/api/v3/entities.rb
index 832b4bdeb4f..7c8be7e51db 100644
--- a/lib/api/v3/entities.rb
+++ b/lib/api/v3/entities.rb
@@ -248,6 +248,13 @@ module API
expose :project_id, :issues_events, :merge_requests_events
expose :note_events, :build_events, :pipeline_events, :wiki_page_events
end
+
+ class Issue < ::API::Entities::Issue
+ unexpose :assignees
+ expose :assignee do |issue, options|
+ ::API::Entities::UserBasic.represent(issue.assignees.first, options)
+ end
+ end
end
end
end
diff --git a/lib/api/v3/issues.rb b/lib/api/v3/issues.rb
index 715083fc4f8..cedbeb0ded0 100644
--- a/lib/api/v3/issues.rb
+++ b/lib/api/v3/issues.rb
@@ -8,6 +8,7 @@ module API
helpers do
def find_issues(args = {})
args = params.merge(args)
+ args = convert_parameters_from_legacy_format(args)
args.delete(:id)
args[:milestone_title] = args.delete(:milestone)
@@ -51,7 +52,7 @@ module API
resource :issues do
desc "Get currently authenticated user's issues" do
- success ::API::Entities::Issue
+ success ::API::V3::Entities::Issue
end
params do
optional :state, type: String, values: %w[opened closed all], default: 'all',
@@ -60,8 +61,12 @@ module API
end
get do
issues = find_issues(scope: 'authored')
+<<<<<<< HEAD
present paginate(issues), with: ::API::Entities::Issue, current_user: current_user
+=======
+ present paginate(issues), with: ::API::V3::Entities::Issue, current_user: current_user
+>>>>>>> b0a2435... Merge branch 'multiple_assignees_review_upstream' into ee_master
end
end
@@ -70,7 +75,7 @@ module API
end
resource :groups, requirements: { id: %r{[^/]+} } do
desc 'Get a list of group issues' do
- success ::API::Entities::Issue
+ success ::API::V3::Entities::Issue
end
params do
optional :state, type: String, values: %w[opened closed all], default: 'all',
@@ -82,7 +87,7 @@ module API
issues = find_issues(group_id: group.id, match_all_labels: true)
- present paginate(issues), with: ::API::Entities::Issue, current_user: current_user
+ present paginate(issues), with: ::API::V3::Entities::Issue, current_user: current_user
end
end
@@ -94,7 +99,7 @@ module API
desc 'Get a list of project issues' do
detail 'iid filter is deprecated have been removed on V4'
- success ::API::Entities::Issue
+ success ::API::V3::Entities::Issue
end
params do
optional :state, type: String, values: %w[opened closed all], default: 'all',
@@ -107,22 +112,22 @@ module API
issues = find_issues(project_id: project.id)
- present paginate(issues), with: ::API::Entities::Issue, current_user: current_user, project: user_project
+ present paginate(issues), with: ::API::V3::Entities::Issue, current_user: current_user, project: user_project
end
desc 'Get a single project issue' do
- success ::API::Entities::Issue
+ success ::API::V3::Entities::Issue
end
params do
requires :issue_id, type: Integer, desc: 'The ID of a project issue'
end
get ":id/issues/:issue_id" do
issue = find_project_issue(params[:issue_id])
- present issue, with: ::API::Entities::Issue, current_user: current_user, project: user_project
+ present issue, with: ::API::V3::Entities::Issue, current_user: current_user, project: user_project
end
desc 'Create a new project issue' do
- success ::API::Entities::Issue
+ success ::API::V3::Entities::Issue
end
params do
requires :title, type: String, desc: 'The title of an issue'
@@ -140,6 +145,7 @@ module API
issue_params = declared_params(include_missing: false)
issue_params = issue_params.merge(merge_request_to_resolve_discussions_of: issue_params.delete(:merge_request_for_resolving_discussions))
+ issue_params = convert_parameters_from_legacy_format(issue_params)
issue = ::Issues::CreateService.new(user_project,
current_user,
@@ -147,14 +153,14 @@ module API
render_spam_error! if issue.spam?
if issue.valid?
- present issue, with: ::API::Entities::Issue, current_user: current_user, project: user_project
+ present issue, with: ::API::V3::Entities::Issue, current_user: current_user, project: user_project
else
render_validation_error!(issue)
end
end
desc 'Update an existing issue' do
- success ::API::Entities::Issue
+ success ::API::V3::Entities::Issue
end
params do
requires :issue_id, type: Integer, desc: 'The ID of a project issue'
@@ -176,6 +182,7 @@ module API
end
update_params = declared_params(include_missing: false).merge(request: request, api: true)
+ update_params = convert_parameters_from_legacy_format(update_params)
issue = ::Issues::UpdateService.new(user_project,
current_user,
@@ -184,14 +191,14 @@ module API
render_spam_error! if issue.spam?
if issue.valid?
- present issue, with: ::API::Entities::Issue, current_user: current_user, project: user_project
+ present issue, with: ::API::V3::Entities::Issue, current_user: current_user, project: user_project
else
render_validation_error!(issue)
end
end
desc 'Move an existing issue' do
- success ::API::Entities::Issue
+ success ::API::V3::Entities::Issue
end
params do
requires :issue_id, type: Integer, desc: 'The ID of a project issue'
@@ -206,7 +213,7 @@ module API
begin
issue = ::Issues::MoveService.new(user_project, current_user).execute(issue, new_project)
- present issue, with: ::API::Entities::Issue, current_user: current_user, project: user_project
+ present issue, with: ::API::V3::Entities::Issue, current_user: current_user, project: user_project
rescue ::Issues::MoveService::MoveError => error
render_api_error!(error.message, 400)
end
diff --git a/lib/api/v3/merge_requests.rb b/lib/api/v3/merge_requests.rb
index 1616142a619..b6b7254ae29 100644
--- a/lib/api/v3/merge_requests.rb
+++ b/lib/api/v3/merge_requests.rb
@@ -34,7 +34,7 @@ module API
if project.has_external_issue_tracker?
::API::Entities::ExternalIssue
else
- ::API::Entities::Issue
+ ::API::V3::Entities::Issue
end
end
diff --git a/lib/api/v3/milestones.rb b/lib/api/v3/milestones.rb
index be90cec4afc..4c7061d4939 100644
--- a/lib/api/v3/milestones.rb
+++ b/lib/api/v3/milestones.rb
@@ -39,7 +39,7 @@ module API
end
desc 'Get all issues for a single project milestone' do
- success ::API::Entities::Issue
+ success ::API::V3::Entities::Issue
end
params do
requires :milestone_id, type: Integer, desc: 'The ID of a project milestone'
@@ -56,7 +56,7 @@ module API
}
issues = IssuesFinder.new(current_user, finder_params).execute
- present paginate(issues), with: ::API::Entities::Issue, current_user: current_user, project: user_project
+ present paginate(issues), with: ::API::V3::Entities::Issue, current_user: current_user, project: user_project
end
end
end
diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb
index e02b360924a..89ec715ddf6 100644
--- a/lib/banzai/reference_parser/issue_parser.rb
+++ b/lib/banzai/reference_parser/issue_parser.rb
@@ -28,7 +28,7 @@ module Banzai
nodes,
Issue.all.includes(
:author,
- :assignee,
+ :assignees,
{
# These associations are primarily used for checking permissions.
# Eager loading these ensures we don't end up running dozens of
diff --git a/lib/gitlab/chat_commands/presenters/issue_base.rb b/lib/gitlab/chat_commands/presenters/issue_base.rb
index 054f7f4be0c..25bc82994ba 100644
--- a/lib/gitlab/chat_commands/presenters/issue_base.rb
+++ b/lib/gitlab/chat_commands/presenters/issue_base.rb
@@ -22,7 +22,7 @@ module Gitlab
[
{
title: "Assignee",
- value: @resource.assignee ? @resource.assignee.name : "_None_",
+ value: @resource.assignees.any? ? @resource.assignees.first.name : "_None_",
short: true
},
{
diff --git a/lib/gitlab/fogbugz_import/importer.rb b/lib/gitlab/fogbugz_import/importer.rb
index 222bcdcbf9c..3dcee681c72 100644
--- a/lib/gitlab/fogbugz_import/importer.rb
+++ b/lib/gitlab/fogbugz_import/importer.rb
@@ -122,15 +122,15 @@ module Gitlab
author_id = user_info(bug['ixPersonOpenedBy'])[:gitlab_id] || project.creator_id
issue = Issue.create!(
- iid: bug['ixBug'],
- project_id: project.id,
- title: bug['sTitle'],
- description: body,
- author_id: author_id,
- assignee_id: assignee_id,
- state: bug['fOpen'] == 'true' ? 'opened' : 'closed',
- created_at: date,
- updated_at: DateTime.parse(bug['dtLastUpdated'])
+ iid: bug['ixBug'],
+ project_id: project.id,
+ title: bug['sTitle'],
+ description: body,
+ author_id: author_id,
+ assignee_ids: [assignee_id],
+ state: bug['fOpen'] == 'true' ? 'opened' : 'closed',
+ created_at: date,
+ updated_at: DateTime.parse(bug['dtLastUpdated'])
)
issue_labels = ::LabelsFinder.new(nil, project_id: project.id, title: labels).execute(skip_authorization: true)
diff --git a/lib/gitlab/github_import/issue_formatter.rb b/lib/gitlab/github_import/issue_formatter.rb
index 6f5ac4dac0d..977cd0423ba 100644
--- a/lib/gitlab/github_import/issue_formatter.rb
+++ b/lib/gitlab/github_import/issue_formatter.rb
@@ -10,7 +10,7 @@ module Gitlab
description: description,
state: state,
author_id: author_id,
- assignee_id: assignee_id,
+ assignee_ids: Array(assignee_id),
created_at: raw_data.created_at,
updated_at: raw_data.updated_at
}
diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb
index 5ca3e6a95ca..1b43440673c 100644
--- a/lib/gitlab/google_code_import/importer.rb
+++ b/lib/gitlab/google_code_import/importer.rb
@@ -108,13 +108,13 @@ module Gitlab
end
issue = Issue.create!(
- iid: raw_issue['id'],
- project_id: project.id,
- title: raw_issue['title'],
- description: body,
- author_id: project.creator_id,
- assignee_id: assignee_id,
- state: raw_issue['state'] == 'closed' ? 'closed' : 'opened'
+ iid: raw_issue['id'],
+ project_id: project.id,
+ title: raw_issue['title'],
+ description: body,
+ author_id: project.creator_id,
+ assignee_ids: [assignee_id],
+ state: raw_issue['state'] == 'closed' ? 'closed' : 'opened'
)
issue_labels = ::LabelsFinder.new(nil, project_id: project.id, title: labels).execute(skip_authorization: true)