Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-09-21 13:21:50 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-09-21 13:21:50 +0300
commit8ba9c2bd6d10c74529a0e2e6bb894c34614966f1 (patch)
treec80ff14075e4d4bfc96828b3f980c6fd51429398 /app/controllers/projects/registry
parentee3cf5d6f3d5a3631fa7e94a242f2dfe9b38a935 (diff)
Add ContainerTag and ContainerRepository frontend API
Diffstat (limited to 'app/controllers/projects/registry')
-rw-r--r--app/controllers/projects/registry/repositories_controller.rb44
-rw-r--r--app/controllers/projects/registry/tags_controller.rb31
2 files changed, 27 insertions, 48 deletions
diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb
index 952081a349f..32c0fc6d14a 100644
--- a/app/controllers/projects/registry/repositories_controller.rb
+++ b/app/controllers/projects/registry/repositories_controller.rb
@@ -10,31 +10,9 @@ module Projects
respond_to do |format|
format.html
format.json do
- # Remove code below
- render json: [
- {
- name: 'gitlab-org/omnibus-gitlab/foo',
- tags_path: 'foo',
- destroy_path: 'bar',
- location: 'foo',
- id: '134',
- destroy_path: 'bar'
- },
- {
- name: 'gitlab-org/omnibus-gitlab',
- tags_path: 'foo',
- destroy_path: 'bar',
- location: 'foo',
- id: '123',
- },
- {
- name: 'gitlab-org/omnibus-gitlab/bar',
- tags_path: 'foo',
- destroy_path: 'bar',
- location: 'foo',
- id: '973',
- }
- ]
+ render json: ContainerRepositoriesSerializer
+ .new(project: project, current_user: current_user)
+ .represent(@images)
end
end
end
@@ -42,25 +20,11 @@ module Projects
def destroy
if image.destroy
respond_to do |format|
- # TODO: @Kamil, I don't think this is used ever. Should we keep it or remove it?
- format.html do
- redirect_to project_container_registry_index_path(@project),
- status: 302,
- notice: 'Image repository has been removed successfully!'
- end
-
format.json { head :no_content }
end
else
respond_to do |format|
- # TODO: @Kamil, I don't think this is used ever. Should we keep it or remove it?
- format.html do
- redirect_to project_container_registry_index_path(@project),
- status: 302,
- alert: 'Failed to remove image repository!'
- end
-
- format.json { head :no_content }
+ 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..e32c5528ee7 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!'
- else
- redirect_to project_container_registry_index_path(@project),
- status: 302,
- alert: 'Failed to remove registry tag!'
+ respond_to do |format|
+ format.json do
+ if tag.delete
+ format.json { head :no_content }
+ else
+ format.json { head :bad_request }
+ end
+ end
end
end
private
+ def tags
+ Kaminari::PaginatableArray.new(image.tags, limit: 15)
+ end
+
def image
@image ||= project.container_repositories
.find(params[:repository_id])