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,24 +7,28 @@ ...@@ -7,24 +7,28 @@
- link_start = '<a href="%{url}">'.html_safe % { url: help_page_path('PLACEHOLDER') } - 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 } = 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?
= form_for(@dependency_proxy, method: :put, url: group_dependency_proxy_path(@group)) do |f| - if can?(current_user, :admin_group, @group)
.form-group = form_for(@dependency_proxy, method: :put, url: group_dependency_proxy_path(@group)) do |f|
.js-dependency-proxy-toggle-area .form-group
%button{ type: 'button', .js-dependency-proxy-toggle-area
class: "js-project-feature-toggle project-feature-toggle #{'is-checked' if @dependency_proxy.enabled?}", %button{ type: 'button',
"aria-label": s_("DependencyProxy|Toggle Dependency Proxy") } class: "js-project-feature-toggle project-feature-toggle #{'is-checked' if @dependency_proxy.enabled?}",
= f.hidden_field :enabled, { class: 'js-project-feature-toggle-input'} "aria-label": s_("DependencyProxy|Toggle Dependency Proxy") }
%span.toggle-icon = f.hidden_field :enabled, { class: 'js-project-feature-toggle-input'}
= sprite_icon('status_success_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-checked') %span.toggle-icon
= sprite_icon('status_failed_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-unchecked') = sprite_icon('status_success_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-checked')
= sprite_icon('status_failed_borderless', size: 16, css_class: 'toggle-icon-svg toggle-status-unchecked')
- if @dependency_proxy.enabled - if @dependency_proxy.enabled
= render 'groups/dependency_proxies/url' = render 'groups/dependency_proxies/url'
.prepend-top-20 .prepend-top-20
= f.submit 'Save changes', class: 'btn btn-success' = f.submit 'Save changes', class: 'btn btn-success'
- else
- if @dependency_proxy.enabled
= render 'groups/dependency_proxies/url'
- else - else
- if @dependency_proxy.enabled .alert.alert-info
= render 'groups/dependency_proxies/url' = _('Dependency proxy feature is limited to public groups for now.')
...@@ -16,7 +16,7 @@ describe 'Group Dependency Proxy' do ...@@ -16,7 +16,7 @@ describe 'Group Dependency Proxy' do
stub_licensed_features(dependency_proxy: true) stub_licensed_features(dependency_proxy: true)
end end
describe 'feature settings', :js do describe 'feature settings' do
context 'when not logged in' do context 'when not logged in' do
it 'does not show the feature settings' do it 'does not show the feature settings' do
visit path visit path
...@@ -27,74 +27,89 @@ describe 'Group Dependency Proxy' do ...@@ -27,74 +27,89 @@ describe 'Group Dependency Proxy' do
end end
context 'when logged in as group owner' do context 'when logged in as group owner' do
before do context 'feature is available', :js do
sign_in(owner) before do
visit path sign_in(owner)
end visit path
it 'toggle 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
end
context 'when disabled' do
it 'does not show the proxy URL' do
expect(page).not_to have_css('.js-dependency-proxy-url')
end end
end
context 'when enabled by owner' do it 'toggles defaults to disabled' do
before do page.within('.js-dependency-proxy-toggle-area') do
page.within('.edit_dependency_proxy_group_setting') do expect(find('.js-project-feature-toggle-input', visible: false).value).to eq('false')
find('.js-project-feature-toggle').click
end end
click_button('Save changes')
wait_for_requests
visit path
end end
it 'shows the proxy URL' do context 'when disabled' do
page.within('.edit_dependency_proxy_group_setting') do it 'does not show the proxy URL' do
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers') expect(page).not_to have_css('.js-dependency-proxy-url')
end end
end end
context 'then when logged in as group developer' do context 'when enabled by owner' do
before do before do
sign_in(developer) page.within('.edit_dependency_proxy_group_setting') do
find('.js-project-feature-toggle').click
end
click_button('Save changes')
wait_for_requests
visit path visit path
end end
it 'does not show the feature toggle' do it 'shows the proxy URL' do
expect(page).not_to have_css('.js-dependency-proxy-toggle-area') page.within('.edit_dependency_proxy_group_setting') do
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
end
end end
it 'shows the proxy URL' do context 'then when logged in as group developer' do
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers') before do
sign_in(developer)
visit path
end
it 'does not show the feature toggle but shows the proxy URL' do
expect(page).not_to have_css('.js-dependency-proxy-toggle-area')
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
end
end end
end end
end end
end
context 'when feature is not available because of license', js: false do context 'feature is not avaible' do
it 'renders 404 page' do before do
stub_licensed_features(dependency_proxy: false) sign_in(owner)
end
context 'group is private' do
let(:group) { create(:group, :private) }
visit path it 'informs user that feature is only available for public groups' do
visit path
expect(page).to have_gitlab_http_status(404) expect(page).to have_content('Dependency proxy feature is limited to public groups for now.')
end end
end end
context 'when feature is disabled globally', js: false do context 'feature is not supported by the license' do
it 'renders 404 page' do it 'renders 404 page' do
disable_feature stub_licensed_features(dependency_proxy: false)
visit path visit path
expect(page).to have_gitlab_http_status(404)
end
end
context 'feature is disabled globally' do
it 'renders 404 page' do
disable_feature
expect(page).to have_gitlab_http_status(404) visit path
expect(page).to have_gitlab_http_status(404)
end
end
end end
end end
end end
......
...@@ -3921,6 +3921,9 @@ msgstr "" ...@@ -3921,6 +3921,9 @@ msgstr ""
msgid "Dependency proxy URL" msgid "Dependency proxy URL"
msgstr "" msgstr ""
msgid "Dependency proxy feature is limited to public groups for now."
msgstr ""
msgid "DependencyProxy|Toggle Dependency Proxy" msgid "DependencyProxy|Toggle Dependency Proxy"
msgstr "" 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