summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorwinh <winnie@gitlab.com>2017-05-24 14:37:55 +0200
committerwinh <winnie@gitlab.com>2017-05-25 19:08:37 +0200
commitf565c4393efe1cadd05b22ae2fa7e36cee4d2793 (patch)
treeb3315a3bcf1e9e1f05346ea69036ba3277804d8f /app
parente63d27d83bdf9c07776c18ebc297d75728aa7e29 (diff)
downloadgitlab-ce-f565c4393efe1cadd05b22ae2fa7e36cee4d2793.tar.gz
Provide default for calculating label text color (!11681)
Diffstat (limited to 'app')
-rw-r--r--app/helpers/labels_helper.rb5
-rw-r--r--app/models/label.rb4
2 files changed, 6 insertions, 3 deletions
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index e5b1e6e8bc7..4e6e6805920 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -69,13 +69,12 @@ module LabelsHelper
end
def render_colored_label(label, label_suffix = '', tooltip: true)
- label_color = label.color || Label::DEFAULT_COLOR
- text_color = text_color_for_bg(label_color)
+ text_color = text_color_for_bg(label.color)
# Intentionally not using content_tag here so that this method can be called
# by LabelReferenceFilter
span = %(<span class="label color-label #{"has-tooltip" if tooltip}" ) +
- %(style="background-color: #{label_color}; color: #{text_color}" ) +
+ %(style="background-color: #{label.color}; color: #{text_color}" ) +
%(title="#{escape_once(label.description)}" data-container="body">) +
%(#{escape_once(label.name)}#{label_suffix}</span>)
diff --git a/app/models/label.rb b/app/models/label.rb
index ddddb6bdf8f..074239702f8 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -133,6 +133,10 @@ class Label < ActiveRecord::Base
template
end
+ def color
+ super || DEFAULT_COLOR
+ end
+
def text_color
LabelsHelper.text_color_for_bg(self.color)
end