debian-mirror-gitlab/app/controllers/groups/registry/repositories_controller.rb

51 lines
1.5 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
module Groups
module Registry
class RepositoriesController < Groups::ApplicationController
before_action :verify_container_registry_enabled!
before_action :authorize_read_container_image!
before_action :feature_flag_group_container_registry_browser!
def index
respond_to do |format|
format.html
format.json do
@images = group.container_repositories.with_api_entity_associations
2020-03-09 13:42:32 +05:30
track_event(:list_repositories)
serializer = ContainerRepositoriesSerializer
2019-12-21 20:55:43 +05:30
.new(current_user: current_user)
2020-03-09 13:42:32 +05:30
2020-04-08 14:13:33 +05:30
if Feature.enabled?(:vue_container_registry_explorer, group)
2020-03-09 13:42:32 +05:30
render json: serializer.with_pagination(request, response)
.represent_read_only(@images)
else
render json: serializer.represent_read_only(@images)
end
2019-12-21 20:55:43 +05:30
end
end
end
2020-03-09 13:42:32 +05:30
# The show action renders index to allow frontend routing to work on page refresh
def show
render :index
end
2019-12-21 20:55:43 +05:30
private
def feature_flag_group_container_registry_browser!
render_404 unless Feature.enabled?(:group_container_registry_browser, group)
end
def verify_container_registry_enabled!
render_404 unless Gitlab.config.registry.enabled
end
def authorize_read_container_image!
return render_404 unless can?(current_user, :read_container_image, group)
end
end
end
end