Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-02 12:06:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-02 12:06:58 +0300
commit259c0cc0c4f8a49001b33d1bee577f4422e16d62 (patch)
treeb2cb5854de1e32daf6f94d55a7b6e5805f020eec /app/services/issuable
parent01de60f3a8f4d99e641d04d31369628425137c21 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/issuable')
-rw-r--r--app/services/issuable/bulk_update_service.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/app/services/issuable/bulk_update_service.rb b/app/services/issuable/bulk_update_service.rb
index 273a12f386a..bbb3c2ad050 100644
--- a/app/services/issuable/bulk_update_service.rb
+++ b/app/services/issuable/bulk_update_service.rb
@@ -4,19 +4,18 @@ module Issuable
class BulkUpdateService
include Gitlab::Allowable
- attr_accessor :current_user, :params
+ attr_accessor :parent, :current_user, :params
- def initialize(user = nil, params = {})
- @current_user, @params = user, params.dup
+ def initialize(parent, user = nil, params = {})
+ @parent, @current_user, @params = parent, user, params.dup
end
- # rubocop: disable CodeReuse/ActiveRecord
def execute(type)
model_class = type.classify.constantize
update_class = type.classify.pluralize.constantize::UpdateService
ids = params.delete(:issuable_ids).split(",")
- items = model_class.where(id: ids)
+ items = find_issuables(parent, model_class, ids)
permitted_attrs(type).each do |key|
params.delete(key) unless params[key].present?
@@ -37,7 +36,6 @@ module Issuable
success: !items.count.zero?
}
end
- # rubocop: enable CodeReuse/ActiveRecord
private
@@ -50,5 +48,15 @@ module Issuable
attrs.push(:assignee_id)
end
end
+
+ def find_issuables(parent, model_class, ids)
+ if parent.is_a?(Project)
+ model_class.id_in(ids).of_projects(parent)
+ elsif parent.is_a?(Group)
+ model_class.id_in(ids).of_projects(parent.all_projects)
+ end
+ end
end
end
+
+Issuable::BulkUpdateService.prepend_if_ee('EE::Issuable::BulkUpdateService')