Commit 10f16095 authored by James Lopez's avatar James Lopez

changes to be picked by the UI branch

parent 8f973b8f
class Import::GitlabProjectController < Import::BaseController
before_action :verify_gitlab_project_import_enabled
before_action :gitlab_project_auth, except: :callback
rescue_from OAuth::Error, with: :gitlab_project_unauthorized
#TODO permissions stuff
def callback
redirect_to status_import_gitlab_project_url
end
def status
@repos = client.projects
@incompatible_repos = client.incompatible_projects
@already_added_projects = current_user.created_projects.where(import_type: "gitlab_project")
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos.to_a.reject!{ |repo| already_added_projects_names.include? "#{repo["owner"]}/#{repo["slug"]}" }
end
def jobs
jobs = current_user.created_projects.where(import_type: "gitlab_project").to_json(only: [:id, :import_status])
render json: jobs
end
def create
@file = params[:file]
# @project_name =
repo_owner = current_user.username
@target_namespace = params[:new_namespace].presence || repo_owner
namespace = get_or_create_namespace || (render and return)
@project = Gitlab::ImportExport::ImportService.execute(archive_file: file, owner: repo_owner)
end
private
def verify_gitlab_project_import_enabled
render_404 unless gitlab_project_import_enabled?
end
end
......@@ -156,6 +156,12 @@ Rails.application.routes.draw do
get :new_user_map, path: :user_map
post :create_user_map, path: :user_map
end
resource :gitlab_project, only: [:create, :new], controller: :gitlab_projects do
get :status
get :callback
get :jobs
end
end
#
......
module Projects
module Gitlab
module ImportExport
class ExportService < BaseService
def execute(options = {})
archive_file = options[:archive_file]
Gitlab::ImportExport::Importer.import(archive_file: archive_file, storage_path: storage_path)
class ImportService
def self.execute(*args)
new(args).execute
end
def initialize(options = {})
@archive_file = options[:archive_file]
@current_user = options[:owner]
end
def execute
Gitlab::ImportExport::Importer.import(archive_file: @archive_file, storage_path: storage_path)
restore_project_tree
restore_repo(project_tree.project)
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