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
Show 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
...
@@ -743,6 +743,7 @@ module ProjectsHelper
operations#show
operations#show
badges#index
badges#index
pages#show
pages#show
packages_and_registries#index
]
]
end
end
...
@@ -782,6 +783,16 @@ module ProjectsHelper
...
@@ -782,6 +783,16 @@ module ProjectsHelper
end
end
def
settings_container_registry_expiration_policy_available?
(
project
)
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
&&
Gitlab
.
config
.
registry
.
enabled
&&
can?
(
current_user
,
:destroy_container_image
,
project
)
can?
(
current_user
,
:destroy_container_image
,
project
)
end
end
...
...
app/views/layouts/nav/sidebar/_project_menus.html.haml
View file @
8c7defd3
...
@@ -274,6 +274,11 @@
...
@@ -274,6 +274,11 @@
=
link_to
project_pages_path
(
@project
),
title:
_
(
'Pages'
)
do
=
link_to
project_pages_path
(
@project
),
title:
_
(
'Pages'
)
do
%span
%span
=
_
(
'Pages'
)
=
_
(
'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
-# Shortcut to Project > Activity
%li
.hidden
%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
...
@@ -129,6 +129,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
put
:revoke
put
:revoke
end
end
end
end
resources
:packages_and_registries
,
only:
[
:index
]
end
end
resources
:autocomplete_sources
,
only:
[]
do
resources
:autocomplete_sources
,
only:
[]
do
...
...
ee/spec/features/projects/navbar_spec.rb
View file @
8c7defd3
...
@@ -61,6 +61,7 @@ RSpec.describe 'Project navbar' do
...
@@ -61,6 +61,7 @@ RSpec.describe 'Project navbar' do
context
'when packages are available'
do
context
'when packages are available'
do
before
do
before
do
stub_config
(
packages:
{
enabled:
true
},
registry:
{
enabled:
false
})
stub_config
(
packages:
{
enabled:
true
},
registry:
{
enabled:
false
})
stub_feature_flags
(
sidebar_refactor:
false
)
visit
project_path
(
project
)
visit
project_path
(
project
)
end
end
...
...
spec/features/projects/navbar_spec.rb
View file @
8c7defd3
...
@@ -12,6 +12,7 @@ RSpec.describe 'Project navbar' do
...
@@ -12,6 +12,7 @@ RSpec.describe 'Project navbar' do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
before
do
stub_feature_flags
(
sidebar_refactor:
false
)
insert_package_nav
(
_
(
'Operations'
))
insert_package_nav
(
_
(
'Operations'
))
insert_infrastructure_registry_nav
insert_infrastructure_registry_nav
stub_config
(
registry:
{
enabled:
false
})
stub_config
(
registry:
{
enabled:
false
})
...
@@ -69,4 +70,23 @@ RSpec.describe 'Project navbar' do
...
@@ -69,4 +70,23 @@ RSpec.describe 'Project navbar' do
it_behaves_like
'verified navigation bar'
it_behaves_like
'verified navigation bar'
end
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
end
spec/features/projects/settings/registry_settings_spec.rb
View file @
8c7defd3
...
@@ -11,8 +11,7 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
...
@@ -11,8 +11,7 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
let
(
:container_registry_enabled
)
{
true
}
let
(
:container_registry_enabled
)
{
true
}
let
(
:container_registry_enabled_on_project
)
{
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
before
do
project
.
update!
(
container_registry_enabled:
container_registry_enabled_on_project
)
project
.
update!
(
container_registry_enabled:
container_registry_enabled_on_project
)
project
.
container_expiration_policy
.
update!
(
enabled:
true
)
project
.
container_expiration_policy
.
update!
(
enabled:
true
)
...
@@ -43,8 +42,8 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
...
@@ -43,8 +42,8 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
expect
(
submit_button
).
not_to
be_disabled
expect
(
submit_button
).
not_to
be_disabled
submit_button
.
click
submit_button
.
click
end
end
toast
=
find
(
'.gl-toast'
)
expect
(
toast
).
to
have_content
(
'Cleanup policy successfully saved.'
)
expect
(
find
(
'.gl-toast'
)
).
to
have_content
(
'Cleanup policy successfully saved.'
)
end
end
it
'does not save cleanup policy submit form with invalid regex'
do
it
'does not save cleanup policy submit form with invalid regex'
do
...
@@ -57,8 +56,8 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
...
@@ -57,8 +56,8 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
expect
(
submit_button
).
not_to
be_disabled
expect
(
submit_button
).
not_to
be_disabled
submit_button
.
click
submit_button
.
click
end
end
toast
=
find
(
'.gl-toast'
)
expect
(
toast
).
to
have_content
(
'Something went wrong while updating the cleanup policy.'
)
expect
(
find
(
'.gl-toast'
)
).
to
have_content
(
'Something went wrong while updating the cleanup policy.'
)
end
end
end
end
...
@@ -112,4 +111,25 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
...
@@ -112,4 +111,25 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
expect
(
page
).
not_to
have_selector
(
'#js-registry-policies'
)
expect
(
page
).
not_to
have_selector
(
'#js-registry-policies'
)
end
end
end
end
end
context
'with sidebar feature flag off'
do
subject
{
visit
project_settings_ci_cd_path
(
project
)
}
before
do
stub_feature_flags
(
sidebar_refactor:
false
)
end
it_behaves_like
'an expiration policy form'
end
context
'with sidebar feature flag on'
do
subject
{
visit
project_settings_packages_and_registries_path
(
project
)
}
before
do
stub_feature_flags
(
sidebar_refactor:
true
)
end
it_behaves_like
'an expiration policy form'
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