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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e15a2c31
Commit
e15a2c31
authored
Nov 23, 2021
by
Mark Florian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use gl_badge_tag helper in gl_tab_counter_badge
Addresses
https://gitlab.com/gitlab-org/gitlab/-/issues/345475
.
parent
b6571712
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
12 deletions
+22
-12
app/helpers/tab_helper.rb
app/helpers/tab_helper.rb
+13
-9
spec/helpers/tab_helper_spec.rb
spec/helpers/tab_helper_spec.rb
+9
-3
No files found.
app/helpers/tab_helper.rb
View file @
e15a2c31
...
...
@@ -63,6 +63,19 @@ module TabHelper
end
end
# Creates a <gl-badge> for use inside tabs.
#
# html_options - The html_options hash (default: {})
def
gl_tab_counter_badge
(
count
,
html_options
=
{})
gl_badge_tag
(
count
,
{
size: :sm
},
html_options
.
merge
(
class:
[
'gl-tab-counter-badge'
,
*
html_options
[
:class
]]
)
)
end
# Navigation link helper
#
# Returns an `li` element with an 'active' class if the supplied
...
...
@@ -211,12 +224,3 @@ module TabHelper
current_page?
(
options
)
end
end
def
gl_tab_counter_badge
(
count
,
html_options
=
{})
badge_classes
=
%w[badge badge-muted badge-pill gl-badge sm gl-tab-counter-badge]
content_tag
(
:span
,
count
,
class:
[
*
html_options
[
:class
],
badge_classes
].
join
(
' '
),
data:
html_options
[
:data
]
)
end
spec/helpers/tab_helper_spec.rb
View file @
e15a2c31
...
...
@@ -161,18 +161,24 @@ RSpec.describe TabHelper do
describe
'gl_tab_counter_badge'
do
it
'creates a tab counter badge'
do
expect
(
gl_tab_counter_badge
(
1
)).
to
eq
(
'<span class="badge badge-muted badge-pill gl-badge sm gl-tab-counter-badge">1</span>'
)
expect
(
helper
.
gl_tab_counter_badge
(
1
)).
to
eq
(
'<span class="gl-badge badge badge-pill badge-muted sm gl-tab-counter-badge">1</span>'
)
end
context
'with extra classes'
do
it
'creates a tab counter badge with the correct class attribute'
do
expect
(
gl_tab_counter_badge
(
1
,
{
class:
'js-test'
})).
to
eq
(
'<span class="js-test badge badge-muted badge-pill gl-badge sm gl-tab-counter-badge">1</span>'
)
expect
(
helper
.
gl_tab_counter_badge
(
1
,
{
class:
'js-test'
})).
to
eq
(
'<span class="gl-badge badge badge-pill badge-muted sm gl-tab-counter-badge js-test">1</span>'
)
end
end
context
'with data attributes'
do
it
'creates a tab counter badge with the data attributes'
do
expect
(
gl_tab_counter_badge
(
1
,
{
data:
{
some_attribute:
'foo'
}
})).
to
eq
(
'<span class="badge badge-muted badge-pill gl-badge sm gl-tab-counter-badge" data-some-attribute="foo">1</span>'
)
expect
(
helper
.
gl_tab_counter_badge
(
1
,
{
data:
{
some_attribute:
'foo'
}
})).
to
eq
(
'<span data-some-attribute="foo" class="gl-badge badge badge-pill badge-muted sm gl-tab-counter-badge">1</span>'
)
end
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