diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-10-04 10:58:34 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-10-04 10:58:34 +0300 |
commit | c958c201b72577eb01662cc1dac0f253e3d3e6db (patch) | |
tree | 26f52060490aaee5c2695e34c57b812383d834a3 /app/controllers | |
parent | 912e6b0b3d887b86bf41066062376438d3377da7 (diff) | |
parent | ba4a442996d322ca736c97ff6e7f7fdf3860d36a (diff) |
Merge branch '31050-registry-image-lists' into 'master'
Lazy load and paginate registry image list
Closes #31050
See merge request gitlab-org/gitlab-ce!14303
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/registry/repositories_controller.rb | 21 | ||||
-rw-r--r-- | app/controllers/projects/registry/tags_controller.rb | 27 |
2 files changed, 36 insertions, 12 deletions
diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb index 71e7dc70a4d..32c0fc6d14a 100644 --- a/app/controllers/projects/registry/repositories_controller.rb +++ b/app/controllers/projects/registry/repositories_controller.rb @@ -6,17 +6,26 @@ module Projects def index @images = project.container_repositories + + respond_to do |format| + format.html + format.json do + render json: ContainerRepositoriesSerializer + .new(project: project, current_user: current_user) + .represent(@images) + end + end end def destroy if image.destroy - redirect_to project_container_registry_index_path(@project), - status: 302, - notice: 'Image repository has been removed successfully!' + respond_to do |format| + format.json { head :no_content } + end else - redirect_to project_container_registry_index_path(@project), - status: 302, - alert: 'Failed to remove image repository!' + respond_to do |format| + format.json { head :bad_request } + end end end diff --git a/app/controllers/projects/registry/tags_controller.rb b/app/controllers/projects/registry/tags_controller.rb index ae72bd03cfb..e602aa3f393 100644 --- a/app/controllers/projects/registry/tags_controller.rb +++ b/app/controllers/projects/registry/tags_controller.rb @@ -3,20 +3,35 @@ module Projects class TagsController < ::Projects::Registry::ApplicationController before_action :authorize_update_container_image!, only: [:destroy] + def index + respond_to do |format| + format.json do + render json: ContainerTagsSerializer + .new(project: @project, current_user: @current_user) + .with_pagination(request, response) + .represent(tags) + end + end + end + def destroy if tag.delete - redirect_to project_container_registry_index_path(@project), - status: 302, - notice: 'Registry tag has been removed successfully!' + respond_to do |format| + format.json { head :no_content } + end else - redirect_to project_container_registry_index_path(@project), - status: 302, - alert: 'Failed to remove registry tag!' + respond_to do |format| + format.json { head :bad_request } + end end end private + def tags + Kaminari::PaginatableArray.new(image.tags, limit: 15) + end + def image @image ||= project.container_repositories .find(params[:repository_id]) |