Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/quick_actions/issue_actions.rb')
-rw-r--r--lib/gitlab/quick_actions/issue_actions.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/gitlab/quick_actions/issue_actions.rb b/lib/gitlab/quick_actions/issue_actions.rb
index b0aae363749..1822b0c8bd5 100644
--- a/lib/gitlab/quick_actions/issue_actions.rb
+++ b/lib/gitlab/quick_actions/issue_actions.rb
@@ -102,6 +102,41 @@ module Gitlab
@execution_message[:duplicate] = message
end
+ desc _('Clone this issue')
+ explanation do |project = quick_action_target.project.full_path|
+ _("Clones this issue, without comments, to %{project}.") % { project: project }
+ end
+ params 'path/to/project [--with_notes]'
+ types Issue
+ condition do
+ quick_action_target.persisted? &&
+ current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project)
+ end
+ command :clone do |params = ''|
+ params = params.split(' ')
+ with_notes = params.delete('--with_notes').present?
+
+ # If we have more than 1 param, then the user supplied too many spaces, or mistyped `--with_notes`
+ if params.size > 1
+ @execution_message[:clone] = _('Failed to clone this issue: wrong parameters.')
+ next
+ end
+
+ target_project_path = params[0]
+ target_project = target_project_path.present? ? Project.find_by_full_path(target_project_path) : quick_action_target.project
+
+ if target_project.present?
+ @updates[:target_clone_project] = target_project
+ @updates[:clone_with_notes] = with_notes
+
+ message = _("Cloned this issue to %{path_to_project}.") % { path_to_project: target_project_path || quick_action_target.project.full_path }
+ else
+ message = _("Failed to clone this issue because target project doesn't exist.")
+ end
+
+ @execution_message[:clone] = message
+ end
+
desc _('Move this issue to another project.')
explanation do |path_to_project|
_("Moves this issue to %{path_to_project}.") % { path_to_project: path_to_project }