Commit f9eda9b3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Group filtering on dashboard

parent d6363e93
......@@ -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
......@@ -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"
......
.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
.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"
......@@ -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
......
!!! 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
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