Commit bd3b677b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add projects page to dashboard. Remove projects pagination on dashboard

parent b68bba44
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
......
......@@ -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
%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"
......@@ -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
......
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment