summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2016-12-06 13:07:38 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2016-12-06 13:07:38 +0000
commit532c031915597a660ab21de0cd11f8255e54c03d (patch)
treeadc06bc8b44defd299a9836c649d1f806e4f5725 /app/helpers
parentda5c37256bf73cb4fbac44d96a27bad7321bdccc (diff)
parent7b99b18643b443109d790940ffdf40c301e2c85d (diff)
downloadgitlab-ce-532c031915597a660ab21de0cd11f8255e54c03d.tar.gz
Merge branch 'refine-ci-statuses' into 'master'
Refine CI Statuses ## What does this MR do? This MR introduces classes for each relevant CI status. ## What are the relevant issue numbers? Closes #24273 See merge request !7889
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/ci_status_helper.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb
index abcf84b4d15..8e19752a8a1 100644
--- a/app/helpers/ci_status_helper.rb
+++ b/app/helpers/ci_status_helper.rb
@@ -5,8 +5,9 @@ module CiStatusHelper
end
def ci_status_with_icon(status, target = nil)
- content = ci_icon_for_status(status) + ci_label_for_status(status)
+ content = ci_icon_for_status(status) + ci_text_for_status(status)
klass = "ci-status ci-#{status}"
+
if target
link_to content, target, class: klass
else
@@ -14,7 +15,19 @@ module CiStatusHelper
end
end
+ def ci_text_for_status(status)
+ if detailed_status?(status)
+ status.text
+ else
+ status
+ end
+ end
+
def ci_label_for_status(status)
+ if detailed_status?(status)
+ return status.label
+ end
+
case status
when 'success'
'passed'
@@ -31,6 +44,10 @@ module CiStatusHelper
end
def ci_icon_for_status(status)
+ if detailed_status?(status)
+ return custom_icon(status.icon)
+ end
+
icon_name =
case status
when 'success'
@@ -94,4 +111,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