Commit bd3b677b86d7c76788420e94862836343ac5c841
1 parent
b68bba44
Exists in
master
and in
4 other branches
Add projects page to dashboard. Remove projects pagination on dashboard
Showing
5 changed files
with
71 additions
and
24 deletions
Show diff stats
app/controllers/dashboard_controller.rb
1 | 1 | class DashboardController < ApplicationController |
2 | 2 | respond_to :html |
3 | 3 | |
4 | - before_filter :projects | |
4 | + before_filter :load_projects | |
5 | 5 | before_filter :event_filter, only: :index |
6 | 6 | |
7 | 7 | def index |
8 | 8 | @groups = current_user.authorized_groups |
9 | - | |
10 | 9 | @has_authorized_projects = @projects.count > 0 |
11 | - | |
12 | - @projects = case params[:scope] | |
13 | - when 'personal' then | |
14 | - @projects.personal(current_user) | |
15 | - when 'joined' then | |
16 | - @projects.joined(current_user) | |
17 | - else | |
18 | - @projects | |
19 | - end | |
20 | - | |
21 | 10 | @teams = current_user.authorized_teams |
22 | - | |
23 | - @projects = @projects.page(params[:page]).per(30) | |
11 | + @projects_count = @projects.count | |
12 | + @projects = @projects.limit(20) | |
24 | 13 | |
25 | 14 | @events = Event.in_projects(current_user.authorized_projects.pluck(:id)) |
26 | 15 | @events = @event_filter.apply_filter(@events) |
... | ... | @@ -35,6 +24,19 @@ class DashboardController < ApplicationController |
35 | 24 | end |
36 | 25 | end |
37 | 26 | |
27 | + def projects | |
28 | + @projects = case params[:scope] | |
29 | + when 'personal' then | |
30 | + @projects.personal(current_user) | |
31 | + when 'joined' then | |
32 | + @projects.joined(current_user) | |
33 | + else | |
34 | + @projects | |
35 | + end | |
36 | + | |
37 | + @projects = @projects.page(params[:page]).per(30) | |
38 | + end | |
39 | + | |
38 | 40 | # Get authored or assigned open merge requests |
39 | 41 | def merge_requests |
40 | 42 | @merge_requests = current_user.cared_merge_requests |
... | ... | @@ -57,7 +59,7 @@ class DashboardController < ApplicationController |
57 | 59 | |
58 | 60 | protected |
59 | 61 | |
60 | - def projects | |
62 | + def load_projects | |
61 | 63 | @projects = current_user.authorized_projects.sorted_by_activity |
62 | 64 | end |
63 | 65 | ... | ... |
app/views/dashboard/_projects.html.haml
... | ... | @@ -2,19 +2,12 @@ |
2 | 2 | %h5.title |
3 | 3 | Projects |
4 | 4 | %small |
5 | - (#{projects.total_count}) | |
5 | + (#{@projects_count}) | |
6 | 6 | - if current_user.can_create_project? |
7 | 7 | %span.right |
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 | 12 | %ul.well-list |
20 | 13 | - projects.each do |project| |
... | ... | @@ -33,4 +26,6 @@ |
33 | 26 | - if projects.blank? |
34 | 27 | %li |
35 | 28 | %h3.nothing_here_message There are no projects here. |
36 | - .bottom= paginate projects, theme: "gitlab" | |
29 | + - if @projects_count > 20 | |
30 | + %li.bottom | |
31 | + %strong= link_to "show all projects", dashboard_projects_path | ... | ... |
... | ... | @@ -0,0 +1,46 @@ |
1 | +%h3.page_title | |
2 | + Projects | |
3 | + %span | |
4 | + (#{@projects.total_count}) | |
5 | + - if current_user.can_create_project? | |
6 | + %span.right | |
7 | + = link_to new_project_path, class: "btn very_small info" do | |
8 | + %i.icon-plus | |
9 | + New Project | |
10 | + | |
11 | +%hr | |
12 | +.row | |
13 | + .span3 | |
14 | + %ul.nav.nav-pills.nav-stacked | |
15 | + = nav_tab :scope, nil do | |
16 | + = link_to "All", dashboard_projects_path | |
17 | + = nav_tab :scope, 'personal' do | |
18 | + = link_to "Personal", dashboard_projects_path(scope: 'personal') | |
19 | + = nav_tab :scope, 'joined' do | |
20 | + = link_to "Joined", dashboard_projects_path(scope: 'joined') | |
21 | + | |
22 | + .span9 | |
23 | + = form_tag dashboard_projects_path, method: 'get' do | |
24 | + %fieldset.dashboard-search-filter | |
25 | + = hidden_field_tag "scope", params[:scope] | |
26 | + = search_field_tag "search", params[:search], { placeholder: 'Search', class: 'left input-xxlarge' } | |
27 | + = button_tag type: 'submit', class: 'btn' do | |
28 | + %i.icon-search | |
29 | + | |
30 | + %ul.well-list | |
31 | + - @projects.each do |project| | |
32 | + %li | |
33 | + = link_to project_path(project), class: dom_class(project) do | |
34 | + - if project.namespace | |
35 | + = project.namespace.human_name | |
36 | + \/ | |
37 | + %strong.well-title | |
38 | + = truncate(project.name, length: 25) | |
39 | + %span.right.light | |
40 | + %strong Last activity: | |
41 | + %span= project_last_activity(project) | |
42 | + - if @projects.blank? | |
43 | + %li | |
44 | + %h3.nothing_here_message There are no projects here. | |
45 | + .bottom= paginate @projects, theme: "gitlab" | |
46 | + | ... | ... |
app/views/layouts/application.html.haml
... | ... | @@ -8,6 +8,9 @@ |
8 | 8 | %ul.main_menu |
9 | 9 | = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do |
10 | 10 | = link_to "Home", root_path, title: "Home" |
11 | + = nav_link(path: 'dashboard#projects') do | |
12 | + = link_to dashboard_projects_path do | |
13 | + Projects | |
11 | 14 | = nav_link(path: 'dashboard#issues') do |
12 | 15 | = link_to dashboard_issues_path do |
13 | 16 | Issues | ... | ... |
config/routes.rb
... | ... | @@ -119,6 +119,7 @@ Gitlab::Application.routes.draw do |
119 | 119 | # Dashboard Area |
120 | 120 | # |
121 | 121 | get "dashboard" => "dashboard#index" |
122 | + get "dashboard/projects" => "dashboard#projects" | |
122 | 123 | get "dashboard/issues" => "dashboard#issues" |
123 | 124 | get "dashboard/merge_requests" => "dashboard#merge_requests" |
124 | 125 | ... | ... |