This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

Commit 03441769 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Include default labels in issues autocomplete etc. Show colored labels on issues show page

parent 435fdc9d8f41
...@@ -7,11 +7,11 @@ class LabelsController < ProjectResourceController ...@@ -7,11 +7,11 @@ class LabelsController < ProjectResourceController
respond_to :js, :html respond_to :js, :html
def index def index
@labels = @project.issues_labels.order('count DESC') @labels = @project.issues_labels
end end
def generate def generate
Gitlab::Labels.generate(@project) Gitlab::IssuesLabels.generate(@project)
redirect_to project_labels_path(@project) redirect_to project_labels_path(@project)
end end
......
...@@ -11,10 +11,6 @@ def issue_css_classes issue ...@@ -11,10 +11,6 @@ def issue_css_classes issue
classes classes
end end
def issue_tags
@project.issues.tag_counts_on(:labels).map(&:name)
end
# Returns an OpenStruct object suitable for use by <tt>options_from_collection_for_select</tt> # Returns an OpenStruct object suitable for use by <tt>options_from_collection_for_select</tt>
# to allow filtering issues by an unassigned User or Milestone # to allow filtering issues by an unassigned User or Milestone
def unassigned_filter def unassigned_filter
...@@ -32,12 +28,6 @@ def issues_filter ...@@ -32,12 +28,6 @@ def issues_filter
} }
end end
def labels_autocomplete_source
labels = @project.issues_labels.order('count DESC')
labels = labels.map{ |l| { label: l.name, value: l.name } }
labels.to_json
end
def issues_active_milestones def issues_active_milestones
@project.milestones.active.order("id desc").all @project.milestones.active.order("id desc").all
end end
...@@ -88,19 +78,4 @@ def title_for_issue(issue_id) ...@@ -88,19 +78,4 @@ def title_for_issue(issue_id)
"" ""
end end
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 end
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
...@@ -34,7 +34,7 @@ class Project < ActiveRecord::Base ...@@ -34,7 +34,7 @@ class Project < ActiveRecord::Base
attr_accessible :namespace_id, :creator_id, as: :admin attr_accessible :namespace_id, :creator_id, as: :admin
acts_as_taggable_on :labels acts_as_taggable_on :labels, :issues_default_labels
attr_accessor :import_url attr_accessor :import_url
...@@ -204,7 +204,7 @@ def project_id ...@@ -204,7 +204,7 @@ def project_id
end end
def issues_labels def issues_labels
issues.tag_counts_on(:labels) @issues_labels ||= (issues_default_labels + issues.tags_on(:labels)).uniq.sort_by(&:name)
end end
def issue_exists?(issue_id) def issue_exists?(issue_id)
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
.pull-right .pull-right
- @issue.labels.each do |label| - @issue.labels.each do |label|
%span.label %span{class: "label #{label_css_class(label.name)}"}
%i.icon-tag %i.icon-tag
= label.name = label.name
&nbsp; &nbsp;
......
- frequency = @project.issues.tagged_with(label.name).count
%li %li
%strong %strong
%span{class: "label #{label_css_class(label.name)}"}
%i.icon-tag %i.icon-tag
- if frequency.zero?
%span.light= label.name
- else
= label.name = label.name
.pull-right .pull-right
- unless frequency.zero?
= link_to project_issues_path(label_name: label.name) do = link_to project_issues_path(label_name: label.name) do
%strong %strong
= pluralize(label.count, 'issue') = pluralize(frequency, 'issue')
= "»" = "»"
...@@ -4,12 +4,11 @@ ...@@ -4,12 +4,11 @@
Labels Labels
%br %br
.light-well - if @labels.present?
%ul.bordered-list.labels-table %ul.bordered-list.labels-table
- @labels.each do |label| - @labels.each do |label|
= render 'label', label: label = render 'label', label: label
- unless @labels.present? - else
%li .light-well
%h3.nothing_here_message Add first label to your issues or #{link_to 'generate', generate_project_labels_path(@project), method: :post} default set of labels %h3.nothing_here_message Add first label to your issues or #{link_to 'generate', generate_project_labels_path(@project), method: :post} default set of labels
module Gitlab module Gitlab
class Labels class IssuesLabels
class << self class << self
def important_labels def important_labels
%w(bug critical confirmed) %w(bug critical confirmed)
...@@ -17,12 +17,11 @@ def positive_labels ...@@ -17,12 +17,11 @@ def positive_labels
%w(feature enhancement) %w(feature enhancement)
end end
def self.generate(project) def generate(project)
labels = important_labels + warning_labels + neutral_labels + positive_labels labels = important_labels + warning_labels + neutral_labels + positive_labels
labels.each do |label_name| project.issues_default_label_list = labels
# create tag for project project.save
end
end end
end end
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment