Commit d88a238b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'dz-hide-zero-counter' into 'master'

Hide zero counters on header

Closes #30449

See merge request !10506
parents 75462cba 6ed59e12
...@@ -47,17 +47,19 @@ ...@@ -47,17 +47,19 @@
%li %li
= link_to assigned_issues_dashboard_path, title: 'Issues', aria: { label: "Issues" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to assigned_issues_dashboard_path, title: 'Issues', aria: { label: "Issues" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('hashtag fw') = icon('hashtag fw')
%span.badge.issues-count - issues_count = cached_assigned_issuables_count(current_user, :issues, :opened)
= number_with_delimiter(cached_assigned_issuables_count(current_user, :issues, :opened)) %span.badge.issues-count{ class: ('hidden' if issues_count.zero?) }
= number_with_delimiter(issues_count)
%li %li
= link_to assigned_mrs_dashboard_path, title: 'Merge requests', aria: { label: "Merge requests" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to assigned_mrs_dashboard_path, title: 'Merge requests', aria: { label: "Merge requests" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= custom_icon('mr_bold') = custom_icon('mr_bold')
%span.badge.merge-requests-count - merge_requests_count = cached_assigned_issuables_count(current_user, :merge_requests, :opened)
= number_with_delimiter(cached_assigned_issuables_count(current_user, :merge_requests, :opened)) %span.badge.merge-requests-count{ class: ('hidden' if merge_requests_count.zero?) }
= number_with_delimiter(merge_requests_count)
%li %li
= link_to dashboard_todos_path, title: 'Todos', aria: { label: "Todos" }, class: 'shortcuts-todos', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to dashboard_todos_path, title: 'Todos', aria: { label: "Todos" }, class: 'shortcuts-todos', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('check-circle fw') = icon('check-circle fw')
%span.badge.todos-count %span.badge.todos-count{ class: ('hidden' if todos_pending_count.zero?) }
= todos_count_format(todos_pending_count) = todos_count_format(todos_pending_count)
%li.header-user.dropdown %li.header-user.dropdown
= link_to current_user, class: "header-user-dropdown-toggle", data: { toggle: "dropdown" } do = link_to current_user, class: "header-user-dropdown-toggle", data: { toggle: "dropdown" } do
......
---
title: Hide header counters for issue/mr/todos if zero
merge_request: 10506
author:
require 'spec_helper' require 'spec_helper'
describe 'Navigation bar counter', feature: true, js: true, caching: true do describe 'Navigation bar counter', feature: true, caching: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:empty_project, namespace: user.namespace) } let(:project) { create(:empty_project, namespace: user.namespace) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
...@@ -13,33 +13,48 @@ describe 'Navigation bar counter', feature: true, js: true, caching: true do ...@@ -13,33 +13,48 @@ describe 'Navigation bar counter', feature: true, js: true, caching: true do
end end
it 'reflects dashboard issues count' do it 'reflects dashboard issues count' do
visit issues_dashboard_path visit issues_path
expect_counters('issues', '1') expect_counters('issues', '1')
issue.update(assignee: nil) issue.update(assignee: nil)
visit issues_dashboard_path
expect_counters('issues', '1') Timecop.travel(3.minutes.from_now) do
visit issues_path
expect_counters('issues', '0')
end
end end
it 'reflects dashboard merge requests count' do it 'reflects dashboard merge requests count' do
visit merge_requests_dashboard_path visit merge_requests_path
expect_counters('merge_requests', '1') expect_counters('merge_requests', '1')
merge_request.update(assignee: nil) merge_request.update(assignee: nil)
visit merge_requests_dashboard_path
expect_counters('merge_requests', '1') Timecop.travel(3.minutes.from_now) do
visit merge_requests_path
expect_counters('merge_requests', '0')
end
end
def issues_path
issues_dashboard_path(assignee_id: user.id)
end
def merge_requests_path
merge_requests_dashboard_path(assignee_id: user.id)
end end
def expect_counters(issuable_type, count) def expect_counters(issuable_type, count)
dashboard_count = find('li.active') dashboard_count = find('.nav-links li.active')
find('.global-dropdown-toggle').click
nav_count = find(".dashboard-shortcuts-#{issuable_type}") nav_count = find(".dashboard-shortcuts-#{issuable_type}")
header_count = find(".header-content .#{issuable_type.tr('_', '-')}-count")
expect(nav_count).to have_content(count)
expect(dashboard_count).to have_content(count) expect(dashboard_count).to have_content(count)
expect(nav_count).to have_content(count)
expect(header_count).to have_content(count)
end end
end end
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