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:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-12-05 16:19:12 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-12-05 16:19:12 +0300
commited4ec0dab7df042d53696ad118c9f0a829990802 (patch)
tree7934b845c471c16f8971857de2d52dfebd6440c0 /app/helpers/ci_status_helper.rb
parent5e3cfe2f091a1803aa7d08238232aea846ebfb5a (diff)
Add support for detailed status to status helpers
Diffstat (limited to 'app/helpers/ci_status_helper.rb')
-rw-r--r--app/helpers/ci_status_helper.rb53
1 files changed, 32 insertions, 21 deletions
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb
index abcf84b4d15..ff507765255 100644
--- a/app/helpers/ci_status_helper.rb
+++ b/app/helpers/ci_status_helper.rb
@@ -6,7 +6,8 @@ module CiStatusHelper
def ci_status_with_icon(status, target = nil)
content = ci_icon_for_status(status) + ci_label_for_status(status)
- klass = "ci-status ci-#{status}"
+ klass = "ci-status ci-#{status}" # TODO, add support for detailed status
+
if target
link_to content, target, class: klass
else
@@ -15,11 +16,13 @@ module CiStatusHelper
end
def ci_label_for_status(status)
+ if detailed_status?(status)
+ return status.label
+ end
+
case status
when 'success'
'passed'
- when 'success_with_warnings'
- 'passed with warnings'
else
status
end
@@ -32,25 +35,27 @@ module CiStatusHelper
def ci_icon_for_status(status)
icon_name =
- case status
- when 'success'
- 'icon_status_success'
- when 'success_with_warnings'
- 'icon_status_warning'
- when 'failed'
- 'icon_status_failed'
- when 'pending'
- 'icon_status_pending'
- when 'running'
- 'icon_status_running'
- when 'play'
- 'icon_play'
- when 'created'
- 'icon_status_created'
- when 'skipped'
- 'icon_status_skipped'
+ if detailed_status?(status)
+ status.icon
else
- 'icon_status_canceled'
+ case status
+ when 'success'
+ 'icon_status_success'
+ when 'failed'
+ 'icon_status_failed'
+ when 'pending'
+ 'icon_status_pending'
+ when 'running'
+ 'icon_status_running'
+ when 'play'
+ 'icon_play'
+ when 'created'
+ 'icon_status_created'
+ when 'skipped'
+ 'icon_status_skipped'
+ else
+ 'icon_status_canceled'
+ end
end
custom_icon(icon_name)
@@ -94,4 +99,10 @@ module CiStatusHelper
class: klass, title: title, data: data
end
end
+
+ def detailed_status?(status)
+ status.respond_to?(:text) &&
+ status.respond_to?(:label) &&
+ status.respond_to?(:icon)
+ end
end