diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-20 15:11:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-20 15:11:29 +0300 |
commit | 7b384a1f3d2608898318e67d11eea2914889ae81 (patch) | |
tree | af33e77d13b18a96156c69616cb09a3a4f7697c6 /app/controllers | |
parent | d46287cc16ba244720c6d5c00491944336972988 (diff) |
Add latest changes from gitlab-org/gitlab@12-3-stable
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/dashboard/todos_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/import/github_controller.rb | 21 | ||||
-rw-r--r-- | app/controllers/projects/artifacts_controller.rb | 38 | ||||
-rw-r--r-- | app/controllers/projects/registry/tags_controller.rb | 35 | ||||
-rw-r--r-- | app/controllers/projects/templates_controller.rb | 8 |
5 files changed, 31 insertions, 75 deletions
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 80c0a0d88a8..7012bfcefe3 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -78,8 +78,8 @@ class Dashboard::TodosController < Dashboard::ApplicationController def todos_counts { - count: current_user.todos_pending_count, - done_count: current_user.todos_done_count + count: number_with_delimiter(current_user.todos_pending_count), + done_count: number_with_delimiter(current_user.todos_done_count) } end diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb index c418b11ab13..72f830fc9a1 100644 --- a/app/controllers/import/github_controller.rb +++ b/app/controllers/import/github_controller.rb @@ -2,7 +2,6 @@ class Import::GithubController < Import::BaseController include ImportHelper - include ActionView::Helpers::SanitizeHelper before_action :verify_import_enabled before_action :provider_auth, only: [:status, :realtime_changes, :create] @@ -56,7 +55,7 @@ class Import::GithubController < Import::BaseController def realtime_changes Gitlab::PollingInterval.set_header(response, interval: 3_000) - render json: already_added_projects.to_json(only: [:id], methods: [:import_status]) + render json: find_jobs(provider) end private @@ -83,7 +82,7 @@ class Import::GithubController < Import::BaseController end def already_added_projects - @already_added_projects ||= filtered(find_already_added_projects(provider)) + @already_added_projects ||= find_already_added_projects(provider) end def already_added_project_names @@ -105,7 +104,7 @@ class Import::GithubController < Import::BaseController end def client_repos - @client_repos ||= filtered(client.repos) + @client_repos ||= client.repos end def verify_import_enabled @@ -186,20 +185,6 @@ class Import::GithubController < Import::BaseController def extra_import_params {} end - - def sanitized_filter_param - @filter ||= sanitize(params[:filter]) - end - - def filter_attribute - :name - end - - def filtered(collection) - return collection unless sanitized_filter_param - - collection.select { |item| item[filter_attribute].include?(sanitized_filter_param) } - end end Import::GithubController.prepend_if_ee('EE::Import::GithubController') diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 50399a8cfbb..da8a371acaa 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -8,37 +8,10 @@ class Projects::ArtifactsController < Projects::ApplicationController layout 'project' before_action :authorize_read_build! before_action :authorize_update_build!, only: [:keep] - before_action :authorize_destroy_artifacts!, only: [:destroy] before_action :extract_ref_name_and_path - before_action :validate_artifacts!, except: [:index, :download, :destroy] + before_action :validate_artifacts!, except: [:download] before_action :entry, only: [:file] - MAX_PER_PAGE = 20 - - def index - # Loading artifacts is very expensive in projects with a lot of artifacts. - # This feature flag prevents a DOS attack vector. - # It should be removed only after resolving the underlying performance - # issues: https://gitlab.com/gitlab-org/gitlab/issues/32281 - return head :no_content unless Feature.enabled?(:artifacts_management_page, @project) - - finder = ArtifactsFinder.new(@project, artifacts_params) - all_artifacts = finder.execute - - @artifacts = all_artifacts.page(params[:page]).per(MAX_PER_PAGE) - @total_size = all_artifacts.total_size - end - - def destroy - notice = if artifact.destroy - _('Artifact was successfully deleted.') - else - _('Artifact could not be deleted.') - end - - redirect_to project_artifacts_path(@project), status: :see_other, notice: notice - end - def download return render_404 unless artifacts_file @@ -101,10 +74,6 @@ class Projects::ArtifactsController < Projects::ApplicationController @ref_name, @path = extract_ref(params[:ref_name_and_path]) end - def artifacts_params - params.permit(:sort) - end - def validate_artifacts! render_404 unless build&.artifacts? end @@ -116,11 +85,6 @@ class Projects::ArtifactsController < Projects::ApplicationController end end - def artifact - @artifact ||= - project.job_artifacts.find(params[:id]) - end - def build_from_id project.builds.find_by_id(params[:job_id]) if params[:job_id] end diff --git a/app/controllers/projects/registry/tags_controller.rb b/app/controllers/projects/registry/tags_controller.rb index b5ee0ba9beb..54e2faa2dd7 100644 --- a/app/controllers/projects/registry/tags_controller.rb +++ b/app/controllers/projects/registry/tags_controller.rb @@ -19,12 +19,14 @@ module Projects end def destroy - result = Projects::ContainerRepository::DeleteTagsService - .new(image.project, current_user, tags: [params[:id]]) - .execute(image) - - respond_to do |format| - format.json { head(result[:status] == :success ? :ok : bad_request) } + 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 @@ -40,12 +42,21 @@ module Projects return end - result = Projects::ContainerRepository::DeleteTagsService - .new(image.project, current_user, tags: tag_names) - .execute(image) + @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(result[:status] == :success ? :no_content : :bad_request) } + format.json { head(success_count == @tags.size ? :no_content : :bad_request) } end end @@ -59,6 +70,10 @@ module Projects @image ||= project.container_repositories .find(params[:repository_id]) end + + def tag + @tag ||= image.tag(params[:id]) + end end end end diff --git a/app/controllers/projects/templates_controller.rb b/app/controllers/projects/templates_controller.rb index 95739f96d39..f987033a26c 100644 --- a/app/controllers/projects/templates_controller.rb +++ b/app/controllers/projects/templates_controller.rb @@ -13,14 +13,6 @@ class Projects::TemplatesController < Projects::ApplicationController end end - def names - templates = @template_type.dropdown_names(project) - - respond_to do |format| - format.json { render json: templates } - end - end - private # User must have: |