Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMarcin Kulik <m@ku1ik.com>2015-02-20 20:38:41 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-21 01:47:38 +0300
commitfcabff63f21e6eb44f623528b3a96fc237ef4820 (patch)
tree26f5721bf8472fd319158ecf9f0eb7811e0b28eb /app
parent3360ee876a104459a343f8f82c51b90ba4a717af (diff)
Add gitorious.org importer
Diffstat (limited to 'app')
-rw-r--r--app/controllers/import/gitorious_controller.rb43
-rw-r--r--app/views/import/gitorious/status.html.haml41
-rw-r--r--app/views/projects/new.html.haml7
3 files changed, 91 insertions, 0 deletions
diff --git a/app/controllers/import/gitorious_controller.rb b/app/controllers/import/gitorious_controller.rb
new file mode 100644
index 00000000000..627b4a171b8
--- /dev/null
+++ b/app/controllers/import/gitorious_controller.rb
@@ -0,0 +1,43 @@
+class Import::GitoriousController < Import::BaseController
+
+ def new
+ redirect_to client.authorize_url(callback_import_gitorious_url)
+ end
+
+ def callback
+ session[:gitorious_repos] = params[:repos]
+ redirect_to status_import_gitorious_url
+ end
+
+ def status
+ @repos = client.repos
+
+ @already_added_projects = current_user.created_projects.where(import_type: "gitorious")
+ already_added_projects_names = @already_added_projects.pluck(:import_source)
+
+ @repos.to_a.reject! { |repo| already_added_projects_names.include? repo.full_name }
+ end
+
+ def jobs
+ jobs = current_user.created_projects.where(import_type: "gitorious").to_json(only: [:id, :import_status])
+ render json: jobs
+ end
+
+ def create
+ @repo_id = params[:repo_id]
+ repo = client.repo(@repo_id)
+ @target_namespace = params[:new_namespace].presence || repo.namespace
+ @project_name = repo.name
+
+ namespace = get_or_create_namespace || (render and return)
+
+ @project = Gitlab::GitoriousImport::ProjectCreator.new(repo, namespace, current_user).execute
+ end
+
+ private
+
+ def client
+ @client ||= Gitlab::GitoriousImport::Client.new(session[:gitorious_repos])
+ end
+
+end
diff --git a/app/views/import/gitorious/status.html.haml b/app/views/import/gitorious/status.html.haml
new file mode 100644
index 00000000000..35ed0a717de
--- /dev/null
+++ b/app/views/import/gitorious/status.html.haml
@@ -0,0 +1,41 @@
+%h3.page-title
+ %i.fa.fa-gitorious
+ Import repositories from Gitorious.org
+
+%p.light
+ Select projects you want to import.
+%hr
+%p
+ = button_tag 'Import all projects', class: "btn btn-success js-import-all"
+
+%table.table.import-jobs
+ %thead
+ %tr
+ %th From Gitorious
+ %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
+ %strong= link_to project.path_with_namespace, project
+ %td.job-status
+ - if project.import_status == 'finished'
+ %span.cgreen
+ %i.fa.fa-check
+ done
+ - else
+ = project.human_import_status_name
+
+ - @repos.each do |repo|
+ %tr{id: "repo_#{repo.id}"}
+ %td= repo.full_name
+ %td.import-target
+ = repo.full_name
+ %td.import-actions.job-status
+ = button_tag "Import", class: "btn js-add-to-import"
+
+:coffeescript
+ $ ->
+ new ImporterStatus("#{jobs_import_gitorious_path}", "#{import_gitorious_path}")
diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml
index 6f5851d61a1..33162ded4a6 100644
--- a/app/views/projects/new.html.haml
+++ b/app/views/projects/new.html.haml
@@ -66,6 +66,13 @@
Import projects from GitLab.com
= render 'gitlab_import_modal'
+ .project-import.form-group
+ .col-sm-2
+ .col-sm-10
+ = link_to new_import_gitorious_path do
+ %i.fa.fa-heart
+ Import projects from Gitorious.org
+
%hr.prepend-botton-10
.form-group