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
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2015-02-03 04:01:07 +0300
committerValery Sizov <valery@gitlab.com>2015-02-05 23:50:34 +0300
commit33349dd54928a0b074b4ae3ebfabf214799fc085 (patch)
tree593a14d0f6df812410349f353e252e3a58d8cacd /app/views/import
parent713bc152bde5396bb95a1555907bcd9a2847839d (diff)
GitLab.com integration: refactoring
Diffstat (limited to 'app/views/import')
-rw-r--r--app/views/import/github/create.js.haml18
-rw-r--r--app/views/import/github/status.html.haml63
-rw-r--r--app/views/import/gitlab/create.js.haml18
-rw-r--r--app/views/import/gitlab/status.html.haml63
4 files changed, 162 insertions, 0 deletions
diff --git a/app/views/import/github/create.js.haml b/app/views/import/github/create.js.haml
new file mode 100644
index 00000000000..cd4c9fbf360
--- /dev/null
+++ b/app/views/import/github/create.js.haml
@@ -0,0 +1,18 @@
+- if @already_been_taken
+ :plain
+ target_field = $("tr#repo_#{@repo_id} .import-target")
+ origin_target = target_field.text()
+ project_name = "#{@project_name}"
+ origin_namespace = "#{@target_namespace}"
+ target_field.empty()
+ target_field.append("<p class='alert alert-danger'>This namespace already been taken! Please choose another one</p>")
+ target_field.append("<input type='text' name='target_namespace' />")
+ target_field.append("/" + project_name)
+ target_field.data("project_name", project_name)
+ target_field.find('input').prop("value", origin_namespace)
+- else
+ :plain
+ job = $("tr#repo_#{@repo_id}")
+ job.attr("id", "project_#{@project.id}")
+ $("table.import-jobs tbody").prepend(job)
+ job.addClass("active").find(".import-actions").html("<i class='fa fa-spinner fa-spin'></i> started")
diff --git a/app/views/import/github/status.html.haml b/app/views/import/github/status.html.haml
new file mode 100644
index 00000000000..9797f5983ea
--- /dev/null
+++ b/app/views/import/github/status.html.haml
@@ -0,0 +1,63 @@
+%h3.page-title
+ %i.fa.fa-github
+ Import repositories from GitHub.com
+
+%p.light
+ Select projects you want to import.
+
+%hr
+%table.table.import-jobs
+ %thead
+ %tr
+ %th From GitHub
+ %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 "Add", class: "btn btn-add-to-import"
+
+
+:coffeescript
+ $(".btn-add-to-import").click () ->
+ new_namespace = null
+ tr = $(this).closest("tr")
+ id = tr.attr("id").replace("repo_", "")
+ if tr.find(".import-target input").length > 0
+ new_namespace = tr.find(".import-target input").prop("value")
+ tr.find(".import-target").empty().append(new_namespace + "/" + tr.find(".import-target").data("project_name"))
+ $.post "#{import_github_url}", {repo_id: id, new_namespace: new_namespace}, dataType: 'script'
+
+
+ setInterval (->
+ $.get "#{jobs_import_github_path}", (data)->
+ $.each data, (i, job) ->
+ job_item = $("#project_" + job.id)
+ status_field = job_item.find(".job-status")
+
+ if job.import_status == 'finished'
+ job_item.removeClass("active").addClass("success")
+ status_field.html('<span class="cgreen"><i class="fa fa-check"></i> done</span>')
+ else if job.import_status == 'started'
+ status_field.html("<i class='fa fa-spinner fa-spin'></i> started")
+ else
+ status_field.html(job.import_status)
+
+ ), 4000
diff --git a/app/views/import/gitlab/create.js.haml b/app/views/import/gitlab/create.js.haml
new file mode 100644
index 00000000000..cd4c9fbf360
--- /dev/null
+++ b/app/views/import/gitlab/create.js.haml
@@ -0,0 +1,18 @@
+- if @already_been_taken
+ :plain
+ target_field = $("tr#repo_#{@repo_id} .import-target")
+ origin_target = target_field.text()
+ project_name = "#{@project_name}"
+ origin_namespace = "#{@target_namespace}"
+ target_field.empty()
+ target_field.append("<p class='alert alert-danger'>This namespace already been taken! Please choose another one</p>")
+ target_field.append("<input type='text' name='target_namespace' />")
+ target_field.append("/" + project_name)
+ target_field.data("project_name", project_name)
+ target_field.find('input').prop("value", origin_namespace)
+- else
+ :plain
+ job = $("tr#repo_#{@repo_id}")
+ job.attr("id", "project_#{@project.id}")
+ $("table.import-jobs tbody").prepend(job)
+ job.addClass("active").find(".import-actions").html("<i class='fa fa-spinner fa-spin'></i> started")
diff --git a/app/views/import/gitlab/status.html.haml b/app/views/import/gitlab/status.html.haml
new file mode 100644
index 00000000000..ff0ab189c0b
--- /dev/null
+++ b/app/views/import/gitlab/status.html.haml
@@ -0,0 +1,63 @@
+%h3.page-title
+ %i.fa.fa-github
+ Import repositories from GitLab.com
+
+%p.light
+ Select projects you want to import.
+
+%hr
+%table.table.import-jobs
+ %thead
+ %tr
+ %th From GitLab.com
+ %th To GitLab private instance
+ %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["path_with_namespace"]
+ %td.import-target
+ = repo["path_with_namespace"]
+ %td.import-actions.job-status
+ = button_tag "Add", class: "btn btn-add-to-import"
+
+
+:coffeescript
+ $(".btn-add-to-import").click () ->
+ new_namespace = null
+ tr = $(this).closest("tr")
+ id = tr.attr("id").replace("repo_", "")
+ if tr.find(".import-target input").length > 0
+ new_namespace = tr.find(".import-target input").prop("value")
+ tr.find(".import-target").empty().append(new_namespace + "/" + tr.find(".import-target").data("project_name"))
+ $.post "#{import_gitlab_url}", {repo_id: id, new_namespace: new_namespace}, dataType: 'script'
+
+
+ setInterval (->
+ $.get "#{jobs_import_gitlab_path}", (data)->
+ $.each data, (i, job) ->
+ job_item = $("#project_" + job.id)
+ status_field = job_item.find(".job-status")
+
+ if job.import_status == 'finished'
+ job_item.removeClass("active").addClass("success")
+ status_field.html('<span class="cgreen"><i class="fa fa-check"></i> done</span>')
+ else if job.import_status == 'started'
+ status_field.html("<i class='fa fa-spinner fa-spin'></i> started")
+ else
+ status_field.html(job.import_status)
+
+ ), 4000