Commit 68a317808f90c0e5685dfd91abf5604f5012ab01

Authored by Dmitriy Zaporozhets
2 parents 880cb8aa 133d7822

Merge branch 'feature/project_labels' of /home/git/repositories/gitlab/gitlabhq

app/assets/stylesheets/gitlab_bootstrap/lists.scss
@@ -69,5 +69,14 @@ ul.bordered-list { @@ -69,5 +69,14 @@ ul.bordered-list {
69 display: block; 69 display: block;
70 margin: 0px; 70 margin: 0px;
71 &:last-child { border:none } 71 &:last-child { border:none }
  72 +
  73 + &.active {
  74 + background: #f9f9f9;
  75 + a { font-weight: bold; }
  76 + }
  77 +
  78 + &.light {
  79 + a { color: #777; }
  80 + }
72 } 81 }
73 } 82 }
app/controllers/dashboard_controller.rb
@@ -34,6 +34,7 @@ class DashboardController < ApplicationController @@ -34,6 +34,7 @@ class DashboardController < ApplicationController
34 @projects 34 @projects
35 end 35 end
36 36
  37 + @projects = @projects.tagged_with(params[:label]) if params[:label].present?
37 @projects = @projects.search(params[:search]) if params[:search].present? 38 @projects = @projects.search(params[:search]) if params[:search].present?
38 @projects = @projects.page(params[:page]).per(30) 39 @projects = @projects.page(params[:page]).per(30)
39 end 40 end
app/helpers/projects_helper.rb
@@ -3,6 +3,10 @@ module ProjectsHelper @@ -3,6 +3,10 @@ module ProjectsHelper
3 "You are going to remove #{user.name} from #{project.name} project team. Are you sure?" 3 "You are going to remove #{user.name} from #{project.name} project team. Are you sure?"
4 end 4 end
5 5
  6 + def projects_labels
  7 + Project.tag_counts_on(:labels).map(&:name)
  8 + end
  9 +
6 def link_to_project project 10 def link_to_project project
7 link_to project do 11 link_to project do
8 title = content_tag(:strong, project.name) 12 title = content_tag(:strong, project.name)
app/models/project.rb
@@ -28,12 +28,14 @@ class Project < ActiveRecord::Base @@ -28,12 +28,14 @@ class Project < ActiveRecord::Base
28 include Gitlab::ShellAdapter 28 include Gitlab::ShellAdapter
29 extend Enumerize 29 extend Enumerize
30 30
31 - attr_accessible :name, :path, :description, :default_branch, :issues_tracker, 31 + attr_accessible :name, :path, :description, :default_branch, :issues_tracker, :label_list,
32 :issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id, 32 :issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id,
33 :wiki_enabled, :public, :import_url, :last_activity_at, as: [:default, :admin] 33 :wiki_enabled, :public, :import_url, :last_activity_at, as: [:default, :admin]
34 34
35 attr_accessible :namespace_id, :creator_id, as: :admin 35 attr_accessible :namespace_id, :creator_id, as: :admin
36 36
  37 + acts_as_taggable_on :labels
  38 +
37 attr_accessor :import_url 39 attr_accessor :import_url
38 40
39 # Relations 41 # Relations
app/views/dashboard/projects.html.haml
@@ -20,6 +20,15 @@ @@ -20,6 +20,15 @@
20 = nav_tab :scope, 'joined' do 20 = nav_tab :scope, 'joined' do
21 = link_to "Joined", projects_dashboard_path(scope: 'joined') 21 = link_to "Joined", projects_dashboard_path(scope: 'joined')
22 22
  23 + %p.light Filter by label:
  24 + %ul.bordered-list
  25 + - projects_labels.each do |label|
  26 + %li{ class: (label == params[:label]) ? 'active' : 'light' }
  27 + = link_to projects_dashboard_path(scope: params[:scope], label: label) do
  28 + %i.icon-tag
  29 + = label
  30 +
  31 +
23 .span9 32 .span9
24 = form_tag projects_dashboard_path, method: 'get' do 33 = form_tag projects_dashboard_path, method: 'get' do
25 %fieldset.dashboard-search-filter 34 %fieldset.dashboard-search-filter
@@ -49,6 +58,10 @@ @@ -49,6 +58,10 @@
49 .left 58 .left
50 - if project.description.present? 59 - if project.description.present?
51 %span.light= project.description 60 %span.light= project.description
  61 + - project.labels.each do |label|
  62 + %span.label.label-info
  63 + %i.icon-tag
  64 + = label.name
52 65
53 .pull-right.light 66 .pull-right.light
54 %small.light 67 %small.light
app/views/projects/_form.html.haml
@@ -59,6 +59,15 @@ @@ -59,6 +59,15 @@
59 59
60 %fieldset.features 60 %fieldset.features
61 %legend 61 %legend
  62 + Labels:
  63 + .control-group
  64 + = f.label :label_list, "Labels", class: 'control-label'
  65 + .controls
  66 + = f.text_field :label_list, maxlength: 2000, class: "xxlarge"
  67 + %p.hint Separate with comma.
  68 +
  69 + %fieldset.features
  70 + %legend
62 Features: 71 Features:
63 .control-group 72 .control-group
64 = f.label :issues_enabled, "Issues", class: 'control-label' 73 = f.label :issues_enabled, "Issues", class: 'control-label'