From 1d1f935c6e9e536975aa5c8975855281e8a12225 Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Tue, 17 Apr 2018 16:20:40 +0300 Subject: Add badge count to projects and groups --- app/views/dashboard/_groups_head.html.haml | 1 + app/views/dashboard/_projects_head.html.haml | 2 ++ changelogs/unreleased/add-badge-count-to-projects-and-groups.yml | 5 +++++ 3 files changed, 8 insertions(+) create mode 100644 changelogs/unreleased/add-badge-count-to-projects-and-groups.yml diff --git a/app/views/dashboard/_groups_head.html.haml b/app/views/dashboard/_groups_head.html.haml index 8ab5dc37f34..e85fd0db93c 100644 --- a/app/views/dashboard/_groups_head.html.haml +++ b/app/views/dashboard/_groups_head.html.haml @@ -10,6 +10,7 @@ = nav_link(page: dashboard_groups_path) do = link_to dashboard_groups_path, title: _("Your groups") do Your groups + %span.badge.count= limited_counter_with_delimiter(current_user.groups) = nav_link(page: explore_groups_path) do = link_to explore_groups_path, title: _("Explore public groups") do Explore public groups diff --git a/app/views/dashboard/_projects_head.html.haml b/app/views/dashboard/_projects_head.html.haml index 1050945b15a..831ea00cee1 100644 --- a/app/views/dashboard/_projects_head.html.haml +++ b/app/views/dashboard/_projects_head.html.haml @@ -15,9 +15,11 @@ = nav_link(page: [dashboard_projects_path, root_path]) do = link_to dashboard_projects_path, class: 'shortcuts-activity', data: {placement: 'right'} do Your projects + %span.badge.count= limited_counter_with_delimiter(ProjectsFinder.new(params: {non_public: true}, current_user: current_user).execute) = nav_link(page: starred_dashboard_projects_path) do = link_to starred_dashboard_projects_path, data: {placement: 'right'} do Starred projects + %span.badge.count= limited_counter_with_delimiter(ProjectsFinder.new(params: {starred: true}, current_user: current_user).execute) = nav_link(page: [explore_root_path, trending_explore_projects_path, starred_explore_projects_path, explore_projects_path]) do = link_to explore_root_path, data: {placement: 'right'} do Explore projects diff --git a/changelogs/unreleased/add-badge-count-to-projects-and-groups.yml b/changelogs/unreleased/add-badge-count-to-projects-and-groups.yml new file mode 100644 index 00000000000..33f8c53cc97 --- /dev/null +++ b/changelogs/unreleased/add-badge-count-to-projects-and-groups.yml @@ -0,0 +1,5 @@ +--- +title: Add badge count to projects and groups +merge_request: 18425 +author: George Tsiolis +type: changed -- cgit v1.2.1 From e8d971735b2d48b85b6195104eef46b0bc42206d Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Fri, 30 Nov 2018 17:48:17 +0200 Subject: Update badge-pill class --- app/views/dashboard/_groups_head.html.haml | 2 +- app/views/dashboard/_projects_head.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/dashboard/_groups_head.html.haml b/app/views/dashboard/_groups_head.html.haml index e85fd0db93c..ccb82ffe228 100644 --- a/app/views/dashboard/_groups_head.html.haml +++ b/app/views/dashboard/_groups_head.html.haml @@ -10,7 +10,7 @@ = nav_link(page: dashboard_groups_path) do = link_to dashboard_groups_path, title: _("Your groups") do Your groups - %span.badge.count= limited_counter_with_delimiter(current_user.groups) + %span.badge.badge-pill= limited_counter_with_delimiter(current_user.groups) = nav_link(page: explore_groups_path) do = link_to explore_groups_path, title: _("Explore public groups") do Explore public groups diff --git a/app/views/dashboard/_projects_head.html.haml b/app/views/dashboard/_projects_head.html.haml index 831ea00cee1..d69fc14543b 100644 --- a/app/views/dashboard/_projects_head.html.haml +++ b/app/views/dashboard/_projects_head.html.haml @@ -15,11 +15,11 @@ = nav_link(page: [dashboard_projects_path, root_path]) do = link_to dashboard_projects_path, class: 'shortcuts-activity', data: {placement: 'right'} do Your projects - %span.badge.count= limited_counter_with_delimiter(ProjectsFinder.new(params: {non_public: true}, current_user: current_user).execute) + %span.badge.badge-pill= limited_counter_with_delimiter(ProjectsFinder.new(params: {non_public: true}, current_user: current_user).execute) = nav_link(page: starred_dashboard_projects_path) do = link_to starred_dashboard_projects_path, data: {placement: 'right'} do Starred projects - %span.badge.count= limited_counter_with_delimiter(ProjectsFinder.new(params: {starred: true}, current_user: current_user).execute) + %span.badge.badge-pill= limited_counter_with_delimiter(ProjectsFinder.new(params: {starred: true}, current_user: current_user).execute) = nav_link(page: [explore_root_path, trending_explore_projects_path, starred_explore_projects_path, explore_projects_path]) do = link_to explore_root_path, data: {placement: 'right'} do Explore projects -- cgit v1.2.1 From 23f0020be0fa9dc6c09cd841a246f182677a0897 Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Fri, 7 Dec 2018 12:05:17 +0200 Subject: Move ProjectsFinder into the controller --- app/controllers/dashboard/projects_controller.rb | 3 +++ app/controllers/explore/projects_controller.rb | 3 +++ app/views/dashboard/_projects_head.html.haml | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb index f073b6de444..b1d224d026f 100644 --- a/app/controllers/dashboard/projects_controller.rb +++ b/app/controllers/dashboard/projects_controller.rb @@ -53,6 +53,9 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController # rubocop: disable CodeReuse/ActiveRecord def load_projects(finder_params) + @total_user_projects_count = ProjectsFinder.new(params: { non_public: true }, current_user: current_user).execute + @total_starred_projects_count = ProjectsFinder.new(params: { starred: true }, current_user: current_user).execute + projects = ProjectsFinder .new(params: finder_params, current_user: current_user) .execute diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb index 778fdda8dbd..9f074690cbc 100644 --- a/app/controllers/explore/projects_controller.rb +++ b/app/controllers/explore/projects_controller.rb @@ -55,6 +55,9 @@ class Explore::ProjectsController < Explore::ApplicationController # rubocop: disable CodeReuse/ActiveRecord def load_projects + @total_user_projects_count = ProjectsFinder.new(params: { non_public: true }, current_user: current_user).execute + @total_starred_projects_count = ProjectsFinder.new(params: { starred: true }, current_user: current_user).execute + projects = ProjectsFinder.new(current_user: current_user, params: params) .execute .includes(:route, :creator, :group, namespace: [:route, :owner]) diff --git a/app/views/dashboard/_projects_head.html.haml b/app/views/dashboard/_projects_head.html.haml index d69fc14543b..ae67192cbcd 100644 --- a/app/views/dashboard/_projects_head.html.haml +++ b/app/views/dashboard/_projects_head.html.haml @@ -15,11 +15,11 @@ = nav_link(page: [dashboard_projects_path, root_path]) do = link_to dashboard_projects_path, class: 'shortcuts-activity', data: {placement: 'right'} do Your projects - %span.badge.badge-pill= limited_counter_with_delimiter(ProjectsFinder.new(params: {non_public: true}, current_user: current_user).execute) + %span.badge.badge-pill= limited_counter_with_delimiter(@total_user_projects_count) = nav_link(page: starred_dashboard_projects_path) do = link_to starred_dashboard_projects_path, data: {placement: 'right'} do Starred projects - %span.badge.badge-pill= limited_counter_with_delimiter(ProjectsFinder.new(params: {starred: true}, current_user: current_user).execute) + %span.badge.badge-pill= limited_counter_with_delimiter(@total_starred_projects_count) = nav_link(page: [explore_root_path, trending_explore_projects_path, starred_explore_projects_path, explore_projects_path]) do = link_to explore_root_path, data: {placement: 'right'} do Explore projects -- cgit v1.2.1 From cc9dc0259d422b315c9ed50b545c5dbf3f6ee144 Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Tue, 15 Jan 2019 14:47:27 +0200 Subject: Remove badge count for groups --- app/views/dashboard/_groups_head.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/dashboard/_groups_head.html.haml b/app/views/dashboard/_groups_head.html.haml index ccb82ffe228..8ab5dc37f34 100644 --- a/app/views/dashboard/_groups_head.html.haml +++ b/app/views/dashboard/_groups_head.html.haml @@ -10,7 +10,6 @@ = nav_link(page: dashboard_groups_path) do = link_to dashboard_groups_path, title: _("Your groups") do Your groups - %span.badge.badge-pill= limited_counter_with_delimiter(current_user.groups) = nav_link(page: explore_groups_path) do = link_to explore_groups_path, title: _("Explore public groups") do Explore public groups -- cgit v1.2.1 From 25dcce0aa78ea3ba8c26b451961909f70b15e593 Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Tue, 15 Jan 2019 22:06:24 +0200 Subject: Add tests to check projects badge count --- spec/features/dashboard/projects_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 975b7944741..edca8f9df08 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -91,6 +91,7 @@ describe 'Dashboard Projects' do visit dashboard_projects_path expect(page).to have_content(project.name) + expect(find('.nav-links li:nth-child(1) .badge-pill')).to have_content(1) end it 'shows personal projects on personal projects tab', :js do @@ -121,6 +122,8 @@ describe 'Dashboard Projects' do expect(page).not_to have_content(project.name) expect(page).to have_content(project2.name) + expect(find('.nav-links li:nth-child(1) .badge-pill')).to have_content(1) + expect(find('.nav-links li:nth-child(2) .badge-pill')).to have_content(1) end end -- cgit v1.2.1