Commit 133d78229ec092cb5360d600b62286c7320869ff

Authored by Dmitriy Zaporozhets
1 parent edf41005

Dashboard -> projects -> filtering by project label

app/assets/stylesheets/gitlab_bootstrap/lists.scss
... ... @@ -69,5 +69,14 @@ ul.bordered-list {
69 69 display: block;
70 70 margin: 0px;
71 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 34 @projects
35 35 end
36 36  
  37 + @projects = @projects.tagged_with(params[:label]) if params[:label].present?
37 38 @projects = @projects.search(params[:search]) if params[:search].present?
38 39 @projects = @projects.page(params[:page]).per(30)
39 40 end
... ...
app/helpers/projects_helper.rb
... ... @@ -3,6 +3,10 @@ module ProjectsHelper
3 3 "You are going to remove #{user.name} from #{project.name} project team. Are you sure?"
4 4 end
5 5  
  6 + def projects_labels
  7 + Project.tag_counts_on(:labels).map(&:name)
  8 + end
  9 +
6 10 def link_to_project project
7 11 link_to project do
8 12 title = content_tag(:strong, project.name)
... ...
app/views/dashboard/projects.html.haml
... ... @@ -20,6 +20,15 @@
20 20 = nav_tab :scope, 'joined' do
21 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 32 .span9
24 33 = form_tag projects_dashboard_path, method: 'get' do
25 34 %fieldset.dashboard-search-filter
... ...