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
59615089
Commit
59615089
authored
Jul 30, 2021
by
Anna Vovchenko
Committed by
David Kim
Jul 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide infrastructure registry when package feature is disabled
parent
106f6bec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
5 deletions
+25
-5
lib/sidebars/projects/menus/packages_registries_menu.rb
lib/sidebars/projects/menus/packages_registries_menu.rb
+6
-2
spec/lib/sidebars/projects/menus/packages_registries_menu_spec.rb
.../sidebars/projects/menus/packages_registries_menu_spec.rb
+19
-3
No files found.
lib/sidebars/projects/menus/packages_registries_menu.rb
View file @
59615089
...
...
@@ -31,7 +31,7 @@ module Sidebars
private
def
packages_registry_menu_item
if
!::
Gitlab
.
config
.
packages
.
enabled
||
!
can?
(
context
.
current_user
,
:read_package
,
context
.
project
)
if
packages_registry_disabled?
return
::
Sidebars
::
NilMenuItem
.
new
(
item_id: :packages_registry
)
end
...
...
@@ -58,7 +58,7 @@ module Sidebars
end
def
infrastructure_registry_menu_item
if
Feature
.
disabled?
(
:infrastructure_registry_page
,
context
.
current_user
,
default_enabled: :yaml
)
if
Feature
.
disabled?
(
:infrastructure_registry_page
,
context
.
current_user
,
default_enabled: :yaml
)
||
packages_registry_disabled?
return
::
Sidebars
::
NilMenuItem
.
new
(
item_id: :infrastructure_registry
)
end
...
...
@@ -69,6 +69,10 @@ module Sidebars
item_id: :infrastructure_registry
)
end
def
packages_registry_disabled?
!::
Gitlab
.
config
.
packages
.
enabled
||
!
can?
(
context
.
current_user
,
:read_package
,
context
.
project
)
end
end
end
end
...
...
spec/lib/sidebars/projects/menus/packages_registries_menu_spec.rb
View file @
59615089
...
...
@@ -51,8 +51,8 @@ RSpec.describe Sidebars::Projects::Menus::PackagesRegistriesMenu do
context
'when Container Registry is not visible'
do
let
(
:registry_enabled
)
{
false
}
it
'
menu link points to Infrastructure Registry page
'
do
expect
(
subject
.
link
).
to
eq
described_class
.
new
(
context
).
renderable_items
.
find
{
|
i
|
i
.
item_id
==
:infrastructure_registry
}.
link
it
'
does not display menu link
'
do
expect
(
subject
.
render?
).
to
eq
false
end
end
end
...
...
@@ -130,10 +130,26 @@ RSpec.describe Sidebars::Projects::Menus::PackagesRegistriesMenu do
is_expected
.
not_to
be_nil
end
context
'when config package setting is disabled'
do
it
'does not add the menu item to the list'
do
stub_config
(
packages:
{
enabled:
false
})
is_expected
.
to
be_nil
end
end
context
'when user cannot read packages'
do
let
(
:user
)
{
nil
}
it
'does not add the menu item to the list'
do
is_expected
.
to
be_nil
end
end
end
context
'when feature flag :infrastructure_registry_page is disabled'
do
it
'
the menu item is not added to list of menu items
'
do
it
'
does not add the menu item to the list
'
do
stub_feature_flags
(
infrastructure_registry_page:
false
)
is_expected
.
to
be_nil
...
...
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