Project import and retry import scaffold
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
1436433c7b
commit
37db76a31b
4 changed files with 89 additions and 55 deletions
|
@ -5,7 +5,7 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
# Authorize
|
# Authorize
|
||||||
before_filter :authorize_read_project!, except: [:index, :new, :create]
|
before_filter :authorize_read_project!, except: [:index, :new, :create]
|
||||||
before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive]
|
before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive, :retry_import]
|
||||||
before_filter :require_non_empty_project, only: [:blob, :tree, :graph]
|
before_filter :require_non_empty_project, only: [:blob, :tree, :graph]
|
||||||
|
|
||||||
layout 'navless', only: [:new, :create, :fork]
|
layout 'navless', only: [:new, :create, :fork]
|
||||||
|
@ -21,16 +21,9 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@project = ::Projects::CreateService.new(current_user, params[:project]).execute
|
@project = ::Projects::CreateService.new(current_user, params[:project]).execute
|
||||||
|
flash[:notice] = 'Project was successfully created.' if @project.saved?
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
flash[:notice] = 'Project was successfully created.' if @project.saved?
|
|
||||||
format.html do
|
|
||||||
if @project.saved?
|
|
||||||
redirect_to @project
|
|
||||||
else
|
|
||||||
render "new"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -67,9 +60,7 @@ class ProjectsController < ApplicationController
|
||||||
if @project.empty_repo?
|
if @project.empty_repo?
|
||||||
render "projects/empty", layout: user_layout
|
render "projects/empty", layout: user_layout
|
||||||
else
|
else
|
||||||
if current_user
|
@last_push = current_user.recent_push(@project.id) if current_user
|
||||||
@last_push = current_user.recent_push(@project.id)
|
|
||||||
end
|
|
||||||
render :show, layout: user_layout
|
render :show, layout: user_layout
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -77,6 +68,28 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def import
|
||||||
|
if project.import_finished?
|
||||||
|
redirect_to @project
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def retry_import
|
||||||
|
unless @project.import_failed?
|
||||||
|
redirect_to import_project_path(@project)
|
||||||
|
end
|
||||||
|
|
||||||
|
@project.import_url = params[:project][:import_url]
|
||||||
|
|
||||||
|
if @project.save
|
||||||
|
@project.reload
|
||||||
|
@project.import_retry
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to import_project_path(@project)
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
return access_denied! unless can?(current_user, :remove_project, project)
|
return access_denied! unless can?(current_user, :remove_project, project)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
- if @project.saved?
|
- if @project.saved?
|
||||||
|
- if @project.import?
|
||||||
|
:plain
|
||||||
|
location.href = "#{import_project_path(@project)}";
|
||||||
|
- else
|
||||||
:plain
|
:plain
|
||||||
location.href = "#{project_path(@project)}";
|
location.href = "#{project_path(@project)}";
|
||||||
- else
|
- else
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
= render "home_panel"
|
= render "home_panel"
|
||||||
|
|
||||||
- if @project.import? && !@project.imported
|
|
||||||
.save-project-loader
|
|
||||||
%center
|
|
||||||
%h2
|
|
||||||
%i.icon-spinner.icon-spin
|
|
||||||
Importing repository.
|
|
||||||
%p.monospace git clone --bare #{@project.import_url}
|
|
||||||
%p Please wait while we import the repository for you. Refresh at will.
|
|
||||||
:javascript
|
|
||||||
new ProjectImport();
|
|
||||||
|
|
||||||
- else
|
|
||||||
%div.git-empty
|
%div.git-empty
|
||||||
%fieldset
|
%fieldset
|
||||||
%legend Git global setup:
|
%legend Git global setup:
|
||||||
|
|
29
app/views/projects/import.html.haml
Normal file
29
app/views/projects/import.html.haml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
- if @project.import_in_progress?
|
||||||
|
.save-project-loader
|
||||||
|
%center
|
||||||
|
%h2
|
||||||
|
%i.icon-spinner.icon-spin
|
||||||
|
Import in progress.
|
||||||
|
%p.monospace git clone --bare #{@project.import_url}
|
||||||
|
%p Please wait while we import the repository for you. Refresh at will.
|
||||||
|
:javascript
|
||||||
|
new ProjectImport();
|
||||||
|
|
||||||
|
- elsif @project.import_failed?
|
||||||
|
.save-project-loader
|
||||||
|
%center
|
||||||
|
%h2
|
||||||
|
Import failed. Retry?
|
||||||
|
%hr
|
||||||
|
= form_for @project, url: retry_import_project_path(@project), method: :put, html: { class: 'form-horizontal' } do |f|
|
||||||
|
.form-group.import-url-data
|
||||||
|
= f.label :import_url, class: 'control-label' do
|
||||||
|
%span Import existing repo
|
||||||
|
.col-sm-10
|
||||||
|
= f.text_field :import_url, class: 'form-control', placeholder: 'https://github.com/randx/six.git'
|
||||||
|
.bs-callout.bs-callout-info
|
||||||
|
This url must be publicly accessible or you can add a username and password like this: https://username:password@gitlab.com/company/project.git.
|
||||||
|
%br
|
||||||
|
The import will time out after 2 minutes. For big repositories, use a clone/push combination.
|
||||||
|
.form-actions
|
||||||
|
= f.submit 'Retry import', class: "btn btn-create", tabindex: 4
|
Loading…
Reference in a new issue