Commit be68cc461755752697642c58154781ae4ec9ab31

Authored by Dmitriy Zaporozhets
1 parent 9d668750

add Gitlab::Label class and different color labels for default labels set

app/helpers/issues_helper.rb
... ... @@ -88,4 +88,19 @@ module IssuesHelper
88 88 ""
89 89 end
90 90 end
  91 +
  92 + def label_css_class(name)
  93 + case name
  94 + when *warning_labels
  95 + 'label-warning'
  96 + when *neutral_labels
  97 + 'label-inverse'
  98 + when *positive_labels
  99 + 'label-success'
  100 + when *important_labels
  101 + 'label-important'
  102 + else
  103 + 'label-info'
  104 + end
  105 + end
91 106 end
... ...
app/views/issues/_issue.html.haml
... ... @@ -27,7 +27,7 @@
27 27  
28 28 .issue-labels
29 29 - issue.labels.each do |label|
30   - %span.label.label-info
  30 + %span{class: "label #{label_css_class(label.name)}"}
31 31 %i.icon-tag
32 32 = label.name
33 33  
... ...
lib/gitlab/labels.rb 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +module Gitlab
  2 + class Labels
  3 + class << self
  4 + def important_labels
  5 + %w(bug critical confirmed)
  6 + end
  7 +
  8 + def warning_labels
  9 + %w(documentation support)
  10 + end
  11 +
  12 + def neutral_labels
  13 + %w(discussion suggestion)
  14 + end
  15 +
  16 + def positive_labels
  17 + %w(feature enhancement)
  18 + end
  19 +
  20 + def self.generate(project)
  21 + labels = important_labels + warning_labels + neutral_labels + positive_labels
  22 +
  23 + labels.each do |label_name|
  24 + # create tag for project
  25 + end
  26 + end
  27 + end
  28 + end
  29 +end
... ...