diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-08-15 23:57:38 +0000 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-08-15 23:57:38 +0000 |
commit | f4ce990b0e2811cd2c3391fc5f11de990bc54f16 (patch) | |
tree | 34bfb064d8cdec92337d59f9904a64850b8a47d7 /app/controllers | |
parent | bd5c259a0bb94cb601a3c0f017c383731ac868e6 (diff) | |
parent | f3de7855f90ed6785f546ed4831e3cc9d34c63ad (diff) | |
download | gitlab-ce-f4ce990b0e2811cd2c3391fc5f11de990bc54f16.tar.gz |
Merge branch '24705-multi-selection-for-delete-on-registry-page' into 'master'
Resolve "Multi selection for delete on registry page"
Closes #24705
See merge request gitlab-org/gitlab-ce!30837
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/registry/tags_controller.rb | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/app/controllers/projects/registry/tags_controller.rb b/app/controllers/projects/registry/tags_controller.rb index bf1d8d8b5fc..54e2faa2dd7 100644 --- a/app/controllers/projects/registry/tags_controller.rb +++ b/app/controllers/projects/registry/tags_controller.rb @@ -5,6 +5,8 @@ module Projects class TagsController < ::Projects::Registry::ApplicationController before_action :authorize_destroy_container_image!, only: [:destroy] + LIMIT = 15 + def index respond_to do |format| format.json do @@ -28,10 +30,40 @@ module Projects end end + def bulk_destroy + unless params[:ids].present? + head :bad_request + return + end + + tag_names = params[:ids] || [] + if tag_names.size > LIMIT + head :bad_request + return + end + + @tags = tag_names.map { |tag_name| image.tag(tag_name) } + unless @tags.all? { |tag| tag.valid_name? } + head :bad_request + return + end + + success_count = 0 + @tags.each do |tag| + if tag.delete + success_count += 1 + end + end + + respond_to do |format| + format.json { head(success_count == @tags.size ? :no_content : :bad_request) } + end + end + private def tags - Kaminari::PaginatableArray.new(image.tags, limit: 15) + Kaminari::PaginatableArray.new(image.tags, limit: LIMIT) end def image |