Commit f9eda9b3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Group filtering on dashboard

parent d6363e93
...@@ -2,12 +2,22 @@ class DashboardController < ApplicationController ...@@ -2,12 +2,22 @@ class DashboardController < ApplicationController
respond_to :html respond_to :html
def index 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) @events = Event.recent_for_user(current_user).limit(20).offset(params[:offset] || 0)
@last_push = current_user.recent_push @last_push = current_user.recent_push
respond_to do |format| respond_to do |format|
format.html format.html { render 'index', layout: determine_layout }
format.js format.js
format.atom { render layout: false } format.atom { render layout: false }
end end
...@@ -31,4 +41,10 @@ class DashboardController < ApplicationController ...@@ -31,4 +41,10 @@ class DashboardController < ApplicationController
format.atom { render layout: false } format.atom { render layout: false }
end end
end end
protected
def determine_layout
@group ? 'group' : 'application'
end
end end
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
%table %table
%thead %thead
%th Name %th Name
%th Path %th Code
%th Projects %th Projects
%th Edit %th Edit
%th.cred Danger Zone! %th.cred Danger Zone!
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
- @groups.each do |group| - @groups.each do |group|
%tr %tr
%td= link_to group.name, [:admin, group] %td= link_to group.name, [:admin, group]
%td= group.path %td= group.code
%td= group.projects.count %td= group.projects.count
%td= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small" %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" %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 @@ ...@@ -9,28 +9,9 @@
.loading.hide .loading.hide
.side .side
= render "events/event_last_push", event: @last_push = render "events/event_last_push", event: @last_push
.projects_box - unless @group
%h5 = render "groups", groups: @groups
Projects = render "projects", projects: @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"
%div %div
%span.rss-icon %span.rss-icon
= link_to dashboard_path(:atom, { private_token: current_user.private_token }) do = 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