summaryrefslogtreecommitdiff
path: root/app/controllers/dashboard_controller.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-24 14:53:52 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-24 14:53:52 +0200
commit5953582b65e1d49c3d04d9bc97069cb323ab277c (patch)
treecac617ef3e009f21eb1791013aa61ce5afcb3c5c /app/controllers/dashboard_controller.rb
parentce527b68f07c245e887a640b6f874406bae7d0ed (diff)
downloadgitlab-ce-5953582b65e1d49c3d04d9bc97069cb323ab277c.tar.gz
Show Assigned/Authored/All filter for dashboard issues and mr pages
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/dashboard_controller.rb')
-rw-r--r--app/controllers/dashboard_controller.rb22
1 files changed, 18 insertions, 4 deletions
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index aaab4b40c4c..70dd3fff9a0 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)