diff options
Diffstat (limited to 'app/services/issuable_base_service.rb')
-rw-r--r-- | app/services/issuable_base_service.rb | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index 38b10996f44..65a73dadc2e 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -97,29 +97,6 @@ class IssuableBaseService < BaseService params.delete(label_key) if params[label_key].nil? end - def filter_labels_in_param(key) - return if params[key].to_a.empty? - - params[key] = available_labels.id_in(params[key]).pluck_primary_key - end - - def find_or_create_label_ids - labels = params.delete(:labels) - - return unless labels - - params[:label_ids] = labels.map do |label_name| - label = Labels::FindOrCreateService.new( - current_user, - parent, - title: label_name.strip, - available_labels: available_labels - ).execute - - label.try(:id) - end.compact - end - def labels_service @labels_service ||= ::Labels::AvailableLabelsService.new(current_user, parent, params) end @@ -138,7 +115,7 @@ class IssuableBaseService < BaseService new_label_ids.uniq end - def handle_quick_actions_on_create(issuable) + def handle_quick_actions(issuable) merge_quick_actions_into_params!(issuable) end @@ -146,17 +123,21 @@ class IssuableBaseService < BaseService original_description = params.fetch(:description, issuable.description) description, command_params = - QuickActions::InterpretService.new(project, current_user) + QuickActions::InterpretService.new(project, current_user, quick_action_options) .execute(original_description, issuable, only: only) # Avoid a description already set on an issuable to be overwritten by a nil - params[:description] = description if description + params[:description] = description if description && description != original_description params.merge!(command_params) end + def quick_action_options + {} + end + def create(issuable) - handle_quick_actions_on_create(issuable) + handle_quick_actions(issuable) filter_params(issuable) params.delete(:state_event) @@ -200,11 +181,13 @@ class IssuableBaseService < BaseService end def update(issuable) + handle_quick_actions(issuable) + filter_params(issuable) + change_state(issuable) change_subscription(issuable) change_todo(issuable) toggle_award(issuable) - filter_params(issuable) old_associations = associations_before_update(issuable) label_ids = process_label_ids(params, existing_label_ids: issuable.label_ids) |