Commit 2ab64cc4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve dependency proxy feature UI

Hide feature toggle control for non public group. Show user the message
that only public groups are supported for now.
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 90b0e3c2
......@@ -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)
......
......@@ -3921,6 +3921,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