From be68cc461755752697642c58154781ae4ec9ab31 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 7 May 2013 17:57:59 +0300 Subject: [PATCH] add Gitlab::Label class and different color labels for default labels set --- app/helpers/issues_helper.rb | 15 +++++++++++++++ app/views/issues/_issue.html.haml | 2 +- lib/gitlab/labels.rb | 29 +++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 lib/gitlab/labels.rb diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 70ebbdd..ab4ffa8 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 6c6d45e..f44c0a6 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 0000000..f53223c --- /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 -- libgit2 0.21.2