diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-18 18:06:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-18 18:06:03 +0300 |
commit | 4584eb0e07d372d6014de16ab359965475184c99 (patch) | |
tree | 586f35b77fac7ddfb8a05aa57b4fb6aa3d98212e /app/controllers/import | |
parent | bdbded586beb38e2ee4642c6a1e78ccbebc094dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/import')
-rw-r--r-- | app/controllers/import/github_controller.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb index 72f830fc9a1..c418b11ab13 100644 --- a/app/controllers/import/github_controller.rb +++ b/app/controllers/import/github_controller.rb @@ -2,6 +2,7 @@ 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] @@ -55,7 +56,7 @@ class Import::GithubController < Import::BaseController def realtime_changes Gitlab::PollingInterval.set_header(response, interval: 3_000) - render json: find_jobs(provider) + render json: already_added_projects.to_json(only: [:id], methods: [:import_status]) end private @@ -82,7 +83,7 @@ class Import::GithubController < Import::BaseController end def already_added_projects - @already_added_projects ||= find_already_added_projects(provider) + @already_added_projects ||= filtered(find_already_added_projects(provider)) end def already_added_project_names @@ -104,7 +105,7 @@ class Import::GithubController < Import::BaseController end def client_repos - @client_repos ||= client.repos + @client_repos ||= filtered(client.repos) end def verify_import_enabled @@ -185,6 +186,20 @@ 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') |