Commit 5f65c332 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'xanf-remove-obsolete-importers-code' into 'master'

Remove obsolete code in importers and remove new_import_ui feature flag"

See merge request gitlab-org/gitlab!35748
parents cbab46bf 890086e7
...@@ -30,7 +30,7 @@ class Import::BaseController < ApplicationController ...@@ -30,7 +30,7 @@ class Import::BaseController < ApplicationController
end end
def incompatible_repos def incompatible_repos
[] raise NotImplementedError
end end
def provider_name def provider_name
...@@ -87,15 +87,6 @@ class Import::BaseController < ApplicationController ...@@ -87,15 +87,6 @@ class Import::BaseController < ApplicationController
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def find_jobs(import_type)
current_user.created_projects
.with_import_state
.where(import_type: import_type)
.to_json(only: [:id], methods: [:import_status])
end
# rubocop: enable CodeReuse/ActiveRecord
# deprecated: being replaced by app/services/import/base_service.rb # deprecated: being replaced by app/services/import/base_service.rb
def find_or_create_namespace(names, owner) def find_or_create_namespace(names, owner)
names = params[:target_namespace].presence || names names = params[:target_namespace].presence || names
......
...@@ -22,23 +22,8 @@ class Import::BitbucketController < Import::BaseController ...@@ -22,23 +22,8 @@ class Import::BitbucketController < Import::BaseController
redirect_to status_import_bitbucket_url redirect_to status_import_bitbucket_url
end end
# rubocop: disable CodeReuse/ActiveRecord
def status def status
return super if Feature.enabled?(:new_import_ui) super
bitbucket_client = Bitbucket::Client.new(credentials)
repos = bitbucket_client.repos(filter: sanitized_filter_param)
@repos, @incompatible_repos = repos.partition { |repo| repo.valid? }
@already_added_projects = find_already_added_projects('bitbucket')
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos.to_a.reject! { |repo| already_added_projects_names.include?(repo.full_name) }
end
# rubocop: enable CodeReuse/ActiveRecord
def jobs
render json: find_jobs('bitbucket')
end end
def realtime_changes def realtime_changes
......
...@@ -52,23 +52,8 @@ class Import::BitbucketServerController < Import::BaseController ...@@ -52,23 +52,8 @@ class Import::BitbucketServerController < Import::BaseController
redirect_to status_import_bitbucket_server_path redirect_to status_import_bitbucket_server_path
end end
# rubocop: disable CodeReuse/ActiveRecord
def status def status
return super if Feature.enabled?(:new_import_ui) super
@collection = client.repos(page_offset: page_offset, limit: limit_per_page, filter: sanitized_filter_param)
@repos, @incompatible_repos = @collection.partition { |repo| repo.valid? }
# Use the import URL to filter beyond what BaseService#find_already_added_projects
@already_added_projects = filter_added_projects('bitbucket_server', @repos.map(&:browse_url))
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos.reject! { |repo| already_added_projects_names.include?(repo.browse_url) }
end
# rubocop: enable CodeReuse/ActiveRecord
def jobs
render json: find_jobs('bitbucket_server')
end end
def realtime_changes def realtime_changes
......
...@@ -50,14 +50,7 @@ class Import::FogbugzController < Import::BaseController ...@@ -50,14 +50,7 @@ class Import::FogbugzController < Import::BaseController
return redirect_to new_import_fogbugz_path return redirect_to new_import_fogbugz_path
end end
return super if Feature.enabled?(:new_import_ui) super
@repos = client.repos
@already_added_projects = find_already_added_projects('fogbugz')
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos.reject! { |repo| already_added_projects_names.include? repo.name }
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
...@@ -65,10 +58,6 @@ class Import::FogbugzController < Import::BaseController ...@@ -65,10 +58,6 @@ class Import::FogbugzController < Import::BaseController
super super
end end
def jobs
render json: find_jobs('fogbugz')
end
def create def create
repo = client.repo(params[:repo_id]) repo = client.repo(params[:repo_id])
fb_session = { uri: session[:fogbugz_uri], token: session[:fogbugz_token] } fb_session = { uri: session[:fogbugz_uri], token: session[:fogbugz_token] }
...@@ -96,6 +85,11 @@ class Import::FogbugzController < Import::BaseController ...@@ -96,6 +85,11 @@ class Import::FogbugzController < Import::BaseController
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
override :incompatible_repos
def incompatible_repos
[]
end
override :provider_name override :provider_name
def provider_name def provider_name
:fogbugz :fogbugz
......
...@@ -21,15 +21,17 @@ class Import::GiteaController < Import::GithubController ...@@ -21,15 +21,17 @@ class Import::GiteaController < Import::GithubController
super super
end end
private protected
def host_key override :provider_name
:"#{provider}_host_url" def provider_name
:gitea
end end
override :provider private
def provider
:gitea def host_key
:"#{provider_name}_host_url"
end end
override :provider_url override :provider_url
......
# frozen_string_literal: true # frozen_string_literal: true
class Import::GithubController < Import::BaseController class Import::GithubController < Import::BaseController
extend ::Gitlab::Utils::Override
include ImportHelper include ImportHelper
include ActionView::Helpers::SanitizeHelper include ActionView::Helpers::SanitizeHelper
...@@ -34,18 +36,11 @@ class Import::GithubController < Import::BaseController ...@@ -34,18 +36,11 @@ class Import::GithubController < Import::BaseController
# Improving in https://gitlab.com/gitlab-org/gitlab-foss/issues/55585 # Improving in https://gitlab.com/gitlab-org/gitlab-foss/issues/55585
client_repos client_repos
respond_to do |format| super
format.json do
render json: { imported_projects: serialized_imported_projects,
provider_repos: serialized_provider_repos,
namespaces: serialized_namespaces }
end
format.html
end
end end
def create def create
result = Import::GithubService.new(client, current_user, import_params).execute(access_params, provider) result = Import::GithubService.new(client, current_user, import_params).execute(access_params, provider_name)
if result[:status] == :success if result[:status] == :success
render json: serialized_imported_projects(result[:project]) render json: serialized_imported_projects(result[:project])
...@@ -55,44 +50,51 @@ class Import::GithubController < Import::BaseController ...@@ -55,44 +50,51 @@ class Import::GithubController < Import::BaseController
end end
def realtime_changes def realtime_changes
Gitlab::PollingInterval.set_header(response, interval: 3_000) super
render json: already_added_projects.to_json(only: [:id], methods: [:import_status])
end end
private protected
def import_params # rubocop: disable CodeReuse/ActiveRecord
params.permit(permitted_import_params) override :importable_repos
end def importable_repos
already_added_projects_names = already_added_projects.pluck(:import_source)
def permitted_import_params client_repos.reject { |repo| already_added_projects_names.include?(repo.full_name) }
[:repo_id, :new_name, :target_namespace]
end end
# rubocop: enable CodeReuse/ActiveRecord
def serialized_imported_projects(projects = already_added_projects) override :incompatible_repos
ProjectSerializer.new.represent(projects, serializer: :import, provider_url: provider_url) def incompatible_repos
[]
end end
def serialized_provider_repos override :provider_name
repos = client_repos.reject { |repo| already_added_project_names.include? repo.full_name } def provider_name
Import::ProviderRepoSerializer.new(current_user: current_user).represent(repos, provider: provider, provider_url: provider_url) :github
end end
def serialized_namespaces override :provider_url
NamespaceSerializer.new.represent(namespaces) def provider_url
strong_memoize(:provider_url) do
provider = Gitlab::Auth::OAuth::Provider.config_for('github')
provider&.dig('url').presence || 'https://github.com'
end
end end
def already_added_projects private
@already_added_projects ||= filtered(find_already_added_projects(provider))
def import_params
params.permit(permitted_import_params)
end end
def already_added_project_names def permitted_import_params
@already_added_projects_names ||= already_added_projects.pluck(:import_source) # rubocop:disable CodeReuse/ActiveRecord [:repo_id, :new_name, :target_namespace]
end end
def namespaces def serialized_imported_projects(projects = already_added_projects)
current_user.manageable_groups_with_routes ProjectSerializer.new.represent(projects, serializer: :import, provider_url: provider_url)
end end
def expire_etag_cache def expire_etag_cache
...@@ -118,29 +120,29 @@ class Import::GithubController < Import::BaseController ...@@ -118,29 +120,29 @@ class Import::GithubController < Import::BaseController
end end
def import_enabled? def import_enabled?
__send__("#{provider}_import_enabled?") # rubocop:disable GitlabSecurity/PublicSend __send__("#{provider_name}_import_enabled?") # rubocop:disable GitlabSecurity/PublicSend
end end
def realtime_changes_path def realtime_changes_path
public_send("realtime_changes_import_#{provider}_path", format: :json) # rubocop:disable GitlabSecurity/PublicSend public_send("realtime_changes_import_#{provider_name}_path", format: :json) # rubocop:disable GitlabSecurity/PublicSend
end end
def new_import_url def new_import_url
public_send("new_import_#{provider}_url", extra_import_params) # rubocop:disable GitlabSecurity/PublicSend public_send("new_import_#{provider_name}_url", extra_import_params) # rubocop:disable GitlabSecurity/PublicSend
end end
def status_import_url def status_import_url
public_send("status_import_#{provider}_url", extra_import_params) # rubocop:disable GitlabSecurity/PublicSend public_send("status_import_#{provider_name}_url", extra_import_params) # rubocop:disable GitlabSecurity/PublicSend
end end
def callback_import_url def callback_import_url
public_send("users_import_#{provider}_callback_url", extra_import_params) # rubocop:disable GitlabSecurity/PublicSend public_send("users_import_#{provider_name}_callback_url", extra_import_params) # rubocop:disable GitlabSecurity/PublicSend
end end
def provider_unauthorized def provider_unauthorized
session[access_token_key] = nil session[access_token_key] = nil
redirect_to new_import_url, redirect_to new_import_url,
alert: "Access denied to your #{Gitlab::ImportSources.title(provider.to_s)} account." alert: "Access denied to your #{Gitlab::ImportSources.title(provider_name.to_s)} account."
end end
def provider_rate_limit(exception) def provider_rate_limit(exception)
...@@ -151,29 +153,16 @@ class Import::GithubController < Import::BaseController ...@@ -151,29 +153,16 @@ class Import::GithubController < Import::BaseController
end end
def access_token_key def access_token_key
:"#{provider}_access_token" :"#{provider_name}_access_token"
end end
def access_params def access_params
{ github_access_token: session[access_token_key] } { github_access_token: session[access_token_key] }
end end
# The following methods are overridden in subclasses
def provider
:github
end
def provider_url
strong_memoize(:provider_url) do
provider = Gitlab::Auth::OAuth::Provider.config_for('github')
provider&.dig('url').presence || 'https://github.com'
end
end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def logged_in_with_provider? def logged_in_with_provider?
current_user.identities.exists?(provider: provider) current_user.identities.exists?(provider: provider_name)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
...@@ -202,12 +191,6 @@ class Import::GithubController < Import::BaseController ...@@ -202,12 +191,6 @@ class Import::GithubController < Import::BaseController
def filter_attribute def filter_attribute
:name :name
end end
def filtered(collection)
return collection unless sanitized_filter_param
collection.select { |item| item[filter_attribute].include?(sanitized_filter_param) }
end
end end
Import::GithubController.prepend_if_ee('EE::Import::GithubController') Import::GithubController.prepend_if_ee('EE::Import::GithubController')
...@@ -16,21 +16,8 @@ class Import::GitlabController < Import::BaseController ...@@ -16,21 +16,8 @@ class Import::GitlabController < Import::BaseController
redirect_to status_import_gitlab_url redirect_to status_import_gitlab_url
end end
# rubocop: disable CodeReuse/ActiveRecord
def status def status
return super if Feature.enabled?(:new_import_ui) super
@repos = client.projects(starting_page: 1, page_limit: MAX_PROJECT_PAGES, per_page: PER_PAGE_PROJECTS)
@already_added_projects = find_already_added_projects('gitlab')
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos = @repos.to_a.reject { |repo| already_added_projects_names.include? repo["path_with_namespace"] }
end
# rubocop: enable CodeReuse/ActiveRecord
def jobs
render json: find_jobs('gitlab')
end end
def create def create
...@@ -63,6 +50,11 @@ class Import::GitlabController < Import::BaseController ...@@ -63,6 +50,11 @@ class Import::GitlabController < Import::BaseController
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
override :incompatible_repos
def incompatible_repos
[]
end
override :provider_name override :provider_name
def provider_name def provider_name
:gitlab :gitlab
......
...@@ -5,93 +5,4 @@ ...@@ -5,93 +5,4 @@
%i.fa.fa-bitbucket %i.fa.fa-bitbucket
= _('Import projects from Bitbucket') = _('Import projects from Bitbucket')
- if Feature.enabled?(:new_import_ui) = render 'import/githubish_status', provider: 'bitbucket'
= render 'import/githubish_status', provider: 'bitbucket'
- else
- if @repos.any?
%p.light
= _('Select projects you want to import.')
%p
- if @incompatible_repos.any?
= button_tag class: 'btn btn-import btn-success js-import-all' do
= _('Import all compatible projects')
= icon('spinner spin', class: 'loading-icon')
- else
= button_tag class: 'btn btn-import btn-success js-import-all' do
= _('Import all projects')
= icon('spinner spin', class: 'loading-icon')
.position-relative.ms-no-clear.d-flex.flex-fill.float-right.append-bottom-10
= form_tag status_import_bitbucket_path, method: 'get' do
= text_field_tag :filter, @filter, class: 'form-control pr-5', placeholder: _('Filter projects'), size: 40, autofocus: true, 'aria-label': _('Search')
.position-absolute.position-top-0.d-flex.align-items-center.text-muted.position-right-0.h-100
.border-left
%button{ class: 'btn btn-transparent btn-secondary', 'aria-label': _('Search Button'), type: 'submit' }
%i{ class: 'fa fa-search', 'aria-hidden': true }
.table-responsive
%table.table.import-jobs
%colgroup.import-jobs-from-col
%colgroup.import-jobs-to-col
%colgroup.import-jobs-status-col
%thead
%tr
%th= _('From Bitbucket')
%th= _('To GitLab')
%th= _('Status')
%tbody
- @already_added_projects.each do |project|
%tr{ id: "project_#{project.id}", class: "#{project_status_css_class(project.import_status)}" }
%td
= link_to project.import_source, "https://bitbucket.org/#{project.import_source}", target: '_blank', rel: 'noopener noreferrer'
%td
= link_to project.full_path, [project.namespace.becomes(Namespace), project]
%td.job-status
- case project.import_status
- when 'finished'
%span
%i.fa.fa-check
= _('done')
- when 'started'
%i.fa.fa-spinner.fa-spin
= _('started')
- else
= project.human_import_status_name
- @repos.each do |repo|
%tr{ id: "repo_#{repo.owner}___#{repo.slug}" }
%td
= link_to repo.full_name, "https://bitbucket.org/#{repo.full_name}", target: '_blank', rel: 'noopener noreferrer'
%td.import-target
%fieldset.row
.input-group
.project-path.input-group-prepend
- if current_user.can_select_namespace?
- selected = params[:namespace_id] || :current_user
- opts = current_user.can_create_group? ? { extra_group: Group.new(name: repo.owner, path: repo.owner) } : {}
= select_tag :namespace_id, namespaces_options(selected, opts.merge({ display_path: true })), { class: 'select2 js-select-namespace', tabindex: 1 }
- else
= text_field_tag :path, current_user.namespace_path, class: "input-group-text input-large form-control", tabindex: 1, disabled: true
%span.input-group-prepend
.input-group-text /
= text_field_tag :path, sanitize_project_name(repo.slug), class: "input-mini form-control", tabindex: 2, autofocus: true, required: true
%td.import-actions.job-status
= button_tag class: 'btn btn-import js-add-to-import' do
= _('Import')
= icon('spinner spin', class: 'loading-icon')
- @incompatible_repos.each do |repo|
%tr{ id: "repo_#{repo.owner}___#{repo.slug}" }
%td
= link_to repo.full_name, "https://bitbucket.org/#{repo.full_name}", target: '_blank', rel: 'noopener noreferrer'
%td.import-target
%td.import-actions-job-status
= label_tag _('Incompatible Project'), nil, class: 'label badge-danger'
- if @incompatible_repos.any?
%p
= _("One or more of your Bitbucket projects cannot be imported into GitLab directly because they use Subversion or Mercurial for version control, rather than Git.")
- link_to_git = link_to(_('Git'), 'https://www.atlassian.com/git/tutorials/migrating-overview')
- link_to_import_flow = link_to(_('import flow'), status_import_bitbucket_path)
= _("Please convert them to %{link_to_git}, and go through the %{link_to_import_flow} again.").html_safe % { link_to_git: link_to_git, link_to_import_flow: link_to_import_flow }
.js-importer-status{ data: { jobs_import_path: "#{jobs_import_bitbucket_path}", import_path: "#{import_bitbucket_path}" } }
...@@ -5,94 +5,4 @@ ...@@ -5,94 +5,4 @@
%i.fa.fa-bitbucket-square %i.fa.fa-bitbucket-square
= _('Import projects from Bitbucket Server') = _('Import projects from Bitbucket Server')
- if Feature.enabled?(:new_import_ui) = render 'import/githubish_status', provider: 'bitbucket_server', extra_data: { reconfigure_path: configure_import_bitbucket_server_path }
= render 'import/githubish_status', provider: 'bitbucket_server', extra_data: { reconfigure_path: configure_import_bitbucket_server_path }
- else
- if @repos.any?
%p.light
= _('Select projects you want to import.')
.btn-group
- if @incompatible_repos.any?
= button_tag class: 'btn btn-import btn-success js-import-all' do
= _('Import all compatible projects')
= icon('spinner spin', class: 'loading-icon')
- else
= button_tag class: 'btn btn-import btn-success js-import-all' do
= _('Import all projects')
= icon('spinner spin', class: 'loading-icon')
.btn-group
= link_to('Reconfigure', configure_import_bitbucket_server_path, class: 'btn btn-primary', method: :post)
.input-btn-group.float-right
= form_tag status_import_bitbucket_server_path, :method => 'get' do
= text_field_tag :filter, sanitize(params[:filter]), class: 'form-control append-bottom-10', placeholder: _('Filter your projects by name'), size: 40, autoFocus: true
.table-responsive.prepend-top-10
%table.table.import-jobs
%colgroup.import-jobs-from-col
%colgroup.import-jobs-to-col
%colgroup.import-jobs-status-col
%thead
%tr
%th= _('From Bitbucket Server')
%th= _('To GitLab')
%th= _('Status')
%tbody
- @already_added_projects.each do |project|
%tr{ id: "project_#{project.id}", class: "#{project_status_css_class(project.import_status)}" }
%td
= link_to project.import_source, project.import_source, target: '_blank', rel: 'noopener noreferrer'
%td
= link_to project.full_path, [project.namespace.becomes(Namespace), project]
%td.job-status
- case project.import_status
- when 'finished'
= icon('check', text: 'Done')
- when 'started'
= icon('spin', text: 'started')
- else
= project.human_import_status_name
- @repos.each do |repo|
%tr{ data: { id: "#{repo.project_key}/#{repo.slug}" } }
%td
= sanitize(link_to(repo.browse_url, repo.browse_url, target: '_blank', rel: 'noopener noreferrer'), attributes: %w(href target rel))
%td.import-target
%fieldset.row
.input-group
.project-path.input-group-prepend
- if current_user.can_select_namespace?
- selected = params[:namespace_id] || :extra_group
- opts = current_user.can_create_group? ? { extra_group: Group.new(name: sanitize_project_name(repo.project_key), path: sanitize_project_name(repo.project_key)) } : {}
= select_tag :namespace_id, namespaces_options(selected, opts.merge({ display_path: true })), { class: 'select2 js-select-namespace', tabindex: 1 }
- else
= text_field_tag :path, current_user.namespace_path, class: "input-group-text input-large form-control", tabindex: 1, disabled: true
%span.input-group-prepend
.input-group-text /
= text_field_tag :path, sanitize_project_name(repo.slug), class: "input-mini form-control", tabindex: 2, required: true
%td.import-actions.job-status
= button_tag class: 'btn btn-import js-add-to-import' do
Import
= icon('spinner spin', class: 'loading-icon')
- @incompatible_repos.each do |repo|
%tr{ id: "repo_#{repo.project_key}___#{repo.slug}" }
%td
= sanitize(link_to(repo.browse_url, repo.browse_url, target: '_blank', rel: 'noopener noreferrer'), attributes: %w(href target rel))
%td.import-target
%td.import-actions-job-status
= label_tag 'Incompatible Project', nil, class: 'label badge-danger'
- if @incompatible_repos.any?
%p
One or more of your Bitbucket Server projects cannot be imported into GitLab
directly because they use Subversion or Mercurial for version control,
rather than Git. Please convert
= link_to 'them to Git,', 'https://www.atlassian.com/git/tutorials/migrating-overview'
and go through the
= link_to 'import flow', status_import_bitbucket_server_path
again.
= paginate_without_count(@collection)
.js-importer-status{ data: { jobs_import_path: "#{jobs_import_bitbucket_server_path}", import_path: "#{import_bitbucket_server_path}" } }
...@@ -4,63 +4,8 @@ ...@@ -4,63 +4,8 @@
%i.fa.fa-bug %i.fa.fa-bug
= _('Import projects from FogBugz') = _('Import projects from FogBugz')
- if Feature.enabled?(:new_import_ui) %p.light
%p.light
- link_to_customize = link_to('customize', new_user_map_import_fogbugz_path) - link_to_customize = link_to('customize', new_user_map_import_fogbugz_path)
= _('Optionally, you can %{link_to_customize} how FogBugz email addresses and usernames are imported into GitLab.').html_safe % { link_to_customize: link_to_customize } = _('Optionally, you can %{link_to_customize} how FogBugz email addresses and usernames are imported into GitLab.').html_safe % { link_to_customize: link_to_customize }
%hr %hr
= render 'import/githubish_status', provider: 'fogbugz', filterable: false = render 'import/githubish_status', provider: 'fogbugz', filterable: false
- else
- if @repos.any?
%p.light
= _('Select projects you want to import.')
%p.light
- link_to_customize = link_to('customize', new_user_map_import_fogbugz_path)
= _('Optionally, you can %{link_to_customize} how FogBugz email addresses and usernames are imported into GitLab.').html_safe % { link_to_customize: link_to_customize }
%hr
%p
= button_tag class: 'btn btn-import btn-success js-import-all' do
= _('Import all projects')
= icon("spinner spin", class: "loading-icon")
.table-responsive
%table.table.import-jobs
%colgroup.import-jobs-from-col
%colgroup.import-jobs-to-col
%colgroup.import-jobs-status-col
%thead
%tr
%th= _("From FogBugz")
%th= _("To GitLab")
%th= _("Status")
%tbody
- @already_added_projects.each do |project|
%tr{ id: "project_#{project.id}", class: "#{project_status_css_class(project.import_status)}" }
%td
= project.import_source
%td
= link_to project.full_path, [project.namespace.becomes(Namespace), project]
%td.job-status
- case project.import_status
- when 'finished'
%span
%i.fa.fa-check
= _("done")
- when 'started'
%i.fa.fa-spinner.fa-spin
= _("started")
- else
= project.human_import_status_name
- @repos.each do |repo|
%tr{ id: "repo_#{repo.id}" }
%td
= repo.name
%td.import-target
#{current_user.username}/#{repo.name}
%td.import-actions.job-status
= button_tag class: "btn btn-import js-add-to-import" do
= _("Import")
= icon("spinner spin", class: "loading-icon")
.js-importer-status{ data: { jobs_import_path: "#{jobs_import_fogbugz_path}", import_path: "#{import_fogbugz_path}" } }
...@@ -4,55 +4,4 @@ ...@@ -4,55 +4,4 @@
= sprite_icon('heart', size: 16, css_class: 'gl-vertical-align-middle') = sprite_icon('heart', size: 16, css_class: 'gl-vertical-align-middle')
= _('Import projects from GitLab.com') = _('Import projects from GitLab.com')
- if Feature.enabled?(:new_import_ui) = render 'import/githubish_status', provider: 'gitlab', filterable: false
= render 'import/githubish_status', provider: 'gitlab', filterable: false
- else
%p.light
= _('Select projects you want to import.')
%hr
%p
= button_tag class: "btn btn-import btn-success js-import-all" do
= _('Import all projects')
= icon("spinner spin", class: "loading-icon")
.table-responsive
%table.table.import-jobs
%colgroup.import-jobs-from-col
%colgroup.import-jobs-to-col
%colgroup.import-jobs-status-col
%thead
%tr
%th= _('From GitLab.com')
%th= _('To this GitLab instance')
%th= _('Status')
%tbody
- @already_added_projects.each do |project|
%tr{ id: "project_#{project.id}", class: "#{project_status_css_class(project.import_status)}" }
%td
= link_to project.import_source, "https://gitlab.com/#{project.import_source}", target: "_blank"
%td
= link_to project.full_path, [project.namespace.becomes(Namespace), project]
%td.job-status
- case project.import_status
- when 'finished'
%span
%i.fa.fa-check
= _('done')
- when 'started'
%i.fa.fa-spinner.fa-spin
= _('started')
- else
= project.human_import_status_name
- @repos.each do |repo|
%tr{ id: "repo_#{repo["id"]}" }
%td
= link_to repo["path_with_namespace"], "https://gitlab.com/#{repo["path_with_namespace"]}", target: "_blank", rel: 'noopener noreferrer'
%td.import-target
= import_project_target(repo['namespace']['path'], repo['name'])
%td.import-actions.job-status
= button_tag class: "btn btn-import js-add-to-import" do
= _('Import')
= icon("spinner spin", class: "loading-icon")
.js-importer-status{ data: { jobs_import_path: "#{jobs_import_gitlab_path}", import_path: "#{import_gitlab_path}" } }
...@@ -24,14 +24,12 @@ namespace :import do ...@@ -24,14 +24,12 @@ namespace :import do
resource :gitlab, only: [:create], controller: :gitlab do resource :gitlab, only: [:create], controller: :gitlab do
get :status get :status
get :callback get :callback
get :jobs
get :realtime_changes get :realtime_changes
end end
resource :bitbucket, only: [:create], controller: :bitbucket do resource :bitbucket, only: [:create], controller: :bitbucket do
get :status get :status
get :callback get :callback
get :jobs
get :realtime_changes get :realtime_changes
end end
...@@ -39,7 +37,6 @@ namespace :import do ...@@ -39,7 +37,6 @@ namespace :import do
post :configure post :configure
get :status get :status
get :callback get :callback
get :jobs
get :realtime_changes get :realtime_changes
end end
...@@ -55,7 +52,6 @@ namespace :import do ...@@ -55,7 +52,6 @@ namespace :import do
resource :fogbugz, only: [:create, :new], controller: :fogbugz do resource :fogbugz, only: [:create, :new], controller: :fogbugz do
get :status get :status
post :callback post :callback
get :jobs
get :realtime_changes get :realtime_changes
get :new_user_map, path: :user_map get :new_user_map, path: :user_map
......
...@@ -10357,9 +10357,6 @@ msgstr "" ...@@ -10357,9 +10357,6 @@ msgstr ""
msgid "Filter pipelines" msgid "Filter pipelines"
msgstr "" msgstr ""
msgid "Filter projects"
msgstr ""
msgid "Filter results" msgid "Filter results"
msgstr "" msgstr ""
...@@ -10567,18 +10564,6 @@ msgstr "" ...@@ -10567,18 +10564,6 @@ msgstr ""
msgid "From <code>%{source_title}</code> into" msgid "From <code>%{source_title}</code> into"
msgstr "" msgstr ""
msgid "From Bitbucket"
msgstr ""
msgid "From Bitbucket Server"
msgstr ""
msgid "From FogBugz"
msgstr ""
msgid "From GitLab.com"
msgstr ""
msgid "From Google Code" msgid "From Google Code"
msgstr "" msgstr ""
...@@ -11053,9 +11038,6 @@ msgstr "" ...@@ -11053,9 +11038,6 @@ msgstr ""
msgid "Getting started with releases" msgid "Getting started with releases"
msgstr "" msgstr ""
msgid "Git"
msgstr ""
msgid "Git LFS is not enabled on this GitLab server, contact your admin." msgid "Git LFS is not enabled on this GitLab server, contact your admin."
msgstr "" msgstr ""
...@@ -16249,9 +16231,6 @@ msgstr "" ...@@ -16249,9 +16231,6 @@ msgstr ""
msgid "One or more of your %{provider} projects cannot be imported into GitLab directly because they use Subversion or Mercurial for version control, rather than Git." msgid "One or more of your %{provider} projects cannot be imported into GitLab directly because they use Subversion or Mercurial for version control, rather than Git."
msgstr "" msgstr ""
msgid "One or more of your Bitbucket projects cannot be imported into GitLab directly because they use Subversion or Mercurial for version control, rather than Git."
msgstr ""
msgid "One or more of your Google Code projects cannot be imported into GitLab directly because they use Subversion or Mercurial for version control, rather than Git." msgid "One or more of your Google Code projects cannot be imported into GitLab directly because they use Subversion or Mercurial for version control, rather than Git."
msgstr "" msgstr ""
...@@ -17305,9 +17284,6 @@ msgstr "" ...@@ -17305,9 +17284,6 @@ msgstr ""
msgid "Please convert %{linkStart}them to Git%{linkEnd}, and go through the %{linkToImportFlow} again." msgid "Please convert %{linkStart}them to Git%{linkEnd}, and go through the %{linkToImportFlow} again."
msgstr "" msgstr ""
msgid "Please convert them to %{link_to_git}, and go through the %{link_to_import_flow} again."
msgstr ""
msgid "Please convert them to Git on Google Code, and go through the %{link_to_import_flow} again." msgid "Please convert them to Git on Google Code, and go through the %{link_to_import_flow} again."
msgstr "" msgstr ""
...@@ -20485,9 +20461,6 @@ msgstr "" ...@@ -20485,9 +20461,6 @@ msgstr ""
msgid "Search" msgid "Search"
msgstr "" msgstr ""
msgid "Search Button"
msgstr ""
msgid "Search Jira issues" msgid "Search Jira issues"
msgstr "" msgstr ""
...@@ -24801,9 +24774,6 @@ msgstr "" ...@@ -24801,9 +24774,6 @@ msgstr ""
msgid "To start serving your jobs you can either add specific Runners to your project or use shared Runners" msgid "To start serving your jobs you can either add specific Runners to your project or use shared Runners"
msgstr "" msgstr ""
msgid "To this GitLab instance"
msgstr ""
msgid "To view all %{scannedResourcesCount} scanned URLs, please download the CSV file" msgid "To view all %{scannedResourcesCount} scanned URLs, please download the CSV file"
msgstr "" msgstr ""
......
...@@ -58,12 +58,12 @@ RSpec.describe Import::BitbucketController do ...@@ -58,12 +58,12 @@ RSpec.describe Import::BitbucketController do
before do before do
@repo = double(name: 'vim', slug: 'vim', owner: 'asd', full_name: 'asd/vim', clone_url: 'http://test.host/demo/url.git', 'valid?' => true) @repo = double(name: 'vim', slug: 'vim', owner: 'asd', full_name: 'asd/vim', clone_url: 'http://test.host/demo/url.git', 'valid?' => true)
@invalid_repo = double(name: 'mercurialrepo', slug: 'mercurialrepo', owner: 'asd', full_name: 'asd/mercurialrepo', clone_url: 'http://test.host/demo/mercurialrepo.git', 'valid?' => false) @invalid_repo = double(name: 'mercurialrepo', slug: 'mercurialrepo', owner: 'asd', full_name: 'asd/mercurialrepo', clone_url: 'http://test.host/demo/mercurialrepo.git', 'valid?' => false)
allow(controller).to receive(:provider_url).and_return('http://demobitbucket.org')
assign_session_tokens assign_session_tokens
stub_feature_flags(new_import_ui: false)
end end
it_behaves_like 'import controller with new_import_ui feature flag' do it_behaves_like 'import controller status' do
before do before do
allow(controller).to receive(:provider_url).and_return('http://demobitbucket.org') allow(controller).to receive(:provider_url).and_return('http://demobitbucket.org')
end end
...@@ -75,12 +75,6 @@ RSpec.describe Import::BitbucketController do ...@@ -75,12 +75,6 @@ RSpec.describe Import::BitbucketController do
let(:client_repos_field) { :repos } let(:client_repos_field) { :repos }
end end
context 'with new_import_ui feature flag enabled' do
before do
stub_feature_flags(new_import_ui: true)
allow(controller).to receive(:provider_url).and_return('http://demobitbucket.org')
end
it 'returns invalid repos' do it 'returns invalid repos' do
allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo, @invalid_repo]) allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo, @invalid_repo])
...@@ -92,28 +86,6 @@ RSpec.describe Import::BitbucketController do ...@@ -92,28 +86,6 @@ RSpec.describe Import::BitbucketController do
expect(json_response['provider_repos'].length).to eq(1) expect(json_response['provider_repos'].length).to eq(1)
expect(json_response.dig("provider_repos", 0, "id")).to eq(@repo.full_name) expect(json_response.dig("provider_repos", 0, "id")).to eq(@repo.full_name)
end end
end
it "assigns variables" do
@project = create(:project, import_type: 'bitbucket', creator_id: user.id)
allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo])
get :status
expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([@repo])
expect(assigns(:incompatible_repos)).to eq([])
end
it "does not show already added project" do
@project = create(:project, import_type: 'bitbucket', creator_id: user.id, import_source: 'asd/vim')
allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo])
get :status
expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([])
end
context 'when filtering' do context 'when filtering' do
let(:filter) { '<html>test</html>' } let(:filter) { '<html>test</html>' }
......
...@@ -148,12 +148,6 @@ RSpec.describe Import::BitbucketServerController do ...@@ -148,12 +148,6 @@ RSpec.describe Import::BitbucketServerController do
@invalid_repo = double(slug: 'invalid', project_key: 'foobar', full_name: 'asd/foobar', "valid?" => false, browse_url: 'http://bad-repo', name: 'invalid') @invalid_repo = double(slug: 'invalid', project_key: 'foobar', full_name: 'asd/foobar', "valid?" => false, browse_url: 'http://bad-repo', name: 'invalid')
@created_repo = double(slug: 'created', project_key: 'existing', full_name: 'group/created', "valid?" => true, browse_url: 'http://existing') @created_repo = double(slug: 'created', project_key: 'existing', full_name: 'group/created', "valid?" => true, browse_url: 'http://existing')
assign_session_tokens assign_session_tokens
stub_feature_flags(new_import_ui: false)
end
context 'with new_import_ui feature flag enabled' do
before do
stub_feature_flags(new_import_ui: true)
end end
it 'returns invalid repos' do it 'returns invalid repos' do
...@@ -167,9 +161,8 @@ RSpec.describe Import::BitbucketServerController do ...@@ -167,9 +161,8 @@ RSpec.describe Import::BitbucketServerController do
expect(json_response['provider_repos'].length).to eq(1) expect(json_response['provider_repos'].length).to eq(1)
expect(json_response.dig("provider_repos", 0, "id")).to eq(@repo.full_name) expect(json_response.dig("provider_repos", 0, "id")).to eq(@repo.full_name)
end end
end
it_behaves_like 'import controller with new_import_ui feature flag' do it_behaves_like 'import controller status' do
let(:repo) { @repo } let(:repo) { @repo }
let(:repo_id) { @repo.full_name } let(:repo_id) { @repo.full_name }
let(:import_source) { @repo.browse_url } let(:import_source) { @repo.browse_url }
...@@ -177,47 +170,14 @@ RSpec.describe Import::BitbucketServerController do ...@@ -177,47 +170,14 @@ RSpec.describe Import::BitbucketServerController do
let(:client_repos_field) { :repos } let(:client_repos_field) { :repos }
end end
it 'assigns repository categories' do
created_project = create(:project, :import_finished, import_type: 'bitbucket_server', creator_id: user.id, import_source: @created_repo.browse_url)
expect(repos).to receive(:partition).and_return([[@repo, @created_repo], [@invalid_repo]])
expect(repos).to receive(:current_page).and_return(1)
expect(repos).to receive(:next_page).and_return(2)
expect(repos).to receive(:prev_page).and_return(nil)
expect(client).to receive(:repos).and_return(repos)
get :status
expect(assigns(:already_added_projects)).to eq([created_project])
expect(assigns(:repos)).to eq([@repo])
expect(assigns(:incompatible_repos)).to eq([@invalid_repo])
end
context 'when filtering' do context 'when filtering' do
let(:filter) { 'test' } let(:filter) { 'test' }
it 'passes filter param to bitbucket client' do it 'passes filter param to bitbucket client' do
expect(repos).to receive(:partition).and_return([[@repo, @created_repo], [@invalid_repo]]) expect(client).to receive(:repos).with(filter: filter, limit: 25, page_offset: 0).and_return([@repo])
expect(client).to receive(:repos).with(filter: filter, limit: 25, page_offset: 0).and_return(repos)
get :status, params: { filter: filter }, as: :json get :status, params: { filter: filter }, as: :json
end end
end end
end end
describe 'GET jobs' do
before do
assign_session_tokens
end
it 'returns a list of imported projects' do
created_project = create(:project, import_type: 'bitbucket_server', creator_id: user.id)
get :jobs
expect(json_response.count).to eq(1)
expect(json_response.first['id']).to eq(created_project.id)
expect(json_response.first['import_status']).to eq('none')
end
end
end end
...@@ -82,36 +82,15 @@ RSpec.describe Import::FogbugzController do ...@@ -82,36 +82,15 @@ RSpec.describe Import::FogbugzController do
before do before do
@repo = OpenStruct.new(id: 'demo', name: 'vim') @repo = OpenStruct.new(id: 'demo', name: 'vim')
stub_client(valid?: true) stub_client(valid?: true)
stub_feature_flags(new_import_ui: false)
end end
it_behaves_like 'import controller with new_import_ui feature flag' do it_behaves_like 'import controller status' do
let(:repo) { @repo } let(:repo) { @repo }
let(:repo_id) { @repo.id } let(:repo_id) { @repo.id }
let(:import_source) { @repo.name } let(:import_source) { @repo.name }
let(:provider_name) { 'fogbugz' } let(:provider_name) { 'fogbugz' }
let(:client_repos_field) { :repos } let(:client_repos_field) { :repos }
end end
it 'assigns variables' do
@project = create(:project, import_type: 'fogbugz', creator_id: user.id)
stub_client(repos: [@repo])
get :status
expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([@repo])
end
it 'does not show already added project' do
@project = create(:project, import_type: 'fogbugz', creator_id: user.id, import_source: 'vim')
stub_client(repos: [@repo])
get :status
expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([])
end
end end
describe 'POST create' do describe 'POST create' do
......
...@@ -36,36 +36,15 @@ RSpec.describe Import::GitlabController do ...@@ -36,36 +36,15 @@ RSpec.describe Import::GitlabController do
before do before do
@repo = OpenStruct.new(id: 1, path: 'vim', path_with_namespace: 'asd/vim', web_url: 'https://gitlab.com/asd/vim') @repo = OpenStruct.new(id: 1, path: 'vim', path_with_namespace: 'asd/vim', web_url: 'https://gitlab.com/asd/vim')
assign_session_token assign_session_token
stub_feature_flags(new_import_ui: false)
end end
it_behaves_like 'import controller with new_import_ui feature flag' do it_behaves_like 'import controller status' do
let(:repo) { @repo } let(:repo) { @repo }
let(:repo_id) { @repo.id } let(:repo_id) { @repo.id }
let(:import_source) { @repo.path_with_namespace } let(:import_source) { @repo.path_with_namespace }
let(:provider_name) { 'gitlab' } let(:provider_name) { 'gitlab' }
let(:client_repos_field) { :projects } let(:client_repos_field) { :projects }
end end
it "assigns variables" do
@project = create(:project, import_type: 'gitlab', creator_id: user.id)
stub_client(projects: [@repo])
get :status
expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([@repo])
end
it "does not show already added project" do
@project = create(:project, import_type: 'gitlab', creator_id: user.id, import_source: 'asd/vim')
stub_client(projects: [@repo])
get :status
expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([])
end
end end
describe "POST create" do describe "POST create" do
......
...@@ -92,23 +92,37 @@ end ...@@ -92,23 +92,37 @@ end
# status_import_gitlab GET /import/gitlab/status(.:format) import/gitlab#status # status_import_gitlab GET /import/gitlab/status(.:format) import/gitlab#status
# callback_import_gitlab GET /import/gitlab/callback(.:format) import/gitlab#callback # callback_import_gitlab GET /import/gitlab/callback(.:format) import/gitlab#callback
# jobs_import_gitlab GET /import/gitlab/jobs(.:format) import/gitlab#jobs # realtime_changes_import_gitlab GET /import/gitlab/realtime_changes(.:format) import/gitlab#realtime_changes
# import_gitlab POST /import/gitlab(.:format) import/gitlab#create # import_gitlab POST /import/gitlab(.:format) import/gitlab#create
RSpec.describe Import::GitlabController, 'routing' do RSpec.describe Import::GitlabController, 'routing' do
it_behaves_like 'importer routing' do it_behaves_like 'importer routing' do
let(:except_actions) { [:new] } let(:except_actions) { [:new] }
let(:provider) { 'gitlab' } let(:provider) { 'gitlab' }
let(:is_realtime) { true }
end end
end end
# status_import_bitbucket GET /import/bitbucket/status(.:format) import/bitbucket#status # status_import_bitbucket GET /import/bitbucket/status(.:format) import/bitbucket#status
# callback_import_bitbucket GET /import/bitbucket/callback(.:format) import/bitbucket#callback # callback_import_bitbucket GET /import/bitbucket/callback(.:format) import/bitbucket#callback
# jobs_import_bitbucket GET /import/bitbucket/jobs(.:format) import/bitbucket#jobs # realtime_changes_import_bitbucket GET /import/bitbucket/realtime_changes(.:format) import/bitbucket#realtime_changes
# import_bitbucket POST /import/bitbucket(.:format) import/bitbucket#create # import_bitbucket POST /import/bitbucket(.:format) import/bitbucket#create
RSpec.describe Import::BitbucketController, 'routing' do RSpec.describe Import::BitbucketController, 'routing' do
it_behaves_like 'importer routing' do it_behaves_like 'importer routing' do
let(:except_actions) { [:new] } let(:except_actions) { [:new] }
let(:provider) { 'bitbucket' } let(:provider) { 'bitbucket' }
let(:is_realtime) { true }
end
end
# status_import_bitbucket_server GET /import/bitbucket_server/status(.:format) import/bitbucket_server#status
# callback_import_bitbucket_server GET /import/bitbucket_server/callback(.:format) import/bitbucket_server#callback
# realtime_changes_import_bitbucket_server GET /import/bitbucket_server/realtime_changes(.:format) import/bitbucket_server#realtime_changes
# new_import_bitbucket_server GET /import/bitbucket_server/new(.:format) import/bitbucket_server#new
# import_bitbucket_server POST /import/bitbucket_server(.:format) import/bitbucket_server#create
RSpec.describe Import::BitbucketServerController, 'routing' do
it_behaves_like 'importer routing' do
let(:provider) { 'bitbucket_server' }
let(:is_realtime) { true }
end end
end end
...@@ -140,7 +154,7 @@ end ...@@ -140,7 +154,7 @@ end
# status_import_fogbugz GET /import/fogbugz/status(.:format) import/fogbugz#status # status_import_fogbugz GET /import/fogbugz/status(.:format) import/fogbugz#status
# callback_import_fogbugz POST /import/fogbugz/callback(.:format) import/fogbugz#callback # callback_import_fogbugz POST /import/fogbugz/callback(.:format) import/fogbugz#callback
# jobs_import_fogbugz GET /import/fogbugz/jobs(.:format) import/fogbugz#jobs # realtime_changes_import_fogbugz GET /import/fogbugz/realtime_changes(.:format) import/fogbugz#realtime_changes
# new_user_map_import_fogbugz GET /import/fogbugz/user_map(.:format) import/fogbugz#new_user_map # new_user_map_import_fogbugz GET /import/fogbugz/user_map(.:format) import/fogbugz#new_user_map
# create_user_map_import_fogbugz POST /import/fogbugz/user_map(.:format) import/fogbugz#create_user_map # create_user_map_import_fogbugz POST /import/fogbugz/user_map(.:format) import/fogbugz#create_user_map
# import_fogbugz POST /import/fogbugz(.:format) import/fogbugz#create # import_fogbugz POST /import/fogbugz(.:format) import/fogbugz#create
...@@ -149,6 +163,7 @@ RSpec.describe Import::FogbugzController, 'routing' do ...@@ -149,6 +163,7 @@ RSpec.describe Import::FogbugzController, 'routing' do
it_behaves_like 'importer routing' do it_behaves_like 'importer routing' do
let(:except_actions) { [:callback] } let(:except_actions) { [:callback] }
let(:provider) { 'fogbugz' } let(:provider) { 'fogbugz' }
let(:is_realtime) { true }
end end
it 'to #callback' do it 'to #callback' do
......
# frozen_string_literal: true
RSpec.shared_examples 'import controller with new_import_ui feature flag' do
include ImportSpecHelper
context 'with new_import_ui feature flag enabled' do
let(:group) { create(:group) }
before do
stub_feature_flags(new_import_ui: true)
group.add_owner(user)
end
it "returns variables for json request" do
project = create(:project, import_type: provider_name, creator_id: user.id)
stub_client(client_repos_field => [repo])
get :status, format: :json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.dig("imported_projects", 0, "id")).to eq(project.id)
expect(json_response.dig("provider_repos", 0, "id")).to eq(repo_id)
expect(json_response.dig("namespaces", 0, "id")).to eq(group.id)
end
it "does not show already added project" do
project = create(:project, import_type: provider_name, namespace: user.namespace, import_status: :finished, import_source: import_source)
stub_client(client_repos_field => [repo])
get :status, format: :json
expect(json_response.dig("imported_projects", 0, "id")).to eq(project.id)
expect(json_response.dig("provider_repos")).to eq([])
end
end
end
# frozen_string_literal: true
RSpec.shared_examples 'import controller status' do
include ImportSpecHelper
let(:group) { create(:group) }
before do
group.add_owner(user)
end
it "returns variables for json request" do
project = create(:project, import_type: provider_name, creator_id: user.id)
stub_client(client_repos_field => [repo])
get :status, format: :json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.dig("imported_projects", 0, "id")).to eq(project.id)
expect(json_response.dig("provider_repos", 0, "id")).to eq(repo_id)
expect(json_response.dig("namespaces", 0, "id")).to eq(group.id)
end
it "does not show already added project" do
project = create(:project, import_type: provider_name, namespace: user.namespace, import_status: :finished, import_source: import_source)
stub_client(client_repos_field => [repo])
get :status, format: :json
expect(json_response.dig("imported_projects", 0, "id")).to eq(project.id)
expect(json_response.dig("provider_repos")).to eq([])
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