Commit b4d87395 authored by Miguel Rincon's avatar Miguel Rincon

Merge branch '296895-group-setting-to-allow-or-prevent-duplicate-maven-uploads' into 'master'

Enable group setting to allow or prevent duplicate Maven uploads

See merge request gitlab-org/gitlab!53591
parents 3ba01aa2 a4c5c8e8
...@@ -4,11 +4,18 @@ module Groups ...@@ -4,11 +4,18 @@ module Groups
module Settings module Settings
class PackagesAndRegistriesController < Groups::ApplicationController class PackagesAndRegistriesController < Groups::ApplicationController
before_action :authorize_admin_group! before_action :authorize_admin_group!
before_action :verify_packages_enabled!
feature_category :package_registry feature_category :package_registry
def index def index
end end
private
def verify_packages_enabled!
render_404 unless group.packages_feature_enabled?
end
end end
end end
end end
- if group_packages_list_nav?
= nav_link(controller: :packages_and_registries) do
= link_to group_settings_packages_and_registries_path(@group), title: _('Packages & Registries') do
%span
= _('Packages & Registries')
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Kubernetes') = _('Kubernetes')
= render_if_exists 'groups/sidebar/packages' = render 'groups/sidebar/packages'
= render 'layouts/nav/sidebar/analytics_links', links: group_analytics_navbar_links(@group, current_user) = render 'layouts/nav/sidebar/analytics_links', links: group_analytics_navbar_links(@group, current_user)
...@@ -177,11 +177,7 @@ ...@@ -177,11 +177,7 @@
%span %span
= _('CI / CD') = _('CI / CD')
- if Feature.enabled?(:packages_and_registries_group_settings, @group) = render 'groups/sidebar/packages_settings'
= nav_link(controller: :packages_and_registries) do
= link_to group_settings_packages_and_registries_path(@group), title: _('Packages & Registries') do
%span
= _('Packages & Registries')
= render_if_exists "groups/ee/settings_nav" = render_if_exists "groups/ee/settings_nav"
......
---
title: Enable group setting to allow or prevent duplicate Maven uploads
merge_request: 53591
author:
type: added
...@@ -611,6 +611,21 @@ Now navigate to your project's **Packages & Registries** page and view the publi ...@@ -611,6 +611,21 @@ Now navigate to your project's **Packages & Registries** page and view the publi
When you publish a package with the same name or version as an existing package, When you publish a package with the same name or version as an existing package,
the existing package is overwritten. the existing package is overwritten.
#### Do not allow duplicate Maven packages
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/296895) in GitLab Free 13.9.
To prevent users from publishing duplicate Maven packages, you can use the [GraphQl API](../../../api/graphql/reference/index.md#packagesettings) or the UI.
In the UI:
1. For your group, go to **Settings > Packages & Registries**.
1. Expand the **Package Registry** section.
1. Turn on the **Reject duplicates** toggle.
1. Optional. To allow some duplicate packages, in the **Exceptions** box, enter a regex pattern that matches the names of packages you want to allow.
Your changes are automatically saved.
## Install a package ## Install a package
To install a package from the GitLab Package Registry, you must configure To install a package from the GitLab Package Registry, you must configure
......
...@@ -15,9 +15,9 @@ RSpec.describe 'Group Packages & Registries settings' do ...@@ -15,9 +15,9 @@ RSpec.describe 'Group Packages & Registries settings' do
sign_in(user) sign_in(user)
end end
context 'when the feature flag is off' do context 'when packges feature is disabled on the group' do
before do before do
stub_feature_flags(packages_and_registries_group_settings: false) stub_packages_setting(enabled: false)
end end
it 'the menu item is not visible' do it 'the menu item is not visible' do
...@@ -27,9 +27,15 @@ RSpec.describe 'Group Packages & Registries settings' do ...@@ -27,9 +27,15 @@ RSpec.describe 'Group Packages & Registries settings' do
expect(settings_menu).not_to have_content 'Packages & Registries' expect(settings_menu).not_to have_content 'Packages & Registries'
end end
it 'renders 404 when navigating to page' do
visit_settings_page
expect(page).to have_content('Not Found')
end
end end
context 'when the feature flag is on' do context 'when packages feature is enabled on the group' do
it 'the menu item is visible' do it 'the menu item is visible' do
visit group_path(group) visit group_path(group)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment