From: Dmitriy Zaporozhets Date: Tue, 7 May 2013 14:57:59 +0000 (+0300) Subject: add Gitlab::Label class and different color labels for default labels set X-Git-Tag: v5.2.0~80^2~2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=be68cc461755752697642c58154781ae4ec9ab31;p=wvm%2Fgitlab.git add Gitlab::Label class and different color labels for default labels set --- diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 70ebbdd37..ab4ffa855 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -88,4 +88,19 @@ module IssuesHelper "" end end + + def label_css_class(name) + case name + when *warning_labels + 'label-warning' + when *neutral_labels + 'label-inverse' + when *positive_labels + 'label-success' + when *important_labels + 'label-important' + else + 'label-info' + end + end end diff --git a/app/views/issues/_issue.html.haml b/app/views/issues/_issue.html.haml index 6c6d45e98..f44c0a6c8 100644 --- a/app/views/issues/_issue.html.haml +++ b/app/views/issues/_issue.html.haml @@ -27,7 +27,7 @@ .issue-labels - issue.labels.each do |label| - %span.label.label-info + %span{class: "label #{label_css_class(label.name)}"} %i.icon-tag = label.name diff --git a/lib/gitlab/labels.rb b/lib/gitlab/labels.rb new file mode 100644 index 000000000..f53223ce6 --- /dev/null +++ b/lib/gitlab/labels.rb @@ -0,0 +1,29 @@ +module Gitlab + class Labels + class << self + def important_labels + %w(bug critical confirmed) + end + + def warning_labels + %w(documentation support) + end + + def neutral_labels + %w(discussion suggestion) + end + + def positive_labels + %w(feature enhancement) + end + + def self.generate(project) + labels = important_labels + warning_labels + neutral_labels + positive_labels + + labels.each do |label_name| + # create tag for project + end + end + end + end +end