summaryrefslogtreecommitdiff
path: root/app/services/quick_actions
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-04-24 15:25:04 +0000
committerRémy Coutable <remy@rymai.me>2018-04-24 15:25:04 +0000
commit878ad484cd489d09df6a7944ebe0099ee38e46c7 (patch)
tree9805f3c8925486496b05d88c78e341eb46f3ccb9 /app/services/quick_actions
parent906fc00c33611ca2e5e3e66892cc990b05071d9f (diff)
parent6a88ffb412430820e23f19c7c32049abe1a019c3 (diff)
downloadgitlab-ce-878ad484cd489d09df6a7944ebe0099ee38e46c7.tar.gz
Merge branch 'matbaj/gitlab-ce-add-inherit-command' into 'master'
Add copy_metadata quick action Closes #38450 See merge request gitlab-org/gitlab-ce!18497
Diffstat (limited to 'app/services/quick_actions')
-rw-r--r--app/services/quick_actions/interpret_service.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb
index 6804dff2a9b..0215994b1a7 100644
--- a/app/services/quick_actions/interpret_service.rb
+++ b/app/services/quick_actions/interpret_service.rb
@@ -270,6 +270,26 @@ module QuickActions
end
end
+ desc 'Copy labels and milestone from other issue or merge request'
+ explanation do |source_issuable|
+ "Copy labels and milestone from #{source_issuable.to_reference}."
+ end
+ params '#issue | !merge_request'
+ condition do
+ issuable.persisted? &&
+ current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
+ end
+ parse_params do |issuable_param|
+ extract_references(issuable_param, :issue).first ||
+ extract_references(issuable_param, :merge_request).first
+ end
+ command :copy_metadata do |source_issuable|
+ if source_issuable.present? && source_issuable.project.id == issuable.project.id
+ @updates[:add_label_ids] = source_issuable.labels.map(&:id)
+ @updates[:milestone_id] = source_issuable.milestone.id if source_issuable.milestone
+ end
+ end
+
desc 'Add a todo'
explanation 'Adds a todo.'
condition do