diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /lib/gitlab/quick_actions | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'lib/gitlab/quick_actions')
-rw-r--r-- | lib/gitlab/quick_actions/issuable_actions.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/gitlab/quick_actions/issuable_actions.rb b/lib/gitlab/quick_actions/issuable_actions.rb index efe07aa8ab2..cf5c9296d8c 100644 --- a/lib/gitlab/quick_actions/issuable_actions.rb +++ b/lib/gitlab/quick_actions/issuable_actions.rb @@ -241,8 +241,49 @@ module Gitlab "#{comment} #{TABLEFLIP}" end + desc _('Set severity') + explanation _('Sets the severity') + params '1 / S1 / Critical' + types Issue + condition do + !quick_action_target.persisted? || quick_action_target.supports_severity? + end + parse_params do |severity| + find_severity(severity) + end + command :severity do |severity| + next unless quick_action_target.supports_severity? + + if severity + if quick_action_target.persisted? + ::Issues::UpdateService.new(project: quick_action_target.project, current_user: current_user, params: { severity: severity }).execute(quick_action_target) + else + quick_action_target.build_issuable_severity(severity: severity) + end + + @execution_message[:severity] = _("Severity updated to %{severity}.") % { severity: severity.capitalize } + else + @execution_message[:severity] = _('No severity matches the provided parameter') + end + end + private + def find_severity(severity_param) + return unless severity_param + + severity_param = severity_param.downcase + severities = IssuableSeverity::SEVERITY_QUICK_ACTION_PARAMS.values.map { |vals| vals.map(&:downcase) } + + matched_severity = severities.find do |severity_values| + severity_values.include?(severity_param) + end + + return unless matched_severity + + matched_severity[0] + end + def run_label_command(labels:, command:, updates_key:) return if labels.empty? |