From 51c9f8b6d681412166aaefccd36c589401ed89b5 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Tue, 19 Sep 2017 16:38:55 +0100 Subject: [ci skip] First iteration: port haml into vue --- .../projects/registry/repositories_controller.rb | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb index 71e7dc70a4d..89093e4172a 100644 --- a/app/controllers/projects/registry/repositories_controller.rb +++ b/app/controllers/projects/registry/repositories_controller.rb @@ -6,6 +6,37 @@ module Projects def index @images = project.container_repositories + + respond_to do |format| + format.html + format.json do + # render json: @images + 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', + } + ] + end + end end def destroy -- cgit v1.2.3 From ee3cf5d6f3d5a3631fa7e94a242f2dfe9b38a935 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Wed, 20 Sep 2017 19:03:53 +0100 Subject: [ci skip] Adds tests to vuex and collapsibe component Formats dates Fixes clipboard button Simplifies HTML --- .../projects/registry/repositories_controller.rb | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb index 89093e4172a..952081a349f 100644 --- a/app/controllers/projects/registry/repositories_controller.rb +++ b/app/controllers/projects/registry/repositories_controller.rb @@ -10,7 +10,7 @@ module Projects respond_to do |format| format.html format.json do - # render json: @images + # Remove code below render json: [ { name: 'gitlab-org/omnibus-gitlab/foo', @@ -41,13 +41,27 @@ module Projects 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| + # 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 - redirect_to project_container_registry_index_path(@project), - status: 302, - alert: 'Failed to remove image repository!' + 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 } + end end end -- cgit v1.2.3 From 8ba9c2bd6d10c74529a0e2e6bb894c34614966f1 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 21 Sep 2017 12:21:50 +0200 Subject: Add ContainerTag and ContainerRepository frontend API --- .../projects/registry/repositories_controller.rb | 44 ++-------------------- .../projects/registry/tags_controller.rb | 31 +++++++++++---- 2 files changed, 27 insertions(+), 48 deletions(-) (limited to 'app/controllers') 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]) -- cgit v1.2.3 From 8dd750e4f7bf599e5a65f14c14aec9236cae4220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 15 Sep 2017 13:25:12 +0200 Subject: Fix the default branches sorting to actually be 'Last updated' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- app/controllers/projects/branches_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index a9cce578366..7f03ce07dec 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -9,7 +9,7 @@ class Projects::BranchesController < Projects::ApplicationController def index @sort = params[:sort].presence || sort_value_recently_updated - @branches = BranchesFinder.new(@repository, params).execute + @branches = BranchesFinder.new(@repository, params.merge(sort: @sort)).execute @branches = Kaminari.paginate_array(@branches).page(params[:page]) respond_to do |format| -- cgit v1.2.3 From 800a5f8ee9a73476a75ff04af2180e294db3a32d Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 2 Oct 2017 22:53:14 +0200 Subject: Add serializer matchers --- app/controllers/projects/registry/tags_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/projects/registry/tags_controller.rb b/app/controllers/projects/registry/tags_controller.rb index e32c5528ee7..e602aa3f393 100644 --- a/app/controllers/projects/registry/tags_controller.rb +++ b/app/controllers/projects/registry/tags_controller.rb @@ -15,13 +15,13 @@ module Projects end def destroy - respond_to do |format| - format.json do - if tag.delete - format.json { head :no_content } - else - format.json { head :bad_request } - end + if tag.delete + respond_to do |format| + format.json { head :no_content } + end + else + respond_to do |format| + format.json { head :bad_request } end end end -- cgit v1.2.3 From 55fe0d7d0aeb9e10730610a646080f8717f37fd0 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 3 Oct 2017 16:57:31 +0200 Subject: Set default scope on PATs that don't have one set to allow them to be revoked --- app/controllers/profiles/personal_access_tokens_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/profiles/personal_access_tokens_controller.rb b/app/controllers/profiles/personal_access_tokens_controller.rb index c1cc509a748..4146deefa89 100644 --- a/app/controllers/profiles/personal_access_tokens_controller.rb +++ b/app/controllers/profiles/personal_access_tokens_controller.rb @@ -1,6 +1,7 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController def index set_index_vars + @personal_access_token = finder.build end def create @@ -40,7 +41,6 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController def set_index_vars @scopes = Gitlab::Auth.available_scopes - @personal_access_token = finder.build @inactive_personal_access_tokens = finder(state: 'inactive').execute @active_personal_access_tokens = finder(state: 'active').execute.order(:expires_at) end -- cgit v1.2.3