Commit fa1f244c authored by Tim Zallmann's avatar Tim Zallmann

Merge branch 'dz-registry-proxy-ui' into 'master'

UI for Dependency proxy for containers

See merge request gitlab-org/gitlab-ee!10386
parents 9e4994ab c2bd1a21
......@@ -46,6 +46,7 @@
= _('Contribution Analytics')
= render_if_exists 'layouts/nav/group_insights_link'
= render_if_exists 'groups/sidebar/dependency_proxy' # EE-specific
= render_if_exists "layouts/nav/ee/epic_link", group: @group
......
import setupToggleButtons from '~/toggle_buttons';
export default () => {
setupToggleButtons(document.querySelector('.js-dependency-proxy-toggle-area'));
};
import DependencyProxy from 'ee/dependency_proxy';
document.addEventListener('DOMContentLoaded', () => new DependencyProxy());
# frozen_string_literal: true
module Groups
class DependencyProxiesController < Groups::ApplicationController
before_action :authorize_admin_group!, only: :update
before_action :dependency_proxy
def show
@blobs_count = group.dependency_proxy_blobs.count
@blobs_total_size = group.dependency_proxy_blobs.total_size
end
def update
dependency_proxy.update(dependency_proxy_params)
redirect_to group_dependency_proxy_path(group)
end
private
def dependency_proxy
@dependency_proxy ||=
group.dependency_proxy_setting || group.create_dependency_proxy_setting
end
def dependency_proxy_params
params.require(:dependency_proxy_group_setting).permit(:enabled)
end
end
end
......@@ -9,6 +9,7 @@ module EE
super + %w[
groups/security/dashboard#show
groups/insights#show
groups/dependency_proxies#show
]
end
......
%h5.prepend-top-20= _('Dependency proxy URL')
%div
= text_field_tag :url, "#{group_url(@group)}/dependency_proxy/containers", class: 'js-dependency-proxy-url form-control', readonly: true
.help-block.prepend-top-5
= s_('Contains %{count} blobs of images (%{size})') % { count: @blobs_count, size: number_to_human_size(@blobs_total_size) }
- page_title "Dependency Proxy"
.settings-header
%h4= _('Dependency proxy')
%p
- 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 @dependency_proxy.enabled
= render 'groups/dependency_proxies/url'
.prepend-top-20
= f.submit 'Save changes', class: 'btn btn-success'
- else
- if @dependency_proxy.enabled
= render 'groups/dependency_proxies/url'
- if @group.feature_available?(:dependency_proxy)
= nav_link(controller: 'groups/dependency_proxies') do
= link_to group_dependency_proxy_path(@group), title: _('Dependency Proxy') do
%span= _('Dependency Proxy')
---
title: Add UI to enable/disable a dependency proxy on a group level
merge_request: 10386
author:
type: added
......@@ -106,6 +106,8 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
path
end
get 'boards(/*extra_params)', as: :legacy_ee_group_boards_redirect, to: legacy_ee_group_boards_redirect
resource :dependency_proxy, only: [:show, :update]
end
scope(path: 'groups/*group_id') do
......
# frozen_string_literal: true
require 'spec_helper'
describe 'Group Dependency Proxy' do
let(:owner) { create(:user) }
let(:developer) { create(:user) }
let(:group) { create(:group) }
let(:path) { group_dependency_proxy_path(group) }
before do
group.add_owner(owner)
group.add_developer(developer)
end
describe 'feature settings', :js do
context 'when not logged in' do
it 'does not show the feature settings' do
visit path
expect(page).not_to have_css('.js-dependency-proxy-toggle-area')
expect(page).not_to have_css('.js-dependency-proxy-url')
end
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')
end
end
context 'when enabled by owner' do
before do
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 '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
context 'then when logged in as group developer' do
before do
sign_in(developer)
visit path
end
it 'does not show the feature toggle' 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
end
end
......@@ -3345,6 +3345,9 @@ msgstr ""
msgid "ContainerRegistry|You can also use a %{deploy_token} for read-only access to the registry images."
msgstr ""
msgid "Contains %{count} blobs of images (%{size})"
msgstr ""
msgid "Contents of .gitlab-ci.yml"
msgstr ""
......@@ -3501,6 +3504,9 @@ msgstr ""
msgid "Create a GitLab account first, and then connect it to your %{label} account."
msgstr ""
msgid "Create a local proxy for storing frequently used upstream images. %{link_start}Learn more%{link_end} about dependency proxies."
msgstr ""
msgid "Create a merge request."
msgstr ""
......@@ -3873,6 +3879,18 @@ msgstr ""
msgid "Deny"
msgstr ""
msgid "Dependency Proxy"
msgstr ""
msgid "Dependency proxy"
msgstr ""
msgid "Dependency proxy URL"
msgstr ""
msgid "DependencyProxy|Toggle Dependency Proxy"
msgstr ""
msgid "Deploy"
msgid_plural "Deploys"
msgstr[0] ""
......
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