Refresh

This website rubydoc.info/github/gitlabhq/gitlabhq/WorkItems/CreateService is currently offline. Cloudflare\'s Always Online™ shows a snapshot of this web page from the Internet Archive\'s Wayback Machine. To check for the live version, click Refresh.

Class: WorkItems::CreateService

Inherits:
Issues::CreateService show all
Includes:
WidgetableService
Defined in:
app/services/work_items/create_service.rb

Direct Known Subclasses

DataSync::BaseCreateService

Constant Summary

Constants included from RateLimitedService

RateLimitedService::RateLimitedNotSetupError

Constants inherited from Issues::BaseService

Issues::BaseService::EpicAssignmentError, Issues::BaseService::NO_REBALANCING_NEEDED

Constants included from Gitlab::Utils::UsageData

Gitlab::Utils::UsageData::DISTRIBUTED_HLL_FALLBACK, Gitlab::Utils::UsageData::FALLBACK, Gitlab::Utils::UsageData::HISTOGRAM_FALLBACK, Gitlab::Utils::UsageData::MAX_BUCKET_SIZE

Instance Attribute Summary

Attributes included from Issues::ResolveDiscussions

#discussion_to_resolve_id, #merge_request_to_resolve_discussions_object, #merge_request_to_resolve_discussions_of_iid

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods included from WidgetableService

#handle_quick_actions, #initialize_callbacks!, #params_include_state_and_status_changes?

Methods inherited from Issues::CreateService

#after_create, #before_create, #external_author, #handle_assignee_changes, #handle_changes, #publish_event, #resolve_discussions_with_issue

Methods included from Services::ReturnServiceResponses

#error, #success

Methods included from Issues::ResolveDiscussions

#discussions_to_resolve, #filter_resolve_discussion_params, #merge_request_to_resolve_discussions_of

Methods included from RateLimitedService

#execute_without_rate_limiting

Methods inherited from Issues::BaseService

#available_callbacks, #close_service, constructor_container_arg, #execute_hooks, #hook_data, #rebalance_if_needed, #reopen_service

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from Issues::IssueTypeHelpers

#create_issue_type_allowed?

Methods included from IncidentManagement::UsageData

#track_incident_action

Methods included from Gitlab::Utils::UsageData

#add, #add_metric, #alt_usage_data, #average, #count, #distinct_count, #estimate_batch_distinct_count, #histogram, #maximum_id, #measure_duration, #metrics_collection_metadata, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_finished_at, #with_metadata, #with_prometheus_client

Methods inherited from IssuableBaseService

constructor_container_arg

Methods inherited from BaseContainerService

#group_container?, #namespace_container?, #project_container?, #project_group, #root_ancestor

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

#initialize(container:, perform_spam_check: true, current_user: nil, params: {}, widget_params: {}) ⇒ CreateService

Returns a new instance of CreateService.



7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/work_items/create_service.rb', line 7

def initialize(container:, perform_spam_check: true, current_user: nil, params: {}, widget_params: {})
  @create_source = params.delete(:create_source)
  super(
    container: container,
    current_user: current_user,
    params: params,
    perform_spam_check: perform_spam_check,
    build_service: ::WorkItems::BuildService.new(container: container, current_user: current_user, params: params)
  )
  @widget_params = widget_params
end

Instance Method Details

#execute(skip_system_notes: false) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/work_items/create_service.rb', line 19

def execute(skip_system_notes: false)
  result = skip_system_notes? ? super(skip_system_notes: true) : super

  # we need to pass `work_item` in error response to properly display errors
  return error(result.message, result.http_status, pass_back: payload(result[:issue])) if result.error?

  work_item = result[:issue]

  if work_item.valid?
    track_work_item_create(work_item)
    success(payload(work_item))
  else
    error(work_item.errors.full_messages, :unprocessable_entity, pass_back: payload(work_item))
  end
rescue ::Issuable::Callbacks::Base::Error => e
  error(e.message, :unprocessable_entity)
end

#parentObject



37
38
39
# File 'app/services/work_items/create_service.rb', line 37

def parent
  container
end