diff options
Diffstat (limited to 'lib/gitlab/quick_actions/issuable_actions.rb')
-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? |