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:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-21 03:07:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-21 03:07:40 +0300
commitbb348db4c22bf58ac685fcd66445ac172491b302 (patch)
treeaca3fcf2e361989744ddaee559b51761100472ed /lib/gitlab/quick_actions
parentbe59dd1d43332496def276c8d3e78fc82e94273a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/quick_actions')
-rw-r--r--lib/gitlab/quick_actions/command_definition.rb19
-rw-r--r--lib/gitlab/quick_actions/dsl.rb10
2 files changed, 24 insertions, 5 deletions
diff --git a/lib/gitlab/quick_actions/command_definition.rb b/lib/gitlab/quick_actions/command_definition.rb
index ebdae139315..b17a0208f95 100644
--- a/lib/gitlab/quick_actions/command_definition.rb
+++ b/lib/gitlab/quick_actions/command_definition.rb
@@ -4,7 +4,7 @@ module Gitlab
module QuickActions
class CommandDefinition
attr_accessor :name, :aliases, :description, :explanation, :execution_message,
- :params, :condition_block, :parse_params_block, :action_block, :warning, :types
+ :params, :condition_block, :parse_params_block, :action_block, :warning, :icon, :types
def initialize(name, attributes = {})
@name = name
@@ -12,6 +12,7 @@ module Gitlab
@aliases = attributes[:aliases] || []
@description = attributes[:description] || ''
@warning = attributes[:warning] || ''
+ @icon = attributes[:icon] || ''
@explanation = attributes[:explanation] || ''
@execution_message = attributes[:execution_message] || ''
@params = attributes[:params] || []
@@ -45,7 +46,13 @@ module Gitlab
explanation
end
- warning.empty? ? message : "#{message} (#{warning})"
+ warning_text = if warning.respond_to?(:call)
+ execute_block(warning, context, arg)
+ else
+ warning
+ end
+
+ warning.empty? ? message : "#{message} (#{warning_text})"
end
def execute(context, arg)
@@ -72,6 +79,11 @@ module Gitlab
desc = context.instance_exec(&desc) rescue ''
end
+ warn = warning
+ if warn.respond_to?(:call)
+ warn = context.instance_exec(&warn) rescue ''
+ end
+
prms = params
if prms.respond_to?(:call)
prms = Array(context.instance_exec(&prms)) rescue params
@@ -81,7 +93,8 @@ module Gitlab
name: name,
aliases: aliases,
description: desc,
- warning: warning,
+ warning: warn,
+ icon: icon,
params: prms
}
end
diff --git a/lib/gitlab/quick_actions/dsl.rb b/lib/gitlab/quick_actions/dsl.rb
index 5abbd377642..a2dfcc6de9a 100644
--- a/lib/gitlab/quick_actions/dsl.rb
+++ b/lib/gitlab/quick_actions/dsl.rb
@@ -33,8 +33,12 @@ module Gitlab
@description = block_given? ? block : text
end
- def warning(message = '')
- @warning = message
+ def warning(text = '', &block)
+ @warning = block_given? ? block : text
+ end
+
+ def icon(string = '')
+ @icon = string
end
# Allows to define params for the next quick action.
@@ -192,6 +196,7 @@ module Gitlab
aliases: aliases,
description: @description,
warning: @warning,
+ icon: @icon,
explanation: @explanation,
execution_message: @execution_message,
params: @params,
@@ -213,6 +218,7 @@ module Gitlab
@params = nil
@condition_block = nil
@warning = nil
+ @icon = nil
@parse_params_block = nil
@types = nil
end