Commit 91d357a6 authored by Illya Klymov's avatar Illya Klymov

Address reviewer comments

parent 0f385b5c
...@@ -64,10 +64,9 @@ export default { ...@@ -64,10 +64,9 @@ export default {
}); });
const existingProjects = [...newImportedProjects, ...state.repositories]; const existingProjects = [...newImportedProjects, ...state.repositories];
const existingProjectNames = new Set(existingProjects.map((p) => p.importSource.fullName));
const newProjects = repositories.providerRepos const newProjects = repositories.providerRepos
.filter( .filter((project) => !existingProjectNames.has(project.fullName))
(project) => !existingProjects.find((p) => p.importSource.fullName === project.fullName),
)
.map((project) => ({ .map((project) => ({
importSource: project, importSource: project,
importedProject: null, importedProject: null,
......
...@@ -74,12 +74,10 @@ class Import::FogbugzController < Import::BaseController ...@@ -74,12 +74,10 @@ class Import::FogbugzController < Import::BaseController
protected protected
# rubocop: disable CodeReuse/ActiveRecord
override :importable_repos override :importable_repos
def importable_repos def importable_repos
client.repos client.repos
end end
# rubocop: enable CodeReuse/ActiveRecord
override :incompatible_repos override :incompatible_repos
def incompatible_repos def incompatible_repos
......
...@@ -41,7 +41,7 @@ class Import::ManifestController < Import::BaseController ...@@ -41,7 +41,7 @@ class Import::ManifestController < Import::BaseController
end end
def create def create
repository = repositories.find do |project| repository = importable_repos.find do |project|
project[:id] == params[:repo_id].to_i project[:id] == params[:repo_id].to_i
end end
...@@ -56,14 +56,10 @@ class Import::ManifestController < Import::BaseController ...@@ -56,14 +56,10 @@ class Import::ManifestController < Import::BaseController
protected protected
# rubocop: disable CodeReuse/ActiveRecord
override :importable_repos override :importable_repos
def importable_repos def importable_repos
already_added_projects_names = already_added_projects.pluck(:import_url) @importable_repos ||= manifest_import_metadata.repositories
repositories.reject { |repo| already_added_projects_names.include?(repo[:url]) }
end end
# rubocop: enable CodeReuse/ActiveRecord
override :incompatible_repos override :incompatible_repos
def incompatible_repos def incompatible_repos
...@@ -88,7 +84,7 @@ class Import::ManifestController < Import::BaseController ...@@ -88,7 +84,7 @@ class Import::ManifestController < Import::BaseController
private private
def ensure_import_vars def ensure_import_vars
unless group && repositories.present? unless group && importable_repos.present?
redirect_to(new_import_manifest_path) redirect_to(new_import_manifest_path)
end end
end end
...@@ -103,10 +99,6 @@ class Import::ManifestController < Import::BaseController ...@@ -103,10 +99,6 @@ class Import::ManifestController < Import::BaseController
@manifest_import_status ||= Gitlab::ManifestImport::Metadata.new(current_user, fallback: session) @manifest_import_status ||= Gitlab::ManifestImport::Metadata.new(current_user, fallback: session)
end end
def repositories
@repositories ||= manifest_import_metadata.repositories
end
def find_jobs def find_jobs
find_already_added_projects.to_json(only: [:id], methods: [:import_status]) find_already_added_projects.to_json(only: [:id], methods: [:import_status])
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment