Commit f9eda9b33a72cae91e51c5733fdf2c0d7b37d149
1 parent
d6363e93
Exists in
master
and in
4 other branches
Group filtering on dashboard
Showing
6 changed files
with
83 additions
and
26 deletions
Show diff stats
app/controllers/dashboard_controller.rb
... | ... | @@ -2,12 +2,22 @@ class DashboardController < ApplicationController |
2 | 2 | respond_to :html |
3 | 3 | |
4 | 4 | def index |
5 | - @projects = current_user.projects_with_events.page(params[:page]).per(40) | |
5 | + @groups = Group.where(id: current_user.projects.pluck(:group_id)) | |
6 | + | |
7 | + @projects = current_user.projects_with_events | |
8 | + | |
9 | + if params[:group].present? | |
10 | + @group = Group.find_by_code(params[:group]) | |
11 | + @projects = @projects.where(group_id: @group.id) | |
12 | + end | |
13 | + | |
14 | + @projects = @projects.page(params[:page]).per(40) | |
15 | + | |
6 | 16 | @events = Event.recent_for_user(current_user).limit(20).offset(params[:offset] || 0) |
7 | 17 | @last_push = current_user.recent_push |
8 | 18 | |
9 | 19 | respond_to do |format| |
10 | - format.html | |
20 | + format.html { render 'index', layout: determine_layout } | |
11 | 21 | format.js |
12 | 22 | format.atom { render layout: false } |
13 | 23 | end |
... | ... | @@ -31,4 +41,10 @@ class DashboardController < ApplicationController |
31 | 41 | format.atom { render layout: false } |
32 | 42 | end |
33 | 43 | end |
44 | + | |
45 | + protected | |
46 | + | |
47 | + def determine_layout | |
48 | + @group ? 'group' : 'application' | |
49 | + end | |
34 | 50 | end | ... | ... |
app/views/admin/groups/index.html.haml
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | %table |
10 | 10 | %thead |
11 | 11 | %th Name |
12 | - %th Path | |
12 | + %th Code | |
13 | 13 | %th Projects |
14 | 14 | %th Edit |
15 | 15 | %th.cred Danger Zone! |
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | - @groups.each do |group| |
18 | 18 | %tr |
19 | 19 | %td= link_to group.name, [:admin, group] |
20 | - %td= group.path | |
20 | + %td= group.code | |
21 | 21 | %td= group.projects.count |
22 | 22 | %td= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small" |
23 | 23 | %td.bgred= link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn small danger" | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +.projects_box | |
2 | + %h5 | |
3 | + Groups | |
4 | + %small | |
5 | + (#{groups.count}) | |
6 | + %ul.unstyled | |
7 | + - groups.each do |group| | |
8 | + %li.wll | |
9 | + = link_to dashboard_path(group: group), class: dom_class(group) do | |
10 | + %strong.group_name= truncate(group.name, length: 25) | |
11 | + %span.arrow | |
12 | + → | |
13 | + %span.last_activity | |
14 | + %strong Projects: | |
15 | + %span= group.projects.count | ... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +.projects_box | |
2 | + %h5 | |
3 | + Projects | |
4 | + %small | |
5 | + (#{projects.total_count}) | |
6 | + - if current_user.can_create_project? | |
7 | + %span.right | |
8 | + = link_to new_project_path, class: "btn very_small info" do | |
9 | + %i.icon-plus | |
10 | + New Project | |
11 | + %ul.unstyled | |
12 | + - projects.each do |project| | |
13 | + %li.wll | |
14 | + = link_to project_path(project), class: dom_class(project) do | |
15 | + %strong.project_name= truncate(project.name, length: 25) | |
16 | + %span.arrow | |
17 | + → | |
18 | + %span.last_activity | |
19 | + %strong Last activity: | |
20 | + %span= project_last_activity(project) | |
21 | + .bottom= paginate projects, theme: "gitlab" | ... | ... |
app/views/dashboard/index.html.haml
... | ... | @@ -9,28 +9,9 @@ |
9 | 9 | .loading.hide |
10 | 10 | .side |
11 | 11 | = render "events/event_last_push", event: @last_push |
12 | - .projects_box | |
13 | - %h5 | |
14 | - Projects | |
15 | - %small | |
16 | - (#{@projects.total_count}) | |
17 | - - if current_user.can_create_project? | |
18 | - %span.right | |
19 | - = link_to new_project_path, class: "btn very_small info" do | |
20 | - %i.icon-plus | |
21 | - New Project | |
22 | - %ul.unstyled | |
23 | - - @projects.each do |project| | |
24 | - %li.wll | |
25 | - = link_to project_path(project), class: dom_class(project) do | |
26 | - %strong.project_name= truncate(project.name, length: 25) | |
27 | - %span.arrow | |
28 | - → | |
29 | - %span.last_activity | |
30 | - %strong Last activity: | |
31 | - %span= project_last_activity(project) | |
32 | - .bottom= paginate @projects, theme: "gitlab" | |
33 | - | |
12 | + - unless @group | |
13 | + = render "groups", groups: @groups | |
14 | + = render "projects", projects: @projects | |
34 | 15 | %div |
35 | 16 | %span.rss-icon |
36 | 17 | = link_to dashboard_path(:atom, { private_token: current_user.private_token }) do | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +!!! 5 | |
2 | +%html{ lang: "en"} | |
3 | + = render "layouts/head" | |
4 | + %body{class: "#{app_theme} application"} | |
5 | + = render "layouts/flash" | |
6 | + = render "layouts/head_panel", title: "#{@group.name}:Dashboard" | |
7 | + .container | |
8 | + %ul.main_menu | |
9 | + = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do | |
10 | + = link_to "Home", root_path, title: "Home" | |
11 | + = nav_link(path: 'dashboard#issues') do | |
12 | + = link_to dashboard_issues_path(group: @group) do | |
13 | + Issues | |
14 | + %span.count= current_user.assigned_issues.opened.count | |
15 | + = nav_link(path: 'dashboard#merge_requests') do | |
16 | + = link_to dashboard_merge_requests_path(group: @group) do | |
17 | + Merge Requests | |
18 | + %span.count= current_user.cared_merge_requests.count | |
19 | + = nav_link(path: 'search#show') do | |
20 | + = link_to "People", "#" | |
21 | + = nav_link(path: 'help#index') do | |
22 | + = link_to "Help", help_path | |
23 | + | |
24 | + .content= yield | ... | ... |