Commit c38b9a2f80111f8074f8e6ce36e63d68f519c581
1 parent
a03f3189
Exists in
master
and in
4 other branches
Filter projects on dashboard
Showing
5 changed files
with
46 additions
and
0 deletions
Show diff stats
app/assets/stylesheets/gitlab_bootstrap/common.scss
... | ... | @@ -100,3 +100,17 @@ input[type='search'].search-text-input { |
100 | 100 | } |
101 | 101 | |
102 | 102 | fieldset legend { font-size: 17px; } |
103 | + | |
104 | +ul.nav.nav-projects-tabs { | |
105 | + @extend .nav-tabs; | |
106 | + | |
107 | + padding-left: 8px; | |
108 | + | |
109 | + li { | |
110 | + a { | |
111 | + padding: 4px 20px; | |
112 | + margin-top: 2px; | |
113 | + border-color: #DDD; | |
114 | + } | |
115 | + } | |
116 | +} | ... | ... |
app/controllers/dashboard_controller.rb
... | ... | @@ -7,6 +7,15 @@ class DashboardController < ApplicationController |
7 | 7 | def index |
8 | 8 | @groups = current_user.authorized_groups |
9 | 9 | |
10 | + @projects = case params[:scope] | |
11 | + when 'personal' then | |
12 | + @projects.personal(current_user) | |
13 | + when 'joined' then | |
14 | + @projects.joined(current_user) | |
15 | + else | |
16 | + @projects | |
17 | + end | |
18 | + | |
10 | 19 | @projects = @projects.page(params[:page]).per(30) |
11 | 20 | |
12 | 21 | @events = Event.in_projects(current_user.project_ids) | ... | ... |
app/helpers/tab_helper.rb
... | ... | @@ -84,4 +84,17 @@ module TabHelper |
84 | 84 | 'active' |
85 | 85 | end |
86 | 86 | end |
87 | + | |
88 | + # Use nav_tab for save controller/action but different params | |
89 | + def nav_tab key, value, &block | |
90 | + o = {} | |
91 | + o[:class] = "" | |
92 | + o[:class] << " active" if params[key] == value | |
93 | + | |
94 | + if block_given? | |
95 | + content_tag(:li, capture(&block), o) | |
96 | + else | |
97 | + content_tag(:li, nil, o) | |
98 | + end | |
99 | + end | |
87 | 100 | end | ... | ... |
app/models/project.rb
... | ... | @@ -74,6 +74,8 @@ class Project < ActiveRecord::Base |
74 | 74 | scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) } |
75 | 75 | scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } |
76 | 76 | scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") } |
77 | + scope :personal, ->(user) { where(namespace_id: user.namespace_id) } | |
78 | + scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } | |
77 | 79 | |
78 | 80 | class << self |
79 | 81 | def authorized_for user | ... | ... |
app/views/dashboard/_projects.html.haml
... | ... | @@ -8,6 +8,14 @@ |
8 | 8 | = link_to new_project_path, class: "btn very_small info" do |
9 | 9 | %i.icon-plus |
10 | 10 | New Project |
11 | + %ul.nav.nav-projects-tabs | |
12 | + = nav_tab :scope, nil do | |
13 | + = link_to "All", dashboard_path | |
14 | + = nav_tab :scope, 'personal' do | |
15 | + = link_to "Personal", dashboard_path(scope: 'personal') | |
16 | + = nav_tab :scope, 'joined' do | |
17 | + = link_to "Joined", dashboard_path(scope: 'joined') | |
18 | + | |
11 | 19 | %ul.unstyled |
12 | 20 | - projects.each do |project| |
13 | 21 | %li.wll | ... | ... |