Commit 80597d59 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'dashboard-fix-assignee' into 'master'

Dashboard: fix assignee filter and remove some old code

See merge request !1354
parents a7b7a2dd 465f1869
...@@ -257,10 +257,6 @@ class ApplicationController < ActionController::Base ...@@ -257,10 +257,6 @@ class ApplicationController < ActionController::Base
# or improve current implementation to filter only issues you # or improve current implementation to filter only issues you
# created or assigned or mentioned # created or assigned or mentioned
#@filter_params[:authorized_only] = true #@filter_params[:authorized_only] = true
unless @filter_params[:assignee_id]
@filter_params[:assignee_id] = current_user.id
end
end end
@filter_params @filter_params
......
module DashboardHelper module DashboardHelper
def entities_per_project(project, entity)
case entity.to_sym
when :issue then @issues.where(project_id: project.id)
when :merge_request then @merge_requests.where(target_project_id: project.id)
else
[]
end.count
end
def projects_dashboard_filter_path(options={}) def projects_dashboard_filter_path(options={})
exist_opts = { exist_opts = {
sort: params[:sort], sort: params[:sort],
...@@ -22,32 +13,11 @@ module DashboardHelper ...@@ -22,32 +13,11 @@ module DashboardHelper
path path
end end
def assigned_entities_count(current_user, entity, scope = nil) def assigned_issues_dashboard_path
items = current_user.send('assigned_' + entity.pluralize) issues_dashboard_path(assignee_id: current_user.id)
get_count(items, scope)
end
def authored_entities_count(current_user, entity, scope = nil)
items = current_user.send(entity.pluralize)
get_count(items, scope)
end end
def authorized_entities_count(current_user, entity, scope = nil) def assigned_mrs_dashboard_path
items = entity.classify.constantize merge_requests_dashboard_path(assignee_id: current_user.id)
get_count(items, scope, true, current_user)
end
protected
def get_count(items, scope, get_authorized = false, current_user = nil)
items = items.opened
if scope.kind_of?(Group)
items = items.of_group(scope)
elsif scope.kind_of?(Project)
items = items.of_projects(scope)
elsif get_authorized
items = items.of_projects(current_user.authorized_projects)
end
items.count
end end
end end
...@@ -10,13 +10,13 @@ ...@@ -10,13 +10,13 @@
%span %span
Projects Projects
= nav_link(path: 'dashboard#issues') do = nav_link(path: 'dashboard#issues') do
= link_to issues_dashboard_path, class: 'shortcuts-issues' do = link_to assigned_issues_dashboard_path, class: 'shortcuts-issues' do
%i.fa.fa-exclamation-circle %i.fa.fa-exclamation-circle
%span %span
Issues Issues
%span.count= current_user.assigned_issues.opened.count %span.count= current_user.assigned_issues.opened.count
= nav_link(path: 'dashboard#merge_requests') do = nav_link(path: 'dashboard#merge_requests') do
= link_to merge_requests_dashboard_path, class: 'shortcuts-merge_requests' do = link_to assigned_mrs_dashboard_path, class: 'shortcuts-merge_requests' do
%i.fa.fa-tasks %i.fa.fa-tasks
%span %span
Merge Requests Merge Requests
......
module SharedPaths module SharedPaths
include Spinach::DSL include Spinach::DSL
include RepoHelpers include RepoHelpers
include DashboardHelper
step 'I visit new project page' do step 'I visit new project page' do
visit new_project_path visit new_project_path
...@@ -71,11 +72,11 @@ module SharedPaths ...@@ -71,11 +72,11 @@ module SharedPaths
end end
step 'I visit dashboard issues page' do step 'I visit dashboard issues page' do
visit issues_dashboard_path visit assigned_issues_dashboard_path
end end
step 'I visit dashboard merge requests page' do step 'I visit dashboard merge requests page' do
visit merge_requests_dashboard_path visit assigned_mrs_dashboard_path
end end
step 'I visit dashboard search page' do step 'I visit dashboard search page' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment