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
ef09a654
Commit
ef09a654
authored
Jun 11, 2021
by
Nourdin el Bacha
Committed by
Paul Slaughter
Jun 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conditionally render create group buttons
- This is added to the old and new top nav Changelog: fixed
parent
91604ec8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
app/helpers/nav/top_nav_helper.rb
app/helpers/nav/top_nav_helper.rb
+5
-1
app/views/layouts/nav/groups_dropdown/_show.html.haml
app/views/layouts/nav/groups_dropdown/_show.html.haml
+7
-6
spec/helpers/nav/top_nav_helper_spec.rb
spec/helpers/nav/top_nav_helper_spec.rb
+9
-0
No files found.
app/helpers/nav/top_nav_helper.rb
View file @
ef09a654
...
...
@@ -276,7 +276,11 @@ module Nav
builder
=
::
Gitlab
::
Nav
::
TopNavMenuBuilder
.
new
builder
.
add_primary_menu_item
(
id:
'your'
,
title:
_
(
'Your groups'
),
href:
dashboard_groups_path
)
builder
.
add_primary_menu_item
(
id:
'explore'
,
title:
_
(
'Explore groups'
),
href:
explore_groups_path
)
builder
.
add_secondary_menu_item
(
id:
'create'
,
title:
_
(
'Create group'
),
href:
new_group_path
)
if
current_user
.
can_create_group?
builder
.
add_secondary_menu_item
(
id:
'create'
,
title:
_
(
'Create group'
),
href:
new_group_path
)
end
builder
.
build
end
end
...
...
app/views/layouts/nav/groups_dropdown/_show.html.haml
View file @
ef09a654
...
...
@@ -12,11 +12,12 @@
=
nav_link
(
path:
'groups#explore'
)
do
=
link_to
explore_groups_path
,
data:
{
track_label:
"groups_dropdown_explore_groups"
,
track_event:
"click_link"
}
do
=
_
(
'Explore groups'
)
=
nav_link
(
path:
'groups/new#create-group-pane'
,
html_options:
{
class:
'gl-border-0 gl-border-t-1 gl-border-solid gl-border-gray-100'
})
do
=
link_to
new_group_path
(
anchor:
'create-group-pane'
),
data:
{
track_label:
"groups_dropdown_create_group"
,
track_event:
"click_link"
}
do
=
_
(
'Create group'
)
=
nav_link
(
path:
'groups/new#import-group-pane'
)
do
=
link_to
new_group_path
(
anchor:
'import-group-pane'
),
data:
{
track_label:
"groups_dropdown_import_group"
,
track_event:
"click_link"
}
do
=
_
(
'Import group'
)
-
if
current_user
.
can_create_group?
=
nav_link
(
path:
'groups/new#create-group-pane'
,
html_options:
{
class:
'gl-border-0 gl-border-t-1 gl-border-solid gl-border-gray-100'
})
do
=
link_to
new_group_path
(
anchor:
'create-group-pane'
),
data:
{
track_label:
"groups_dropdown_create_group"
,
track_event:
"click_link"
}
do
=
_
(
'Create group'
)
=
nav_link
(
path:
'groups/new#import-group-pane'
)
do
=
link_to
new_group_path
(
anchor:
'import-group-pane'
),
data:
{
track_label:
"groups_dropdown_import_group"
,
track_event:
"click_link"
}
do
=
_
(
'Import group'
)
.frequent-items-dropdown-content
#js-groups-dropdown
{
data:
{
user_name:
current_user
.
username
,
group:
group_meta
}
}
spec/helpers/nav/top_nav_helper_spec.rb
View file @
ef09a654
...
...
@@ -7,6 +7,7 @@ RSpec.describe Nav::TopNavHelper do
let_it_be
(
:user
)
{
build_stubbed
(
:user
)
}
let_it_be
(
:admin
)
{
build_stubbed
(
:user
,
:admin
)
}
let_it_be
(
:external_user
)
{
build_stubbed
(
:user
,
:external
,
can_create_group:
false
)
}
let
(
:current_user
)
{
nil
}
...
...
@@ -305,6 +306,14 @@ RSpec.describe Nav::TopNavHelper do
expect
(
groups_view
[
:linksSecondary
]).
to
eq
(
expected_links_secondary
)
end
context
'with external user'
do
let
(
:current_user
)
{
external_user
}
it
'does not have create group link'
do
expect
(
groups_view
[
:linksSecondary
]).
to
eq
([])
end
end
context
'with current nav as group'
do
before
do
helper
.
nav
(
'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