diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/gitlab/quick_actions | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/gitlab/quick_actions')
-rw-r--r-- | lib/gitlab/quick_actions/issue_actions.rb | 35 |
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 } |