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
8c7defd3
Commit
8c7defd3
authored
Apr 27, 2021
by
Nicolò Maria Mezzopera
Committed by
Douglas Barbosa Alexandre
Apr 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Cleanup Policy settings to new packages & registries settings page
parent
c0b13f15
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
173 additions
and
70 deletions
+173
-70
app/assets/javascripts/pages/projects/settings/packages_and_registries/index/index.js
.../projects/settings/packages_and_registries/index/index.js
+5
-0
app/controllers/projects/settings/packages_and_registries_controller.rb
...s/projects/settings/packages_and_registries_controller.rb
+23
-0
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+11
-0
app/views/layouts/nav/sidebar/_project_menus.html.haml
app/views/layouts/nav/sidebar/_project_menus.html.haml
+5
-0
app/views/projects/settings/packages_and_registries/index.html.haml
...projects/settings/packages_and_registries/index.html.haml
+16
-0
config/routes/project.rb
config/routes/project.rb
+2
-0
ee/spec/features/projects/navbar_spec.rb
ee/spec/features/projects/navbar_spec.rb
+1
-0
spec/features/projects/navbar_spec.rb
spec/features/projects/navbar_spec.rb
+20
-0
spec/features/projects/settings/registry_settings_spec.rb
spec/features/projects/settings/registry_settings_spec.rb
+90
-70
No files found.
app/assets/javascripts/pages/projects/settings/packages_and_registries/index/index.js
0 → 100644
View file @
8c7defd3
import
registrySettingsApp
from
'
~/packages_and_registries/settings/project/registry_settings_bundle
'
;
import
initSettingsPanels
from
'
~/settings_panels
'
;
registrySettingsApp
();
initSettingsPanels
();
app/controllers/projects/settings/packages_and_registries_controller.rb
0 → 100644
View file @
8c7defd3
# frozen_string_literal: true
module
Projects
module
Settings
class
PackagesAndRegistriesController
<
Projects
::
ApplicationController
layout
'project_settings'
before_action
:authorize_admin_project!
before_action
:packages_and_registries_settings_enabled!
feature_category
:package_registry
def
index
end
private
def
packages_and_registries_settings_enabled!
render_404
unless
settings_packages_and_registries_enabled?
(
project
)
end
end
end
end
app/helpers/projects_helper.rb
View file @
8c7defd3
...
...
@@ -743,6 +743,7 @@ module ProjectsHelper
operations#show
badges#index
pages#show
packages_and_registries#index
]
end
...
...
@@ -782,6 +783,16 @@ module ProjectsHelper
end
def
settings_container_registry_expiration_policy_available?
(
project
)
Feature
.
disabled?
(
:sidebar_refactor
)
&&
can_destroy_container_registry_image?
(
current_user
,
project
)
end
def
settings_packages_and_registries_enabled?
(
project
)
Feature
.
enabled?
(
:sidebar_refactor
)
&&
can_destroy_container_registry_image?
(
current_user
,
project
)
end
def
can_destroy_container_registry_image?
(
current_user
,
project
)
Gitlab
.
config
.
registry
.
enabled
&&
can?
(
current_user
,
:destroy_container_image
,
project
)
end
...
...
app/views/layouts/nav/sidebar/_project_menus.html.haml
View file @
8c7defd3
...
...
@@ -274,6 +274,11 @@
=
link_to
project_pages_path
(
@project
),
title:
_
(
'Pages'
)
do
%span
=
_
(
'Pages'
)
-
if
settings_packages_and_registries_enabled?
(
@project
)
=
nav_link
(
controller: :packages_and_registries
)
do
=
link_to
project_settings_packages_and_registries_path
(
@project
),
title:
_
(
'Packages & Registries'
),
data:
{
qa_selector:
'project_package_settings_link'
}
do
%span
=
_
(
'Packages & Registries'
)
-# Shortcut to Project > Activity
%li
.hidden
...
...
app/views/projects/settings/packages_and_registries/index.html.haml
0 → 100644
View file @
8c7defd3
-
breadcrumb_title
_
(
'Packages & Registries'
)
-
page_title
_
(
'Packages & Registries'
)
-
@content_class
=
'limit-container-width'
unless
fluid_layout
-
expanded
=
true
%section
.settings.no-animate
#js-registry-policies
{
class:
(
'expanded'
if
expanded
)
}
.settings-header
%h4
.settings-title.js-settings-toggle.js-settings-toggle-trigger-only
=
_
(
"Clean up image tags"
)
%button
.btn.gl-button.btn-default.js-settings-toggle
{
type:
'button'
}
=
expanded
?
_
(
'Collapse'
)
:
_
(
'Expand'
)
%p
=
_
(
"Save space and find images in the Container Registry. Remove unneeded tags and keep only the ones you want."
)
=
link_to
_
(
'How does cleanup work?'
),
help_page_path
(
'user/packages/container_registry/index'
,
anchor:
'cleanup-policy'
),
target:
'_blank'
,
rel:
'noopener noreferrer'
.settings-content
=
render
'projects/registry/settings/index'
config/routes/project.rb
View file @
8c7defd3
...
...
@@ -129,6 +129,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
put
:revoke
end
end
resources
:packages_and_registries
,
only:
[
:index
]
end
resources
:autocomplete_sources
,
only:
[]
do
...
...
ee/spec/features/projects/navbar_spec.rb
View file @
8c7defd3
...
...
@@ -61,6 +61,7 @@ RSpec.describe 'Project navbar' do
context
'when packages are available'
do
before
do
stub_config
(
packages:
{
enabled:
true
},
registry:
{
enabled:
false
})
stub_feature_flags
(
sidebar_refactor:
false
)
visit
project_path
(
project
)
end
...
...
spec/features/projects/navbar_spec.rb
View file @
8c7defd3
...
...
@@ -12,6 +12,7 @@ RSpec.describe 'Project navbar' do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
stub_feature_flags
(
sidebar_refactor:
false
)
insert_package_nav
(
_
(
'Operations'
))
insert_infrastructure_registry_nav
stub_config
(
registry:
{
enabled:
false
})
...
...
@@ -69,4 +70,23 @@ RSpec.describe 'Project navbar' do
it_behaves_like
'verified navigation bar'
end
context
'when sidebar refactor feature flag is on'
do
before
do
stub_feature_flags
(
sidebar_refactor:
true
)
stub_config
(
registry:
{
enabled:
true
})
insert_container_nav
insert_after_sub_nav_item
(
_
(
'Operations'
),
within:
_
(
'Settings'
),
new_sub_nav_item_name:
_
(
'Packages & Registries'
)
)
visit
project_path
(
project
)
end
it_behaves_like
'verified navigation bar'
end
end
spec/features/projects/settings/registry_settings_spec.rb
View file @
8c7defd3
...
...
@@ -11,105 +11,125 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
let
(
:container_registry_enabled
)
{
true
}
let
(
:container_registry_enabled_on_project
)
{
true
}
subject
{
visit
project_settings_ci_cd_path
(
project
)
}
shared_examples
'an expiration policy form'
do
before
do
project
.
update!
(
container_registry_enabled:
container_registry_enabled_on_project
)
project
.
container_expiration_policy
.
update!
(
enabled:
true
)
before
do
project
.
update!
(
container_registry_enabled:
container_registry_enabled_on_project
)
project
.
container_expiration_policy
.
update!
(
enabled:
true
)
sign_in
(
user
)
stub_container_registry_config
(
enabled:
container_registry_enabled
)
end
sign_in
(
user
)
stub_container_registry_config
(
enabled:
container_registry_enabled
)
end
context
'as owner'
do
it
'shows available section'
do
subject
context
'as owner'
do
it
'shows available section'
do
subject
settings_block
=
find
(
'#js-registry-policies'
)
expect
(
settings_block
).
to
have_text
'Clean up image tags'
end
settings_block
=
find
(
'#js-registry-policies'
)
expect
(
settings_block
).
to
have_text
'Clean up image tags'
end
it
'saves cleanup policy submit the form'
do
subject
it
'saves cleanup policy submit the form'
do
subject
within
'#js-registry-policies'
do
select
(
'Every day'
,
from:
'Run cleanup'
)
select
(
'50 tags per image name'
,
from:
'Keep the most recent:'
)
fill_in
(
'Keep tags matching:'
,
with:
'stable'
)
select
(
'7 days'
,
from:
'Remove tags older than:'
)
fill_in
(
'Remove tags matching:'
,
with:
'.*-production'
)
submit_button
=
find
(
'[data-testid="save-button"'
)
expect
(
submit_button
).
not_to
be_disabled
submit_button
.
click
end
within
'#js-registry-policies'
do
select
(
'Every day'
,
from:
'Run cleanup'
)
select
(
'50 tags per image name'
,
from:
'Keep the most recent:'
)
fill_in
(
'Keep tags matching:'
,
with:
'stable'
)
select
(
'7 days'
,
from:
'Remove tags older than:'
)
fill_in
(
'Remove tags matching:'
,
with:
'.*-production'
)
expect
(
find
(
'.gl-toast'
)).
to
have_content
(
'Cleanup policy successfully saved.'
)
end
submit_button
=
find
(
'[data-testid="save-button"'
)
expect
(
submit_button
).
not_to
be_disabled
submit_button
.
click
it
'does not save cleanup policy submit form with invalid regex'
do
subject
within
'#js-registry-policies'
do
fill_in
(
'Remove tags matching:'
,
with:
'*-production'
)
submit_button
=
find
(
'[data-testid="save-button"'
)
expect
(
submit_button
).
not_to
be_disabled
submit_button
.
click
end
expect
(
find
(
'.gl-toast'
)).
to
have_content
(
'Something went wrong while updating the cleanup policy.'
)
end
toast
=
find
(
'.gl-toast'
)
expect
(
toast
).
to
have_content
(
'Cleanup policy successfully saved.'
)
end
it
'does not save cleanup policy submit form with invalid regex'
do
subject
context
'with a project without expiration policy'
do
where
(
:application_setting
,
:feature_flag
,
:result
)
do
true
|
true
|
:available_section
true
|
false
|
:available_section
false
|
true
|
:available_section
false
|
false
|
:disabled_message
end
within
'#js-registry-policies'
do
fill_in
(
'Remove tags matching:'
,
with:
'*-production'
)
with_them
do
before
do
project
.
container_expiration_policy
.
destroy!
stub_feature_flags
(
container_expiration_policies_historic_entry:
false
)
stub_application_setting
(
container_expiration_policies_enable_historic_entries:
application_setting
)
stub_feature_flags
(
container_expiration_policies_historic_entry:
project
)
if
feature_flag
end
submit_button
=
find
(
'[data-testid="save-button"'
)
expect
(
submit_button
).
not_to
be_disabled
submit_button
.
click
it
'displays the expected result'
do
subject
within
'#js-registry-policies'
do
case
result
when
:available_section
expect
(
find
(
'[data-testid="enable-toggle"]'
)).
to
have_content
(
'Disabled - Tags will not be automatically deleted.'
)
when
:disabled_message
expect
(
find
(
'.gl-alert-title'
)).
to
have_content
(
'Cleanup policy for tags is disabled'
)
end
end
end
end
toast
=
find
(
'.gl-toast'
)
expect
(
toast
).
to
have_content
(
'Something went wrong while updating the cleanup policy.'
)
end
end
context
'with a project without expiration policy'
do
where
(
:application_setting
,
:feature_flag
,
:result
)
do
true
|
true
|
:available_section
true
|
false
|
:available_section
false
|
true
|
:available_section
false
|
false
|
:disabled_message
end
context
'when registry is disabled'
do
let
(
:container_registry_enabled
)
{
false
}
it
'does not exists'
do
subject
with_them
do
before
do
project
.
container_expiration_policy
.
destroy!
stub_feature_flags
(
container_expiration_policies_historic_entry:
false
)
stub_application_setting
(
container_expiration_policies_enable_historic_entries:
application_setting
)
stub_feature_flags
(
container_expiration_policies_historic_entry:
project
)
if
feature_flag
expect
(
page
).
not_to
have_selector
(
'#js-registry-policies'
)
end
end
it
'displays the expected result'
do
context
'when container registry is disabled on project'
do
let
(
:container_registry_enabled_on_project
)
{
false
}
it
'does not exists'
do
subject
within
'#js-registry-policies'
do
case
result
when
:available_section
expect
(
find
(
'[data-testid="enable-toggle"]'
)).
to
have_content
(
'Disabled - Tags will not be automatically deleted.'
)
when
:disabled_message
expect
(
find
(
'.gl-alert-title'
)).
to
have_content
(
'Cleanup policy for tags is disabled'
)
end
end
expect
(
page
).
not_to
have_selector
(
'#js-registry-policies'
)
end
end
end
context
'w
hen registry is disabled
'
do
let
(
:container_registry_enabled
)
{
false
}
context
'w
ith sidebar feature flag off
'
do
subject
{
visit
project_settings_ci_cd_path
(
project
)
}
it
'does not exists'
do
subject
expect
(
page
).
not_to
have_selector
(
'#js-registry-policies'
)
before
do
stub_feature_flags
(
sidebar_refactor:
false
)
end
end
context
'when container registry is disabled on project'
do
let
(
:container_registry_enabled_on_project
)
{
false
}
it_behaves_like
'an expiration policy form'
end
it
'does not exists
'
do
subject
context
'with sidebar feature flag on
'
do
subject
{
visit
project_settings_packages_and_registries_path
(
project
)
}
expect
(
page
).
not_to
have_selector
(
'#js-registry-policies'
)
before
do
stub_feature_flags
(
sidebar_refactor:
true
)
end
it_behaves_like
'an expiration policy form'
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