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
700086b4
Commit
700086b4
authored
May 27, 2021
by
Denys Mishunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce `has-sub-items` class to top links
parent
a663a5e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
0 deletions
+68
-0
lib/sidebars/menu.rb
lib/sidebars/menu.rb
+11
-0
lib/sidebars/projects/menus/scope_menu.rb
lib/sidebars/projects/menus/scope_menu.rb
+5
-0
spec/lib/sidebars/menu_spec.rb
spec/lib/sidebars/menu_spec.rb
+52
-0
No files found.
lib/sidebars/menu.rb
View file @
700086b4
...
...
@@ -83,6 +83,17 @@ module Sidebars
insert_element_after
(
@items
,
after_item
,
new_item
)
end
override
:container_html_options
def
container_html_options
super
.
tap
do
|
html_options
|
# Flagging menus that can be rendered but without any children
# like the merge requests or the requirements menu
if
render?
&&
has_renderable_items?
html_options
[
:class
]
=
[
*
html_options
[
:class
],
'has-sub-items'
].
join
(
' '
)
end
end
end
private
override
:index_of
...
...
lib/sidebars/projects/menus/scope_menu.rb
View file @
700086b4
...
...
@@ -34,6 +34,11 @@ module Sidebars
{
class:
'context-header'
}
end
override
:render?
def
render?
true
end
end
end
end
...
...
spec/lib/sidebars/menu_spec.rb
View file @
700086b4
...
...
@@ -144,4 +144,56 @@ RSpec.describe Sidebars::Menu do
end
end
end
describe
'#container_html_options'
do
before
do
allow
(
menu
).
to
receive
(
:title
).
and_return
(
'Foo Menu'
)
end
context
'when menu can be rendered'
do
before
do
allow
(
menu
).
to
receive
(
:render?
).
and_return
(
true
)
end
context
'when menu has renderable items'
do
before
do
allow
(
menu
).
to
receive
(
:has_renderable_items?
).
and_return
(
true
)
end
it
'contains the special class'
do
menu
.
add_item
(
Sidebars
::
MenuItem
.
new
(
title:
'foo1'
,
link:
'foo1'
,
active_routes:
{
path:
'bar'
}))
expect
(
menu
.
container_html_options
[
:class
]).
to
eq
'has-sub-items'
end
context
'when menu already has other classes'
do
it
'appends special class'
do
allow
(
menu
).
to
receive
(
:extra_container_html_options
).
and_return
(
class:
'foo'
)
expect
(
menu
.
container_html_options
[
:class
]).
to
eq
'foo has-sub-items'
end
end
end
context
'when menu does not have renderable items'
do
before
do
allow
(
menu
).
to
receive
(
:has_renderable_items?
).
and_return
(
false
)
end
it
'does not contain the special class'
do
expect
(
menu
.
container_html_options
[
:class
]).
to
be_nil
end
end
end
context
'when menu cannot be rendered'
do
before
do
allow
(
menu
).
to
receive
(
:render?
).
and_return
(
false
)
end
it
'does not contain "has-sub-items" class'
do
expect
(
menu
.
container_html_options
[
:class
]).
to
be_nil
end
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