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
0f380821
Commit
0f380821
authored
Jun 04, 2021
by
Chad Woolley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle top nav active for project/group
- Uses existing #nav helper from PageLayoutHelper
parent
653ded79
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
app/helpers/nav/top_nav_helper.rb
app/helpers/nav/top_nav_helper.rb
+4
-4
spec/helpers/nav/top_nav_helper_spec.rb
spec/helpers/nav/top_nav_helper_spec.rb
+31
-0
No files found.
app/helpers/nav/top_nav_helper.rb
View file @
0f380821
...
@@ -24,7 +24,7 @@ module Nav
...
@@ -24,7 +24,7 @@ module Nav
if
explore_nav_link?
(
:projects
)
if
explore_nav_link?
(
:projects
)
builder
.
add_primary_menu_item_with_shortcut
(
builder
.
add_primary_menu_item_with_shortcut
(
href:
explore_root_path
,
href:
explore_root_path
,
active:
active_nav_link?
(
path:
%w[dashboard#show root#show projects#trending projects#starred projects#index]
),
active:
nav
==
'project'
||
active_nav_link?
(
path:
%w[dashboard#show root#show projects#trending projects#starred projects#index]
),
**
projects_menu_item_attrs
**
projects_menu_item_attrs
)
)
end
end
...
@@ -32,7 +32,7 @@ module Nav
...
@@ -32,7 +32,7 @@ module Nav
if
explore_nav_link?
(
:groups
)
if
explore_nav_link?
(
:groups
)
builder
.
add_primary_menu_item_with_shortcut
(
builder
.
add_primary_menu_item_with_shortcut
(
href:
explore_groups_path
,
href:
explore_groups_path
,
active:
active_nav_link?
(
controller:
[
:groups
,
'groups/milestones'
,
'groups/group_members'
]),
active:
nav
==
'group'
||
active_nav_link?
(
controller:
[
:groups
,
'groups/milestones'
,
'groups/group_members'
]),
**
groups_menu_item_attrs
**
groups_menu_item_attrs
)
)
end
end
...
@@ -59,7 +59,7 @@ module Nav
...
@@ -59,7 +59,7 @@ module Nav
current_item
=
project
?
current_project
(
project:
project
)
:
{}
current_item
=
project
?
current_project
(
project:
project
)
:
{}
builder
.
add_primary_menu_item_with_shortcut
(
builder
.
add_primary_menu_item_with_shortcut
(
active:
active_nav_link?
(
path:
%w[root#index projects#trending projects#starred dashboard/projects#index]
),
active:
nav
==
'project'
||
active_nav_link?
(
path:
%w[root#index projects#trending projects#starred dashboard/projects#index]
),
css_class:
'qa-projects-dropdown'
,
css_class:
'qa-projects-dropdown'
,
data:
{
track_label:
"projects_dropdown"
,
track_event:
"click_dropdown"
,
track_experiment:
"new_repo"
},
data:
{
track_label:
"projects_dropdown"
,
track_event:
"click_dropdown"
,
track_experiment:
"new_repo"
},
view:
PROJECTS_VIEW
,
view:
PROJECTS_VIEW
,
...
@@ -73,7 +73,7 @@ module Nav
...
@@ -73,7 +73,7 @@ module Nav
current_item
=
group
?
current_group
(
group:
group
)
:
{}
current_item
=
group
?
current_group
(
group:
group
)
:
{}
builder
.
add_primary_menu_item_with_shortcut
(
builder
.
add_primary_menu_item_with_shortcut
(
active:
active_nav_link?
(
path:
%w[dashboard/groups explore/groups]
),
active:
nav
==
'group'
||
active_nav_link?
(
path:
%w[dashboard/groups explore/groups]
),
css_class:
'qa-groups-dropdown'
,
css_class:
'qa-groups-dropdown'
,
data:
{
track_label:
"groups_dropdown"
,
track_event:
"click_dropdown"
},
data:
{
track_label:
"groups_dropdown"
,
track_event:
"click_dropdown"
},
view:
GROUPS_VIEW
,
view:
GROUPS_VIEW
,
...
...
spec/helpers/nav/top_nav_helper_spec.rb
View file @
0f380821
...
@@ -106,6 +106,17 @@ RSpec.describe Nav::TopNavHelper do
...
@@ -106,6 +106,17 @@ RSpec.describe Nav::TopNavHelper do
]
]
expect
(
subject
[
:secondary
]).
to
eq
(
expected_secondary
)
expect
(
subject
[
:secondary
]).
to
eq
(
expected_secondary
)
end
end
context
'with current nav as project'
do
before
do
helper
.
nav
(
'project'
)
end
it
'has expected :active'
do
pp
subject
expect
(
subject
[
:primary
].
detect
{
|
entry
|
entry
[
:id
]
==
'project'
}[
:active
]).
to
eq
(
true
)
end
end
end
end
context
'when current_user is non-admin'
do
context
'when current_user is non-admin'
do
...
@@ -190,6 +201,16 @@ RSpec.describe Nav::TopNavHelper do
...
@@ -190,6 +201,16 @@ RSpec.describe Nav::TopNavHelper do
expect
(
projects_view
[
:linksSecondary
]).
to
eq
(
expected_links_secondary
)
expect
(
projects_view
[
:linksSecondary
]).
to
eq
(
expected_links_secondary
)
end
end
context
'with current nav as project'
do
before
do
helper
.
nav
(
'project'
)
end
it
'has expected :active'
do
expect
(
subject
[
:primary
].
detect
{
|
entry
|
entry
[
:id
]
==
'project'
}[
:active
]).
to
eq
(
true
)
end
end
context
'with persisted project'
do
context
'with persisted project'
do
let_it_be
(
:project
)
{
build_stubbed
(
:project
)
}
let_it_be
(
:project
)
{
build_stubbed
(
:project
)
}
...
@@ -281,6 +302,16 @@ RSpec.describe Nav::TopNavHelper do
...
@@ -281,6 +302,16 @@ RSpec.describe Nav::TopNavHelper do
expect
(
groups_view
[
:linksSecondary
]).
to
eq
(
expected_links_secondary
)
expect
(
groups_view
[
:linksSecondary
]).
to
eq
(
expected_links_secondary
)
end
end
context
'with current nav as group'
do
before
do
helper
.
nav
(
'group'
)
end
it
'has expected :active'
do
expect
(
subject
[
:primary
].
detect
{
|
entry
|
entry
[
:id
]
==
'groups'
}[
:active
]).
to
eq
(
true
)
end
end
context
'with persisted group'
do
context
'with persisted group'
do
let_it_be
(
:group
)
{
build_stubbed
(
:group
)
}
let_it_be
(
:group
)
{
build_stubbed
(
:group
)
}
...
...
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