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 @@
- 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)
= form_for(@dependency_proxy, method: :put, url: group_dependency_proxy_path(@group)) do |f|
.form-group
.js-dependency-proxy-toggle-area
%button{ type: 'button',
class: "js-project-feature-toggle project-feature-toggle #{'is-checked' if @dependency_proxy.enabled?}",
"aria-label": s_("DependencyProxy|Toggle Dependency Proxy") }
= f.hidden_field :enabled, { class: 'js-project-feature-toggle-input'}
%span.toggle-icon
= 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 @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
%button{ type: 'button',
class: "js-project-feature-toggle project-feature-toggle #{'is-checked' if @dependency_proxy.enabled?}",
"aria-label": s_("DependencyProxy|Toggle Dependency Proxy") }
= f.hidden_field :enabled, { class: 'js-project-feature-toggle-input'}
%span.toggle-icon
= 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
= render 'groups/dependency_proxies/url'
- if @dependency_proxy.enabled
= render 'groups/dependency_proxies/url'
.prepend-top-20
= f.submit 'Save changes', class: 'btn btn-success'
.prepend-top-20
= f.submit 'Save changes', class: 'btn btn-success'
- else
- if @dependency_proxy.enabled
= render 'groups/dependency_proxies/url'
- else
- if @dependency_proxy.enabled
= render 'groups/dependency_proxies/url'
.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,74 +27,89 @@ describe 'Group Dependency Proxy' do
end
context 'when logged in as group owner' do
before do
sign_in(owner)
visit path
end
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')
context 'feature is available', :js do
before do
sign_in(owner)
visit path
end
end
context 'when enabled by owner' do
before do
page.within('.edit_dependency_proxy_group_setting') do
find('.js-project-feature-toggle').click
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
click_button('Save changes')
wait_for_requests
visit path
end
it 'shows the proxy URL' do
page.within('.edit_dependency_proxy_group_setting') do
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
context 'when disabled' do
it 'does not show the proxy URL' do
expect(page).not_to have_css('.js-dependency-proxy-url')
end
end
context 'then when logged in as group developer' do
context 'when enabled by owner' 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
end
it 'does not show the feature toggle' do
expect(page).not_to have_css('.js-dependency-proxy-toggle-area')
it 'shows the proxy URL' do
page.within('.edit_dependency_proxy_group_setting') do
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
end
end
it 'shows the proxy URL' do
expect(find('.js-dependency-proxy-url').value).to have_content('/dependency_proxy/containers')
context 'then when logged in as group developer' do
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
context 'when feature is not available because of license', js: false do
it 'renders 404 page' do
stub_licensed_features(dependency_proxy: false)
context 'feature is not avaible' do
before do
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)
end
end
expect(page).to have_content('Dependency proxy feature is limited to public groups for now.')
end
end
context 'when feature is disabled globally', js: false do
it 'renders 404 page' do
disable_feature
context 'feature is not supported by the license' do
it 'renders 404 page' do
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
......
......@@ -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