diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index d5712ab3374140c89ad61100164ce4f04cb2f77e..c4e33e3308ff193fd0ea2d1e4851a355a61731cd 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -35,4 +35,42 @@ module DashboardHelper path << "?#{options.to_param}" path end + + def assigned_entities_count(current_user, entity, scope = nil) + items = current_user.send("assigned_" + entity.pluralize).opened + + if scope.kind_of?(Group) + items = items.of_group(scope) + elsif scope.kind_of?(Project) + items = items.of_projects(scope) + end + + items.count + end + + def authored_entities_count(current_user, entity, scope = nil) + items = current_user.send(entity.pluralize).opened + + if scope.kind_of?(Group) + items = items.of_group(scope) + elsif scope.kind_of?(Project) + items = items.of_projects(scope) + end + + items.count + end + + def authorized_entities_count(current_user, entity, scope = nil) + items = entity.classify.constantize.opened + + if scope.kind_of?(Group) + items = items.of_group(scope) + elsif scope.kind_of?(Project) + items = items.of_projects(scope) + else + items = items.of_projects(current_user.authorized_projects) + end + + items.count + end end diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml index 9888da2f7f203bfae9b2c323a1c8c7d61028c384..d3ff291eaa8d31cf87adc4fd68157148f318bf61 100644 --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -1,6 +1,5 @@ %h3.page-title Issues - %span.pull-right #{@issues.total_count} issues %p.light List all issues from all projects you have access to. diff --git a/app/views/dashboard/merge_requests.html.haml b/app/views/dashboard/merge_requests.html.haml index ee3bec2849d774c1f5721c91e11dfa42b7d6142b..7a9ea9f6f902a2e48018f1595de67abe7b19bdb1 100644 --- a/app/views/dashboard/merge_requests.html.haml +++ b/app/views/dashboard/merge_requests.html.haml @@ -1,6 +1,5 @@ %h3.page-title Merge Requests - %span.pull-right #{@merge_requests.total_count} merge requests %p.light diff --git a/app/views/groups/issues.html.haml b/app/views/groups/issues.html.haml index 0eec2d6be0b27a4acc4b9fba00e8dfc486866881..0152ae868333525ac3eaa3fca1681132625ae7de 100644 --- a/app/views/groups/issues.html.haml +++ b/app/views/groups/issues.html.haml @@ -1,6 +1,5 @@ %h3.page-title Issues - %span.pull-right #{@issues.total_count} issues %p.light Only issues from diff --git a/app/views/groups/merge_requests.html.haml b/app/views/groups/merge_requests.html.haml index 71adb2c5516794bc533e8e45ab3106ff107869da..71d346d0469d31bcedd0b95f2cffeaa55b462f97 100644 --- a/app/views/groups/merge_requests.html.haml +++ b/app/views/groups/merge_requests.html.haml @@ -1,6 +1,5 @@ %h3.page-title Merge Requests - %span.pull-right #{@merge_requests.total_count} merge requests %p.light Only merge requests from diff --git a/app/views/projects/issues/_head.html.haml b/app/views/projects/issues/_head.html.haml index 716ea7cefed4d3881afd033721a42a40a583cba4..dad547d4ebc0627782732a2219ed0158a7160da0 100644 --- a/app/views/projects/issues/_head.html.haml +++ b/app/views/projects/issues/_head.html.haml @@ -2,8 +2,6 @@ = nav_link(controller: :issues) do = link_to project_issues_path(@project), class: "tab" do Browse Issues - - if current_controller?(:issues) - %span.badge.issue_counter #{@issues.total_count} = nav_link(controller: :milestones) do = link_to 'Milestones', project_milestones_path(@project), class: "tab" = nav_link(controller: :labels) do diff --git a/app/views/projects/issues/index.html.haml b/app/views/projects/issues/index.html.haml index 2e66d0595657a5aea231ad5ca1637d5c52de9526..5de77b8bf322ddeac4b230ce08d11ffe17ecd798 100644 --- a/app/views/projects/issues/index.html.haml +++ b/app/views/projects/issues/index.html.haml @@ -4,6 +4,6 @@ %i.icon-list.icon-2x .col-md-3.responsive-side = render 'shared/project_filter', project_entities_path: project_issues_path(@project), - labels: true, redirect: 'issues' + labels: true, redirect: 'issues', entity: 'issue' .col-md-9.issues-holder = render "issues" diff --git a/app/views/projects/merge_requests/index.html.haml b/app/views/projects/merge_requests/index.html.haml index 4bb803eb6df07412725cf3d55ced7133952ca3c5..0954fa8fcea0ecd178b722f6ce8044a30e31e0fb 100644 --- a/app/views/projects/merge_requests/index.html.haml +++ b/app/views/projects/merge_requests/index.html.haml @@ -4,14 +4,13 @@ New Merge Request %h3.page-title Merge Requests - %span (#{@merge_requests.total_count}) %hr .row .fixed.sidebar-expand-button.hidden-lg.hidden-md %i.icon-list.icon-2x .col-md-3.responsive-side = render 'shared/project_filter', project_entities_path: project_merge_requests_path(@project), - labels: true, redirect: 'merge_requests' + labels: true, redirect: 'merge_requests', entity: 'merge_request' .col-md-9 .mr-filters.append-bottom-10 .dropdown.inline diff --git a/app/views/shared/_filter.html.haml b/app/views/shared/_filter.html.haml index 19ecc458e29ae8dbb35110e2972f9f32723b0876..9e65ce11adec573c50a2962cf754269db105ac33 100644 --- a/app/views/shared/_filter.html.haml +++ b/app/views/shared/_filter.html.haml @@ -6,12 +6,18 @@ %li{class: ("active" if params[:scope] == 'assigned-to-me')} = link_to filter_path(entity, scope: 'assigned-to-me') do Assigned to me + %span.pull-right + = assigned_entities_count(current_user, entity, @group) %li{class: ("active" if params[:scope] == 'authored')} = link_to filter_path(entity, scope: 'authored') do Created by me + %span.pull-right + = authored_entities_count(current_user, entity, @group) %li{class: ("active" if params[:scope] == 'all')} = link_to filter_path(entity, scope: 'all') do Everyone's + %span.pull-right + = authorized_entities_count(current_user, entity, @group) %fieldset.status-filter %legend State diff --git a/app/views/shared/_project_filter.html.haml b/app/views/shared/_project_filter.html.haml index 743b4fba54217e4933d091700641f5471cb06c36..38cb1208cdc7ebdde9150436230e31a823894046 100644 --- a/app/views/shared/_project_filter.html.haml +++ b/app/views/shared/_project_filter.html.haml @@ -6,12 +6,18 @@ %li{class: ("active" if params[:scope] == 'all')} = link_to project_filter_path(scope: 'all') do Everyone's + %span.pull-right + = authorized_entities_count(current_user, entity, @project) %li{class: ("active" if params[:scope] == 'assigned-to-me')} = link_to project_filter_path(scope: 'assigned-to-me') do Assigned to me + %span.pull-right + = assigned_entities_count(current_user, entity, @project) %li{class: ("active" if params[:scope] == 'created-by-me')} = link_to project_filter_path(scope: 'created-by-me') do Created by me + %span.pull-right + = authored_entities_count(current_user, entity, @project) %fieldset %legend State