Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
8c3e6987
Commit
8c3e6987
authored
Nov 09, 2016
by
Lucas Deschamps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Navigation bar issuables counters reflects dashboard issuables counters
parent
f27f9803
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
2 deletions
+50
-2
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+11
-0
app/views/layouts/nav/_dashboard.html.haml
app/views/layouts/nav/_dashboard.html.haml
+2
-2
changelogs/unreleased/fix_navigation_bar_issuables_counters.yml
...logs/unreleased/fix_navigation_bar_issuables_counters.yml
+4
-0
spec/features/dashboard/issuables_counter_spec.rb
spec/features/dashboard/issuables_counter_spec.rb
+33
-0
No files found.
app/helpers/issuables_helper.rb
View file @
8c3e6987
...
...
@@ -141,8 +141,19 @@ module IssuablesHelper
html
.
html_safe
end
def
cached_assigned_issuables_count
(
assignee
,
issuable_type
,
state
)
cache_key
=
"
#{
assignee
.
id
}
_
#{
issuable_type
}
_
#{
state
}
"
Rails
.
cache
.
fetch
(
cache_key
,
expires_in:
2
.
minutes
)
do
assigned_issuables_count
(
assignee
,
issuable_type
,
state
)
end
end
private
def
assigned_issuables_count
(
assignee
,
issuable_type
,
state
)
assignee
.
send
(
"assigned_
#{
issuable_type
}
"
).
send
(
state
).
count
end
def
sidebar_gutter_collapsed?
cookies
[
:collapsed_gutter
]
==
'true'
end
...
...
app/views/layouts/nav/_dashboard.html.haml
View file @
8c3e6987
...
...
@@ -26,12 +26,12 @@
=
link_to
assigned_issues_dashboard_path
,
title:
'Issues'
,
class:
'dashboard-shortcuts-issues'
do
%span
Issues
%span
.count
=
number_with_delimiter
(
c
urrent_user
.
assigned_issues
.
opened
.
count
)
%span
.count
=
number_with_delimiter
(
c
ached_assigned_issuables_count
(
current_user
,
:issues
,
:opened
)
)
=
nav_link
(
path:
'dashboard#merge_requests'
)
do
=
link_to
assigned_mrs_dashboard_path
,
title:
'Merge Requests'
,
class:
'dashboard-shortcuts-merge_requests'
do
%span
Merge Requests
%span
.count
=
number_with_delimiter
(
c
urrent_user
.
assigned_merge_requests
.
opened
.
count
)
%span
.count
=
number_with_delimiter
(
c
ached_assigned_issuables_count
(
current_user
,
:merge_requests
,
:opened
)
)
=
nav_link
(
controller:
'dashboard/snippets'
)
do
=
link_to
dashboard_snippets_path
,
title:
'Snippets'
do
%span
...
...
changelogs/unreleased/fix_navigation_bar_issuables_counters.yml
0 → 100644
View file @
8c3e6987
---
title
:
Navigation bar issuables counters reflects dashboard issuables counters
merge_request
:
author
:
Lucas Deschamps
spec/features/dashboard/issuables_counter_spec.rb
0 → 100644
View file @
8c3e6987
require
'spec_helper'
describe
'Navigation bar counter'
,
feature:
true
,
js:
true
,
caching:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
before
do
login_as
(
user
)
visit
issues_dashboard_path
end
it
'reflects dashboard issues count'
do
create
(
:issue
,
project:
project
,
assignee:
user
)
visit
issues_dashboard_path
dashboard_count
=
find
(
'li.active span.badge'
)
nav_count
=
find
(
'.dashboard-shortcuts-issues span.count'
)
expect
(
dashboard_count
).
to
have_content
(
'0'
)
expect
(
nav_count
).
to
have_content
(
'0'
)
end
it
'reflects dashboard merge requests count'
do
create
(
:merge_request
,
assignee:
user
)
visit
merge_requests_dashboard_path
dashboard_count
=
find
(
'li.active span.badge'
)
nav_count
=
find
(
'.dashboard-shortcuts-merge_requests span.count'
)
expect
(
dashboard_count
).
to
have_content
(
'0'
)
expect
(
nav_count
).
to
have_content
(
'0'
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment