From 5953582b65e1d49c3d04d9bc97069cb323ab277c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 24 Dec 2013 14:53:52 +0200 Subject: [PATCH] Show Assigned/Authored/All filter for dashboard issues and mr pages Signed-off-by: Dmitriy Zaporozhets --- app/controllers/dashboard_controller.rb | 22 ++++++++++++++++++---- app/views/dashboard/issues.html.haml | 4 ++-- app/views/dashboard/merge_requests.html.haml | 2 +- app/views/layouts/nav/_dashboard.html.haml | 2 +- app/views/shared/_filter.html.haml | 12 ++++++++++++ 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index aaab4b40c..70dd3fff9 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -50,16 +50,30 @@ class DashboardController < ApplicationController @projects = @projects.page(params[:page]).per(30) end - # Get authored or assigned open merge requests def merge_requests - @merge_requests = current_user.cared_merge_requests + @merge_requests = case params[:scope] + when 'authored' then + current_user.merge_requests + when 'all' then + MergeRequest.where(target_project_id: current_user.authorized_projects.pluck(:id)) + else + current_user.assigned_merge_requests + end + @merge_requests = FilterContext.new(@merge_requests, params).execute @merge_requests = @merge_requests.recent.page(params[:page]).per(20) end - # Get only assigned issues def issues - @issues = current_user.assigned_issues + @issues = case params[:scope] + when 'authored' then + current_user.issues + when 'all' then + Issue.where(project_id: current_user.authorized_projects.pluck(:id)) + else + current_user.assigned_issues + end + @issues = FilterContext.new(@issues, params).execute @issues = @issues.recent.page(params[:page]).per(20) @issues = @issues.includes(:author, :project) diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml index 82880d5ef..bda5b7c91 100644 --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -1,9 +1,9 @@ %h3.page-title - Issues assigned to me + Issues %span.pull-right #{@issues.total_count} issues %p.light - For all issues you should visit the project's issues page, or use the search panel to find a specific issue. + List all issues from all project's you have access to. %hr .row diff --git a/app/views/dashboard/merge_requests.html.haml b/app/views/dashboard/merge_requests.html.haml index 9c96edeef..74d02336b 100644 --- a/app/views/dashboard/merge_requests.html.haml +++ b/app/views/dashboard/merge_requests.html.haml @@ -4,7 +4,7 @@ %p.light - Only merge requests created by you or assigned to you are listed here. + List all merge requests from all project's you have access to. %hr .row .span3 diff --git a/app/views/layouts/nav/_dashboard.html.haml b/app/views/layouts/nav/_dashboard.html.haml index cae24c317..12fd49e60 100644 --- a/app/views/layouts/nav/_dashboard.html.haml +++ b/app/views/layouts/nav/_dashboard.html.haml @@ -12,7 +12,7 @@ = nav_link(path: 'dashboard#merge_requests') do = link_to merge_requests_dashboard_path do Merge Requests - %span.count= current_user.cared_merge_requests.opened.count + %span.count= current_user.assigned_merge_requests.opened.count = nav_link(controller: :help) do = link_to "Help", help_path diff --git a/app/views/shared/_filter.html.haml b/app/views/shared/_filter.html.haml index 2f051cea4..c1a3a9e46 100644 --- a/app/views/shared/_filter.html.haml +++ b/app/views/shared/_filter.html.haml @@ -1,6 +1,18 @@ = form_tag filter_path(entity), method: 'get' do %fieldset %ul.nav.nav-pills.nav-stacked + %li{class: ("active" if params[:scope].blank?)} + = link_to filter_path(entity, scope: nil) do + Assigned to me + %li{class: ("active" if params[:scope] == 'authored')} + = link_to filter_path(entity, scope: 'authored') do + Authored by me + %li{class: ("active" if params[:scope] == 'all')} + = link_to filter_path(entity, scope: 'all') do + All + + %fieldset + %ul.nav.nav-pills.nav-stacked %li{class: ("active" if params[:status].blank?)} = link_to filter_path(entity, status: nil) do Open -- 2.11.0