diff options
-rw-r--r-- | app/controllers/projects/labels_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/labels_helper.rb | 30 | ||||
-rw-r--r-- | app/views/projects/issues/_issue.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/issues/show.html.haml | 5 | ||||
-rw-r--r-- | app/views/projects/merge_requests/_merge_request.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/merge_requests/show/_participants.html.haml | 5 | ||||
-rw-r--r-- | app/views/shared/_project_filter.html.haml | 22 | ||||
-rw-r--r-- | lib/gitlab/issues_labels.rb | 37 |
8 files changed, 44 insertions, 65 deletions
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 30fcb64cbb2..d2c5e90b257 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -6,7 +6,7 @@ class Projects::LabelsController < Projects::ApplicationController respond_to :js, :html def index - @labels = @project.issues_labels + @labels = @project.labels end def generate diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 7d72989cb3b..fce0ed6c5d6 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -1,28 +1,20 @@ module LabelsHelper - def issue_label_names + def project_label_names @project.labels.pluck(:title) end - def labels_autocomplete_source - labels = @project.labels - labels = labels.map { |l| { label: l.name, value: l.name } } - labels.to_json - end - - def label_css_class(name) - klass = Gitlab::IssuesLabels + def render_colored_label(label) + label_color = label.color || "#428bca" + r, g, b = label_color.slice(1,7).scan(/.{2}/).map(&:hex) - case name.downcase - when *klass.warning_labels - 'label-warning' - when *klass.neutral_labels - 'label-primary' - when *klass.positive_labels - 'label-success' - when *klass.important_labels - 'label-danger' + if (r + g + b) > 500 + text_color = "#333" else - 'label-info' + text_color = "#FFF" + end + + content_tag :span, class: 'label', style: "background:#{label_color};color:#{text_color}" do + label.name end end end diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml index 8d447da3ae9..db28b831182 100644 --- a/app/views/projects/issues/_issue.html.haml +++ b/app/views/projects/issues/_issue.html.haml @@ -31,9 +31,7 @@ .issue-labels - issue.labels.each do |label| - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - = label.name + = render_colored_label(label) .issue-actions - if can? current_user, :modify_issue, issue diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index 695eb225754..bd5f01ff6a7 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -68,9 +68,6 @@ .issue-show-labels.pull-right - @issue.labels.each do |label| - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - = label.name - + = render_colored_label(label) .voting_notes#notes= render "projects/notes/notes_with_form" diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index c9a80ec22ef..7f5de232dcf 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -34,6 +34,4 @@ .merge-request-labels - merge_request.labels.each do |label| - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - = label.name + = render_colored_label(label) diff --git a/app/views/projects/merge_requests/show/_participants.html.haml b/app/views/projects/merge_requests/show/_participants.html.haml index 0dabd965e52..007c111f7fb 100644 --- a/app/views/projects/merge_requests/show/_participants.html.haml +++ b/app/views/projects/merge_requests/show/_participants.html.haml @@ -5,7 +5,4 @@ .merge-request-show-labels.pull-right - @merge_request.labels.each do |label| - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - = label.name - + = render_colored_label(label) diff --git a/app/views/shared/_project_filter.html.haml b/app/views/shared/_project_filter.html.haml index 38cb1208cdc..21d45ebe806 100644 --- a/app/views/shared/_project_filter.html.haml +++ b/app/views/shared/_project_filter.html.haml @@ -36,21 +36,19 @@ %fieldset %legend Labels %ul.nav.nav-pills.nav-stacked.nav-small.labels-filter - - issue_label_names.each do |label_name| - %li{class: label_filter_class(label_name)} - = link_to labels_filter_path(label_name) do - %span{class: "label #{label_css_class(label_name)}"} - %i.icon-tag - = label_name - - if selected_label?(label_name) + - @project.labels.each do |label| + %li{class: label_filter_class(label.name)} + = link_to labels_filter_path(label.name) do + = render_colored_label(label) + - if selected_label?(label.name) .pull-right %i.icon-remove - - if issue_label_names.empty? - .light-well - Add first label to your issues - %br - or #{link_to 'generate', generate_project_labels_path(@project, redirect: redirect), method: :post} default set of labels + - if @project.labels.empty? + .light-well + Add first label to your issues + %br + or #{link_to 'generate', generate_project_labels_path(@project, redirect: redirect), method: :post} default set of labels %fieldset - if %w(state scope milestone_id assignee_id label_name).select { |k| params[k].present? }.any? diff --git a/lib/gitlab/issues_labels.rb b/lib/gitlab/issues_labels.rb index 9da1977a3d6..0d34976736f 100644 --- a/lib/gitlab/issues_labels.rb +++ b/lib/gitlab/issues_labels.rb @@ -1,27 +1,26 @@ module Gitlab class IssuesLabels 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 generate(project) - label_names = important_labels + warning_labels + neutral_labels + positive_labels + red = '#d9534f' + yellow = '#f0ad4e' + blue = '#428bca' + green = '#5cb85c' + + labels = [ + { title: "bug", color: red }, + { title: "critical", color: red }, + { title: "confirmed", color: red }, + { title: "documentation", color: yellow }, + { title: "support", color: yellow }, + { title: "discussion", color: blue }, + { title: "suggestion", color: blue }, + { title: "feature", color: green }, + { title: "enhancement", color: green } + ] - label_names.each do |label_name| - project.labels.create(title: label_name) + labels.each do |label| + project.labels.create(label) end end end |