labels_helper.rb 597 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module LabelsHelper
  def issue_tags
    @project.issues.tag_counts_on(:labels).map(&:name)
  end

  def labels_autocomplete_source
    labels = @project.issues_labels
    labels = labels.map{ |l| { label: l.name, value: l.name } }
    labels.to_json
  end

  def label_css_class(name)
    klass = Gitlab::IssuesLabels

    case name
    when *klass.warning_labels
      'label-warning'
    when *klass.neutral_labels
      'label-inverse'
    when *klass.positive_labels
      'label-success'
    when *klass.important_labels
      'label-important'
    else
      'label-info'
    end
  end
end