From 6438df3a1e0fb944485cebf07976160184697d72 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 20 Jan 2021 13:34:23 -0600 Subject: Add latest changes from gitlab-org/gitlab@13-8-stable-ee --- app/controllers/import/bulk_imports_controller.rb | 35 ++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'app/controllers/import') diff --git a/app/controllers/import/bulk_imports_controller.rb b/app/controllers/import/bulk_imports_controller.rb index 4417cfe9098..7394e8bf615 100644 --- a/app/controllers/import/bulk_imports_controller.rb +++ b/app/controllers/import/bulk_imports_controller.rb @@ -1,11 +1,15 @@ # frozen_string_literal: true class Import::BulkImportsController < ApplicationController + include ActionView::Helpers::SanitizeHelper + before_action :ensure_group_import_enabled before_action :verify_blocked_uri, only: :status feature_category :importers + POLLING_INTERVAL = 3_000 + rescue_from BulkImports::Clients::Http::ConnectionError, with: :bulk_import_connection_error def configure @@ -32,6 +36,12 @@ class Import::BulkImportsController < ApplicationController render json: :ok end + def realtime_changes + Gitlab::PollingInterval.set_header(response, interval: POLLING_INTERVAL) + + render json: current_user_bulk_imports.to_json(only: [:id], methods: [:status_name]) + end + private def serialized_importable_data @@ -43,7 +53,22 @@ class Import::BulkImportsController < ApplicationController end def importable_data - client.get('groups', top_level_only: true).parsed_response + client.get('groups', query_params).parsed_response + end + + # Default query string params used to fetch groups from GitLab source instance + # + # top_level_only: fetch only top level groups (subgroups are fetched during import itself) + # min_access_level: fetch only groups user has maintainer or above permissions + # search: optional search param to search user's groups by a keyword + def query_params + query_params = { + top_level_only: true, + min_access_level: Gitlab::Access::MAINTAINER + } + + query_params[:search] = sanitized_filter_param if sanitized_filter_param + query_params end def client @@ -131,4 +156,12 @@ class Import::BulkImportsController < ApplicationController access_token: session[access_token_key] } end + + def sanitized_filter_param + @filter ||= sanitize(params[:filter])&.downcase + end + + def current_user_bulk_imports + current_user.bulk_imports.gitlab + end end -- cgit v1.2.1