Class: WorkItems::RelatedWorkItemLinks::CreateService

Inherits:
IssuableLinks::CreateService show all
Extended by:
Gitlab::Utils::Override
Defined in:
app/services/work_items/related_work_item_links/create_service.rb

Instance Attribute Summary

Attributes inherited from IssuableLinks::CreateService

#current_user, #issuable, #params

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::Utils::Override

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

Methods inherited from IssuableLinks::CreateService

#initialize, #relate_issuables

Methods inherited from BaseService

#initialize

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?

Constructor Details

This class inherits a constructor from IssuableLinks::CreateService

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/work_items/related_work_item_links/create_service.rb', line 8

def execute
  return error(_('No matching work item found.'), 404) unless can?(current_user, :admin_work_item_link, issuable)

  response = super

  if response[:status] == :success
    response[:message] = format(
      _('Successfully linked ID(s): %{item_ids}.'),
      item_ids: linked_ids(response[:created_references]).to_sentence
    )
  end

  response
end

#linkable_issuables(work_items) ⇒ Object



23
24
25
# File 'app/services/work_items/related_work_item_links/create_service.rb', line 23

def linkable_issuables(work_items)
  @linkable_issuables ||= work_items.select { |work_item| can_link_item?(work_item) }
end


27
28
29
# File 'app/services/work_items/related_work_item_links/create_service.rb', line 27

def previous_related_issuables
  @related_issues ||= issuable.linked_work_items(authorize: false).to_a
end