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 | 50 | @projects = @projects.page(params[:page]).per(30) |
51 | 51 | end |
52 | 52 | |
53 | - # Get authored or assigned open merge requests | |
54 | 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 | 63 | @merge_requests = FilterContext.new(@merge_requests, params).execute |
57 | 64 | @merge_requests = @merge_requests.recent.page(params[:page]).per(20) |
58 | 65 | end |
59 | 66 | |
60 | - # Get only assigned issues | |
61 | 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 | 77 | @issues = FilterContext.new(@issues, params).execute |
64 | 78 | @issues = @issues.recent.page(params[:page]).per(20) |
65 | 79 | @issues = @issues.includes(:author, :project) | ... | ... |
app/views/dashboard/issues.html.haml
1 | 1 | %h3.page-title |
2 | - Issues assigned to me | |
2 | + Issues | |
3 | 3 | %span.pull-right #{@issues.total_count} issues |
4 | 4 | |
5 | 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 | 7 | %hr |
8 | 8 | |
9 | 9 | .row | ... | ... |
app/views/dashboard/merge_requests.html.haml
app/views/layouts/nav/_dashboard.html.haml
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | = nav_link(path: 'dashboard#merge_requests') do |
13 | 13 | = link_to merge_requests_dashboard_path do |
14 | 14 | Merge Requests |
15 | - %span.count= current_user.cared_merge_requests.opened.count | |
15 | + %span.count= current_user.assigned_merge_requests.opened.count | |
16 | 16 | = nav_link(controller: :help) do |
17 | 17 | = link_to "Help", help_path |
18 | 18 | ... | ... |
app/views/shared/_filter.html.haml
1 | 1 | = form_tag filter_path(entity), method: 'get' do |
2 | 2 | %fieldset |
3 | 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 | 16 | %li{class: ("active" if params[:status].blank?)} |
5 | 17 | = link_to filter_path(entity, status: nil) do |
6 | 18 | Open | ... | ... |