Add projects page to dashboard. Remove projects pagination on dashboard
This commit is contained in:
parent
b68bba441e
commit
bd3b677b86
5 changed files with 71 additions and 24 deletions
|
@ -1,26 +1,15 @@
|
||||||
class DashboardController < ApplicationController
|
class DashboardController < ApplicationController
|
||||||
respond_to :html
|
respond_to :html
|
||||||
|
|
||||||
before_filter :projects
|
before_filter :load_projects
|
||||||
before_filter :event_filter, only: :index
|
before_filter :event_filter, only: :index
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@groups = current_user.authorized_groups
|
@groups = current_user.authorized_groups
|
||||||
|
|
||||||
@has_authorized_projects = @projects.count > 0
|
@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
|
@teams = current_user.authorized_teams
|
||||||
|
@projects_count = @projects.count
|
||||||
@projects = @projects.page(params[:page]).per(30)
|
@projects = @projects.limit(20)
|
||||||
|
|
||||||
@events = Event.in_projects(current_user.authorized_projects.pluck(:id))
|
@events = Event.in_projects(current_user.authorized_projects.pluck(:id))
|
||||||
@events = @event_filter.apply_filter(@events)
|
@events = @event_filter.apply_filter(@events)
|
||||||
|
@ -35,6 +24,19 @@ class DashboardController < ApplicationController
|
||||||
end
|
end
|
||||||
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
|
# Get authored or assigned open merge requests
|
||||||
def merge_requests
|
def merge_requests
|
||||||
@merge_requests = current_user.cared_merge_requests
|
@merge_requests = current_user.cared_merge_requests
|
||||||
|
@ -57,7 +59,7 @@ class DashboardController < ApplicationController
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def projects
|
def load_projects
|
||||||
@projects = current_user.authorized_projects.sorted_by_activity
|
@projects = current_user.authorized_projects.sorted_by_activity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,19 +2,12 @@
|
||||||
%h5.title
|
%h5.title
|
||||||
Projects
|
Projects
|
||||||
%small
|
%small
|
||||||
(#{projects.total_count})
|
(#{@projects_count})
|
||||||
- if current_user.can_create_project?
|
- if current_user.can_create_project?
|
||||||
%span.right
|
%span.right
|
||||||
= link_to new_project_path, class: "btn very_small info" do
|
= link_to new_project_path, class: "btn very_small info" do
|
||||||
%i.icon-plus
|
%i.icon-plus
|
||||||
New Project
|
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
|
%ul.well-list
|
||||||
- projects.each do |project|
|
- projects.each do |project|
|
||||||
|
@ -33,4 +26,6 @@
|
||||||
- if projects.blank?
|
- if projects.blank?
|
||||||
%li
|
%li
|
||||||
%h3.nothing_here_message There are no projects here.
|
%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
|
||||||
|
|
46
app/views/dashboard/projects.html.haml
Normal file
46
app/views/dashboard/projects.html.haml
Normal file
|
@ -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"
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
%ul.main_menu
|
%ul.main_menu
|
||||||
= nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do
|
= nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do
|
||||||
= link_to "Home", root_path, title: "Home"
|
= 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
|
= nav_link(path: 'dashboard#issues') do
|
||||||
= link_to dashboard_issues_path do
|
= link_to dashboard_issues_path do
|
||||||
Issues
|
Issues
|
||||||
|
|
|
@ -119,6 +119,7 @@ Gitlab::Application.routes.draw do
|
||||||
# Dashboard Area
|
# Dashboard Area
|
||||||
#
|
#
|
||||||
get "dashboard" => "dashboard#index"
|
get "dashboard" => "dashboard#index"
|
||||||
|
get "dashboard/projects" => "dashboard#projects"
|
||||||
get "dashboard/issues" => "dashboard#issues"
|
get "dashboard/issues" => "dashboard#issues"
|
||||||
get "dashboard/merge_requests" => "dashboard#merge_requests"
|
get "dashboard/merge_requests" => "dashboard#merge_requests"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue