diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-02 09:06:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-02 09:06:58 +0000 |
commit | 259c0cc0c4f8a49001b33d1bee577f4422e16d62 (patch) | |
tree | b2cb5854de1e32daf6f94d55a7b6e5805f020eec /app | |
parent | 01de60f3a8f4d99e641d04d31369628425137c21 (diff) | |
download | gitlab-ce-259c0cc0c4f8a49001b33d1bee577f4422e16d62.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/issuable_actions.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/branches_controller.rb | 2 | ||||
-rw-r--r-- | app/services/issuable/bulk_update_service.rb | 20 |
3 files changed, 15 insertions, 9 deletions
diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb index 6162d006cc7..7b7cfa7a5d3 100644 --- a/app/controllers/concerns/issuable_actions.rb +++ b/app/controllers/concerns/issuable_actions.rb @@ -121,7 +121,7 @@ module IssuableActions end def bulk_update - result = Issuable::BulkUpdateService.new(current_user, bulk_update_params).execute(resource_name) + result = Issuable::BulkUpdateService.new(parent, current_user, bulk_update_params).execute(resource_name) quantity = result[:count] render json: { notice: "#{quantity} #{resource_name.pluralize(quantity)} updated" } diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 578a3d451a7..a908da08f57 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -133,8 +133,6 @@ class Projects::BranchesController < Projects::ApplicationController # frontend could omit this set. To prevent excessive I/O, we require # that a list of names be specified. def limit_diverging_commit_counts! - return unless Feature.enabled?(:limit_diverging_commit_counts, default_enabled: true) - limit = Kaminari.config.default_per_page # If we don't have many branches in the repository, then go ahead. 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') |