Group filtering on dashboard

This commit is contained in:
Dmitriy Zaporozhets 2012-10-02 19:37:53 +03:00
parent d6363e9359
commit f9eda9b33a
6 changed files with 83 additions and 26 deletions

View file

@ -2,12 +2,22 @@ class DashboardController < ApplicationController
respond_to :html
def index
@projects = current_user.projects_with_events.page(params[:page]).per(40)
@groups = Group.where(id: current_user.projects.pluck(:group_id))
@projects = current_user.projects_with_events
if params[:group].present?
@group = Group.find_by_code(params[:group])
@projects = @projects.where(group_id: @group.id)
end
@projects = @projects.page(params[:page]).per(40)
@events = Event.recent_for_user(current_user).limit(20).offset(params[:offset] || 0)
@last_push = current_user.recent_push
respond_to do |format|
format.html
format.html { render 'index', layout: determine_layout }
format.js
format.atom { render layout: false }
end
@ -31,4 +41,10 @@ class DashboardController < ApplicationController
format.atom { render layout: false }
end
end
protected
def determine_layout
@group ? 'group' : 'application'
end
end

View file

@ -9,7 +9,7 @@
%table
%thead
%th Name
%th Path
%th Code
%th Projects
%th Edit
%th.cred Danger Zone!
@ -17,7 +17,7 @@
- @groups.each do |group|
%tr
%td= link_to group.name, [:admin, group]
%td= group.path
%td= group.code
%td= group.projects.count
%td= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small"
%td.bgred= link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn small danger"

View file

@ -0,0 +1,15 @@
.projects_box
%h5
Groups
%small
(#{groups.count})
%ul.unstyled
- groups.each do |group|
%li.wll
= link_to dashboard_path(group: group), class: dom_class(group) do
%strong.group_name= truncate(group.name, length: 25)
%span.arrow
&rarr;
%span.last_activity
%strong Projects:
%span= group.projects.count

View file

@ -0,0 +1,21 @@
.projects_box
%h5
Projects
%small
(#{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
%ul.unstyled
- projects.each do |project|
%li.wll
= link_to project_path(project), class: dom_class(project) do
%strong.project_name= truncate(project.name, length: 25)
%span.arrow
&rarr;
%span.last_activity
%strong Last activity:
%span= project_last_activity(project)
.bottom= paginate projects, theme: "gitlab"

View file

@ -9,28 +9,9 @@
.loading.hide
.side
= render "events/event_last_push", event: @last_push
.projects_box
%h5
Projects
%small
(#{@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
%ul.unstyled
- @projects.each do |project|
%li.wll
= link_to project_path(project), class: dom_class(project) do
%strong.project_name= truncate(project.name, length: 25)
%span.arrow
&rarr;
%span.last_activity
%strong Last activity:
%span= project_last_activity(project)
.bottom= paginate @projects, theme: "gitlab"
- unless @group
= render "groups", groups: @groups
= render "projects", projects: @projects
%div
%span.rss-icon
= link_to dashboard_path(:atom, { private_token: current_user.private_token }) do

View file

@ -0,0 +1,24 @@
!!! 5
%html{ lang: "en"}
= render "layouts/head"
%body{class: "#{app_theme} application"}
= render "layouts/flash"
= render "layouts/head_panel", title: "#{@group.name}:Dashboard"
.container
%ul.main_menu
= nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do
= link_to "Home", root_path, title: "Home"
= nav_link(path: 'dashboard#issues') do
= link_to dashboard_issues_path(group: @group) do
Issues
%span.count= current_user.assigned_issues.opened.count
= nav_link(path: 'dashboard#merge_requests') do
= link_to dashboard_merge_requests_path(group: @group) do
Merge Requests
%span.count= current_user.cared_merge_requests.count
= nav_link(path: 'search#show') do
= link_to "People", "#"
= nav_link(path: 'help#index') do
= link_to "Help", help_path
.content= yield