From bd3b677b86d7c76788420e94862836343ac5c841 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 27 Jan 2013 12:34:27 +0200 Subject: [PATCH] Add projects page to dashboard. Remove projects pagination on dashboard --- app/controllers/dashboard_controller.rb | 32 +++++++++-------- app/views/dashboard/_projects.html.haml | 13 +++---- app/views/dashboard/projects.html.haml | 46 +++++++++++++++++++++++++ app/views/layouts/application.html.haml | 3 ++ config/routes.rb | 1 + 5 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 app/views/dashboard/projects.html.haml diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 13b7f02f..13d80008 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,26 +1,15 @@ class DashboardController < ApplicationController respond_to :html - before_filter :projects + before_filter :load_projects before_filter :event_filter, only: :index def index @groups = current_user.authorized_groups - @has_authorized_projects = @projects.count > 0 - - @projects = case params[:scope] - when 'personal' then - @projects.personal(current_user) - when 'joined' then - @projects.joined(current_user) - else - @projects - end - @teams = current_user.authorized_teams - - @projects = @projects.page(params[:page]).per(30) + @projects_count = @projects.count + @projects = @projects.limit(20) @events = Event.in_projects(current_user.authorized_projects.pluck(:id)) @events = @event_filter.apply_filter(@events) @@ -35,6 +24,19 @@ class DashboardController < ApplicationController end end + def projects + @projects = case params[:scope] + when 'personal' then + @projects.personal(current_user) + when 'joined' then + @projects.joined(current_user) + else + @projects + end + + @projects = @projects.page(params[:page]).per(30) + end + # Get authored or assigned open merge requests def merge_requests @merge_requests = current_user.cared_merge_requests @@ -57,7 +59,7 @@ class DashboardController < ApplicationController protected - def projects + def load_projects @projects = current_user.authorized_projects.sorted_by_activity end diff --git a/app/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml index 6c1304ee..d7273fdc 100644 --- a/app/views/dashboard/_projects.html.haml +++ b/app/views/dashboard/_projects.html.haml @@ -2,19 +2,12 @@ %h5.title Projects %small - (#{projects.total_count}) + (#{@projects_count}) - if current_user.can_create_project? %span.right = link_to new_project_path, class: "btn very_small info" do %i.icon-plus New Project - %ul.nav.nav-projects-tabs - = nav_tab :scope, nil do - = link_to "All", dashboard_path - = nav_tab :scope, 'personal' do - = link_to "Personal", dashboard_path(scope: 'personal') - = nav_tab :scope, 'joined' do - = link_to "Joined", dashboard_path(scope: 'joined') %ul.well-list - projects.each do |project| @@ -33,4 +26,6 @@ - if projects.blank? %li %h3.nothing_here_message There are no projects here. - .bottom= paginate projects, theme: "gitlab" + - if @projects_count > 20 + %li.bottom + %strong= link_to "show all projects", dashboard_projects_path diff --git a/app/views/dashboard/projects.html.haml b/app/views/dashboard/projects.html.haml new file mode 100644 index 00000000..cfbb332a --- /dev/null +++ b/app/views/dashboard/projects.html.haml @@ -0,0 +1,46 @@ +%h3.page_title + Projects + %span + (#{@projects.total_count}) + - if current_user.can_create_project? + %span.right + = link_to new_project_path, class: "btn very_small info" do + %i.icon-plus + New Project + +%hr +.row + .span3 + %ul.nav.nav-pills.nav-stacked + = nav_tab :scope, nil do + = link_to "All", dashboard_projects_path + = nav_tab :scope, 'personal' do + = link_to "Personal", dashboard_projects_path(scope: 'personal') + = nav_tab :scope, 'joined' do + = link_to "Joined", dashboard_projects_path(scope: 'joined') + + .span9 + = form_tag dashboard_projects_path, method: 'get' do + %fieldset.dashboard-search-filter + = hidden_field_tag "scope", params[:scope] + = search_field_tag "search", params[:search], { placeholder: 'Search', class: 'left input-xxlarge' } + = button_tag type: 'submit', class: 'btn' do + %i.icon-search + + %ul.well-list + - @projects.each do |project| + %li + = link_to project_path(project), class: dom_class(project) do + - if project.namespace + = project.namespace.human_name + \/ + %strong.well-title + = truncate(project.name, length: 25) + %span.right.light + %strong Last activity: + %span= project_last_activity(project) + - if @projects.blank? + %li + %h3.nothing_here_message There are no projects here. + .bottom= paginate @projects, theme: "gitlab" + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 88da5c98..0a83be3f 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,6 +8,9 @@ %ul.main_menu = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do = link_to "Home", root_path, title: "Home" + = nav_link(path: 'dashboard#projects') do + = link_to dashboard_projects_path do + Projects = nav_link(path: 'dashboard#issues') do = link_to dashboard_issues_path do Issues diff --git a/config/routes.rb b/config/routes.rb index 5ae4c808..6bbcf49a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -119,6 +119,7 @@ Gitlab::Application.routes.draw do # Dashboard Area # get "dashboard" => "dashboard#index" + get "dashboard/projects" => "dashboard#projects" get "dashboard/issues" => "dashboard#issues" get "dashboard/merge_requests" => "dashboard#merge_requests"