summaryrefslogtreecommitdiff
path: root/app/controllers/groups/dependency_proxies_controller.rb
blob: b896b240daf1372b3f45cb7e2ab3b6861f66dff2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

module Groups
  class DependencyProxiesController < Groups::ApplicationController
    include DependencyProxy::GroupAccess

    before_action :authorize_admin_dependency_proxy!, only: :update
    before_action :dependency_proxy

    feature_category :package_registry

    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