2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module QuickActions
|
|
|
|
module RelateActions
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
include ::Gitlab::QuickActions::Dsl
|
|
|
|
|
|
|
|
included do
|
2022-07-23 23:45:48 +05:30
|
|
|
desc { _('Mark this issue as related to another issue') }
|
2020-11-24 15:15:51 +05:30
|
|
|
explanation do |related_reference|
|
|
|
|
_('Marks this issue as related to %{issue_ref}.') % { issue_ref: related_reference }
|
|
|
|
end
|
|
|
|
execution_message do |related_reference|
|
|
|
|
_('Marked this issue as related to %{issue_ref}.') % { issue_ref: related_reference }
|
|
|
|
end
|
|
|
|
params '#issue'
|
|
|
|
types Issue
|
|
|
|
condition do
|
2021-11-18 22:05:49 +05:30
|
|
|
current_user.can?(:"update_#{quick_action_target.to_ability_name}", quick_action_target)
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
2021-11-18 22:05:49 +05:30
|
|
|
command :relate do |related_reference|
|
|
|
|
service = IssueLinks::CreateService.new(quick_action_target, current_user, { issuable_references: [related_reference] })
|
|
|
|
create_issue_link = proc { service.execute }
|
|
|
|
|
|
|
|
if quick_action_target.persisted?
|
|
|
|
create_issue_link.call
|
|
|
|
else
|
|
|
|
quick_action_target.run_after_commit(&create_issue_link)
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|