Commit ae07c203 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'dz-dependency-proxy-private-group' into 'master'

Hide dependency proxy setting for private groups

Closes #11610

See merge request gitlab-org/gitlab-ee!12716
parents 914cccb0 2ab64cc4
......@@ -7,7 +7,8 @@
- link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('PLACEHOLDER') }
= s_('Create a local proxy for storing frequently used upstream images. %{link_start}Learn more%{link_end} about dependency proxies.').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
- if can?(current_user, :admin_group, @group)
- if @group.public?
- if can?(current_user, :admin_group, @group)
= form_for(@dependency_proxy, method: :put, url: group_dependency_proxy_path(@group)) do |f|
.form-group
.js-dependency-proxy-toggle-area
......@@ -25,6 +26,9 @@
.prepend-top-20
= f.submit 'Save changes', class: 'btn btn-success'
- else
- else
- if @dependency_proxy.enabled
= render 'groups/dependency_proxies/url'
- else
.alert.alert-info
= _('Dependency proxy feature is limited to public groups for now.')
......@@ -16,7 +16,7 @@ describe 'Group Dependency Proxy' do
stub_licensed_features(dependency_proxy: true)
end
describe 'feature settings', :js do
describe 'feature settings' do
context 'when not logged in' do
it 'does not show the feature settings' do
visit path
......@@ -27,12 +27,13 @@ describe 'Group Dependency Proxy' do
end
context 'when logged in as group owner' do
context 'feature is available', :js do
before do
sign_in(owner)
visit path
end
it 'toggle defaults to disabled' do
it 'toggles defaults to disabled' do
page.within('.js-dependency-proxy-toggle-area') do
expect(find('.js-project-feature-toggle-input', visible: false).value).to eq('false')
end
......@@ -67,18 +68,30 @@ describe 'Group Dependency Proxy' do
visit path
end
it 'does not show the feature toggle' do
it 'does not show the feature toggle but shows the proxy URL' do
expect(page).not_to have_css('.js-dependency-proxy-toggle-area')
end
it 'shows the proxy URL' do
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
end
end
end
end
context 'when feature is not available because of license', js: false do
context 'feature is not avaible' do
before do
sign_in(owner)
end
context 'group is private' do
let(:group) { create(:group, :private) }
it 'informs user that feature is only available for public groups' do
visit path
expect(page).to have_content('Dependency proxy feature is limited to public groups for now.')
end
end
context 'feature is not supported by the license' do
it 'renders 404 page' do
stub_licensed_features(dependency_proxy: false)
......@@ -88,7 +101,7 @@ describe 'Group Dependency Proxy' do
end
end
context 'when feature is disabled globally', js: false do
context 'feature is disabled globally' do
it 'renders 404 page' do
disable_feature
......@@ -98,6 +111,8 @@ describe 'Group Dependency Proxy' do
end
end
end
end
end
def enable_feature
allow(Gitlab.config.dependency_proxy).to receive(:enabled).and_return(true)
......
......@@ -3936,6 +3936,9 @@ msgstr ""
msgid "Dependency proxy URL"
msgstr ""
msgid "Dependency proxy feature is limited to public groups for now."
msgstr ""
msgid "DependencyProxy|Toggle Dependency Proxy"
msgstr ""
......
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