Merge branch 'feature/labels_set' of /home/git/repositories/gitlab/gitlabhq
This commit is contained in:
commit
71647fd579
11 changed files with 94 additions and 30 deletions
|
@ -7,7 +7,13 @@ class LabelsController < ProjectResourceController
|
|||
respond_to :js, :html
|
||||
|
||||
def index
|
||||
@labels = @project.issues_labels.order('count DESC')
|
||||
@labels = @project.issues_labels
|
||||
end
|
||||
|
||||
def generate
|
||||
Gitlab::IssuesLabels.generate(@project)
|
||||
|
||||
redirect_to project_labels_path(@project)
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -11,10 +11,6 @@ module IssuesHelper
|
|||
classes
|
||||
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>
|
||||
# to allow filtering issues by an unassigned User or Milestone
|
||||
def unassigned_filter
|
||||
|
@ -32,12 +28,6 @@ module IssuesHelper
|
|||
}
|
||||
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
|
||||
@project.milestones.active.order("id desc").all
|
||||
end
|
||||
|
|
28
app/helpers/labels_helper.rb
Normal file
28
app/helpers/labels_helper.rb
Normal file
|
@ -0,0 +1,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
|
|
@ -34,7 +34,7 @@ class Project < ActiveRecord::Base
|
|||
|
||||
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
|
||||
|
||||
|
@ -204,7 +204,7 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def issues_labels
|
||||
issues.tag_counts_on(:labels)
|
||||
@issues_labels ||= (issues_default_labels + issues.tags_on(:labels)).uniq.sort_by(&:name)
|
||||
end
|
||||
|
||||
def issue_exists?(issue_id)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
.pull-right
|
||||
- @issue.labels.each do |label|
|
||||
%span.label
|
||||
%span{class: "label #{label_css_class(label.name)}"}
|
||||
%i.icon-tag
|
||||
= label.name
|
||||
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
- frequency = @project.issues.tagged_with(label.name).count
|
||||
%li
|
||||
%strong
|
||||
%i.icon-tag
|
||||
= label.name
|
||||
%span{class: "label #{label_css_class(label.name)}"}
|
||||
%i.icon-tag
|
||||
- if frequency.zero?
|
||||
%span.light= label.name
|
||||
- else
|
||||
= label.name
|
||||
.pull-right
|
||||
= link_to project_issues_path(label_name: label.name) do
|
||||
%strong
|
||||
= pluralize(label.count, 'issue')
|
||||
= "»"
|
||||
- unless frequency.zero?
|
||||
= link_to project_issues_path(label_name: label.name) do
|
||||
%strong
|
||||
= pluralize(frequency, 'issue')
|
||||
= "»"
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
%h3.page_title
|
||||
Labels
|
||||
%br
|
||||
%div.ui-box
|
||||
%ul.well-list.labels-table
|
||||
|
||||
- if @labels.present?
|
||||
%ul.bordered-list.labels-table
|
||||
- @labels.each do |label|
|
||||
= render 'label', label: label
|
||||
|
||||
- unless @labels.present?
|
||||
%li
|
||||
%h3.nothing_here_message Nothing to show here
|
||||
|
||||
- else
|
||||
.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
|
||||
|
|
|
@ -269,7 +269,13 @@ Gitlab::Application.routes.draw do
|
|||
|
||||
resources :team, controller: 'team_members', only: [:index]
|
||||
resources :milestones, except: [:destroy]
|
||||
resources :labels, only: [:index]
|
||||
|
||||
resources :labels, only: [:index] do
|
||||
collection do
|
||||
post :generate
|
||||
end
|
||||
end
|
||||
|
||||
resources :issues, except: [:destroy] do
|
||||
collection do
|
||||
post :bulk_update
|
||||
|
|
28
lib/gitlab/issues_labels.rb
Normal file
28
lib/gitlab/issues_labels.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
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)
|
||||
labels = important_labels + warning_labels + neutral_labels + positive_labels
|
||||
|
||||
project.issues_default_label_list = labels
|
||||
project.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -485,9 +485,9 @@ describe Gitlab::API do
|
|||
response.status.should == 200
|
||||
end
|
||||
|
||||
it "should return a 400 error if hook id not given" do
|
||||
it "should return a 405 error if hook id not given" do
|
||||
delete api("/projects/#{project.id}/hooks", user)
|
||||
response.status.should == 400
|
||||
response.status.should == 405
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue