Commit 5953582b65e1d49c3d04d9bc97069cb323ab277c
1 parent
ce527b68
Exists in
spb-stable
and in
3 other branches
Show Assigned/Authored/All filter for dashboard issues and mr pages
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
5 changed files
with
34 additions
and
8 deletions
Show diff stats
app/controllers/dashboard_controller.rb
@@ -50,16 +50,30 @@ class DashboardController < ApplicationController | @@ -50,16 +50,30 @@ class DashboardController < ApplicationController | ||
50 | @projects = @projects.page(params[:page]).per(30) | 50 | @projects = @projects.page(params[:page]).per(30) |
51 | end | 51 | end |
52 | 52 | ||
53 | - # Get authored or assigned open merge requests | ||
54 | def merge_requests | 53 | def merge_requests |
55 | - @merge_requests = current_user.cared_merge_requests | 54 | + @merge_requests = case params[:scope] |
55 | + when 'authored' then | ||
56 | + current_user.merge_requests | ||
57 | + when 'all' then | ||
58 | + MergeRequest.where(target_project_id: current_user.authorized_projects.pluck(:id)) | ||
59 | + else | ||
60 | + current_user.assigned_merge_requests | ||
61 | + end | ||
62 | + | ||
56 | @merge_requests = FilterContext.new(@merge_requests, params).execute | 63 | @merge_requests = FilterContext.new(@merge_requests, params).execute |
57 | @merge_requests = @merge_requests.recent.page(params[:page]).per(20) | 64 | @merge_requests = @merge_requests.recent.page(params[:page]).per(20) |
58 | end | 65 | end |
59 | 66 | ||
60 | - # Get only assigned issues | ||
61 | def issues | 67 | def issues |
62 | - @issues = current_user.assigned_issues | 68 | + @issues = case params[:scope] |
69 | + when 'authored' then | ||
70 | + current_user.issues | ||
71 | + when 'all' then | ||
72 | + Issue.where(project_id: current_user.authorized_projects.pluck(:id)) | ||
73 | + else | ||
74 | + current_user.assigned_issues | ||
75 | + end | ||
76 | + | ||
63 | @issues = FilterContext.new(@issues, params).execute | 77 | @issues = FilterContext.new(@issues, params).execute |
64 | @issues = @issues.recent.page(params[:page]).per(20) | 78 | @issues = @issues.recent.page(params[:page]).per(20) |
65 | @issues = @issues.includes(:author, :project) | 79 | @issues = @issues.includes(:author, :project) |
app/views/dashboard/issues.html.haml
1 | %h3.page-title | 1 | %h3.page-title |
2 | - Issues assigned to me | 2 | + Issues |
3 | %span.pull-right #{@issues.total_count} issues | 3 | %span.pull-right #{@issues.total_count} issues |
4 | 4 | ||
5 | %p.light | 5 | %p.light |
6 | - For all issues you should visit the project's issues page, or use the search panel to find a specific issue. | 6 | + List all issues from all project's you have access to. |
7 | %hr | 7 | %hr |
8 | 8 | ||
9 | .row | 9 | .row |
app/views/dashboard/merge_requests.html.haml
app/views/layouts/nav/_dashboard.html.haml
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | = nav_link(path: 'dashboard#merge_requests') do | 12 | = nav_link(path: 'dashboard#merge_requests') do |
13 | = link_to merge_requests_dashboard_path do | 13 | = link_to merge_requests_dashboard_path do |
14 | Merge Requests | 14 | Merge Requests |
15 | - %span.count= current_user.cared_merge_requests.opened.count | 15 | + %span.count= current_user.assigned_merge_requests.opened.count |
16 | = nav_link(controller: :help) do | 16 | = nav_link(controller: :help) do |
17 | = link_to "Help", help_path | 17 | = link_to "Help", help_path |
18 | 18 |
app/views/shared/_filter.html.haml
1 | = form_tag filter_path(entity), method: 'get' do | 1 | = form_tag filter_path(entity), method: 'get' do |
2 | %fieldset | 2 | %fieldset |
3 | %ul.nav.nav-pills.nav-stacked | 3 | %ul.nav.nav-pills.nav-stacked |
4 | + %li{class: ("active" if params[:scope].blank?)} | ||
5 | + = link_to filter_path(entity, scope: nil) do | ||
6 | + Assigned to me | ||
7 | + %li{class: ("active" if params[:scope] == 'authored')} | ||
8 | + = link_to filter_path(entity, scope: 'authored') do | ||
9 | + Authored by me | ||
10 | + %li{class: ("active" if params[:scope] == 'all')} | ||
11 | + = link_to filter_path(entity, scope: 'all') do | ||
12 | + All | ||
13 | + | ||
14 | + %fieldset | ||
15 | + %ul.nav.nav-pills.nav-stacked | ||
4 | %li{class: ("active" if params[:status].blank?)} | 16 | %li{class: ("active" if params[:status].blank?)} |
5 | = link_to filter_path(entity, status: nil) do | 17 | = link_to filter_path(entity, status: nil) do |
6 | Open | 18 | Open |