Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
e238a8da
Commit
e238a8da
authored
Aug 14, 2015
by
Artem Sidorenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import sources: show only enabled sources
parent
55dca86b
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
166 additions
and
77 deletions
+166
-77
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+29
-1
app/controllers/import/gitorious_controller.rb
app/controllers/import/gitorious_controller.rb
+5
-0
app/controllers/import/google_code_controller.rb
app/controllers/import/google_code_controller.rb
+5
-0
app/views/projects/_bitbucket_import_modal.html.haml
app/views/projects/_bitbucket_import_modal.html.haml
+4
-4
app/views/projects/_github_import_modal.html.haml
app/views/projects/_github_import_modal.html.haml
+4
-4
app/views/projects/_gitlab_import_modal.html.haml
app/views/projects/_gitlab_import_modal.html.haml
+4
-4
app/views/projects/new.html.haml
app/views/projects/new.html.haml
+67
-62
features/dashboard/new_project.feature
features/dashboard/new_project.feature
+18
-1
features/steps/dashboard/new_project.rb
features/steps/dashboard/new_project.rb
+30
-1
No files found.
app/controllers/application_controller.rb
View file @
e238a8da
...
@@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base
...
@@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery
with: :exception
protect_from_forgery
with: :exception
helper_method
:abilities
,
:can?
,
:current_application_settings
helper_method
:abilities
,
:can?
,
:current_application_settings
helper_method
:
github_import_enabled?
,
:gitlab_import_enabled?
,
:bitbucke
t_import_enabled?
helper_method
:
import_sources_enabled?
,
:github_import_enabled?
,
:github_import_configured?
,
:gitlab_import_enabled?
,
:gitlab_import_configured?
,
:bitbucket_import_enabled?
,
:bitbucket_import_configured?
,
:gitorious_import_enabled?
,
:google_code_import_enabled?
,
:gi
t_import_enabled?
rescue_from
Encoding
::
CompatibilityError
do
|
exception
|
rescue_from
Encoding
::
CompatibilityError
do
|
exception
|
log_exception
(
exception
)
log_exception
(
exception
)
...
@@ -298,15 +298,43 @@ class ApplicationController < ActionController::Base
...
@@ -298,15 +298,43 @@ class ApplicationController < ActionController::Base
@issuable_finder
.
execute
@issuable_finder
.
execute
end
end
def
import_sources_enabled?
!
current_application_settings
.
import_sources
.
empty?
end
def
github_import_enabled?
def
github_import_enabled?
current_application_settings
.
import_sources
.
include?
(
'github'
)
end
def
github_import_configured?
Gitlab
::
OAuth
::
Provider
.
enabled?
(
:github
)
Gitlab
::
OAuth
::
Provider
.
enabled?
(
:github
)
end
end
def
gitlab_import_enabled?
def
gitlab_import_enabled?
request
.
host
!=
'gitlab.com'
&&
current_application_settings
.
import_sources
.
include?
(
'gitlab'
)
end
def
gitlab_import_configured?
Gitlab
::
OAuth
::
Provider
.
enabled?
(
:gitlab
)
Gitlab
::
OAuth
::
Provider
.
enabled?
(
:gitlab
)
end
end
def
bitbucket_import_enabled?
def
bitbucket_import_enabled?
current_application_settings
.
import_sources
.
include?
(
'bitbucket'
)
end
def
bitbucket_import_configured?
Gitlab
::
OAuth
::
Provider
.
enabled?
(
:bitbucket
)
&&
Gitlab
::
BitbucketImport
.
public_key
.
present?
Gitlab
::
OAuth
::
Provider
.
enabled?
(
:bitbucket
)
&&
Gitlab
::
BitbucketImport
.
public_key
.
present?
end
end
def
gitorious_import_enabled?
current_application_settings
.
import_sources
.
include?
(
'gitorious'
)
end
def
google_code_import_enabled?
current_application_settings
.
import_sources
.
include?
(
'google_code'
)
end
def
git_import_enabled?
current_application_settings
.
import_sources
.
include?
(
'git'
)
end
end
end
app/controllers/import/gitorious_controller.rb
View file @
e238a8da
class
Import::GitoriousController
<
Import
::
BaseController
class
Import::GitoriousController
<
Import
::
BaseController
before_action
:verify_gitorious_import_enabled
def
new
def
new
redirect_to
client
.
authorize_url
(
callback_import_gitorious_url
)
redirect_to
client
.
authorize_url
(
callback_import_gitorious_url
)
...
@@ -40,4 +41,8 @@ class Import::GitoriousController < Import::BaseController
...
@@ -40,4 +41,8 @@ class Import::GitoriousController < Import::BaseController
@client
||=
Gitlab
::
GitoriousImport
::
Client
.
new
(
session
[
:gitorious_repos
])
@client
||=
Gitlab
::
GitoriousImport
::
Client
.
new
(
session
[
:gitorious_repos
])
end
end
def
verify_gitorious_import_enabled
not_found!
unless
gitorious_import_enabled?
end
end
end
app/controllers/import/google_code_controller.rb
View file @
e238a8da
class
Import::GoogleCodeController
<
Import
::
BaseController
class
Import::GoogleCodeController
<
Import
::
BaseController
before_action
:verify_google_code_import_enabled
before_action
:user_map
,
only:
[
:new_user_map
,
:create_user_map
]
before_action
:user_map
,
only:
[
:new_user_map
,
:create_user_map
]
def
new
def
new
...
@@ -104,6 +105,10 @@ class Import::GoogleCodeController < Import::BaseController
...
@@ -104,6 +105,10 @@ class Import::GoogleCodeController < Import::BaseController
@client
||=
Gitlab
::
GoogleCodeImport
::
Client
.
new
(
session
[
:google_code_dump
])
@client
||=
Gitlab
::
GoogleCodeImport
::
Client
.
new
(
session
[
:google_code_dump
])
end
end
def
verify_google_code_import_enabled
not_found!
unless
google_code_import_enabled?
end
def
user_map
def
user_map
@user_map
||=
begin
@user_map
||=
begin
user_map
=
client
.
user_map
user_map
=
client
.
user_map
...
...
app/views/projects/_bitbucket_import_modal.html.haml
View file @
e238a8da
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
.modal-body
.modal-body
To enable importing projects from Bitbucket,
To enable importing projects from Bitbucket,
-
if
current_user
.
admin?
-
if
current_user
.
admin?
you need to
as administrator you need to configure
-
else
-
else
your GitLab administrator needs to
ask your GitLab administrator to configure
==
#{
link_to
'
setup OAuth integration'
,
'https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/integration/bitbucket.md'
}
.
==
#{
link_to
'
OAuth integration'
,
help_page_path
(
"integration"
,
"bitbucket"
)
}
.
app/views/projects/_github_import_modal.html.haml
View file @
e238a8da
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
.modal-body
.modal-body
To enable importing projects from GitHub,
To enable importing projects from GitHub,
-
if
current_user
.
admin?
-
if
current_user
.
admin?
you need to
as administrator you need to configure
-
else
-
else
your GitLab administrator needs to
ask your Gitlab administrator to configure
==
#{
link_to
'setup OAuth integration'
,
'https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/integration/github.md'
}
.
==
#{
link_to
'OAuth integration'
,
help_page_path
(
"integration"
,
"github"
)
}
.
\ No newline at end of file
app/views/projects/_gitlab_import_modal.html.haml
View file @
e238a8da
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
.modal-body
.modal-body
To enable importing projects from GitLab.com,
To enable importing projects from GitLab.com,
-
if
current_user
.
admin?
-
if
current_user
.
admin?
you need to
as administrator you need to configure
-
else
-
else
your GitLab administrator needs to
ask your GitLab administrator to configure
==
#{
link_to
'setup OAuth integration'
,
'https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/integration/gitlab.md'
}
.
==
#{
link_to
'OAuth integration'
,
help_page_path
(
"integration"
,
"gitlab"
)
}
.
\ No newline at end of file
app/views/projects/new.html.haml
View file @
e238a8da
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
.col-sm-10
.col-sm-10
=
f
.
select
:namespace_id
,
namespaces_options
(
params
[
:namespace_id
]
||
:current_user
),
{},
{
class:
'select2'
,
tabindex:
2
}
=
f
.
select
:namespace_id
,
namespaces_options
(
params
[
:namespace_id
]
||
:current_user
),
{},
{
class:
'select2'
,
tabindex:
2
}
-
if
import_sources_enabled?
%hr
%hr
.project-import.js-toggle-container
.project-import.js-toggle-container
...
@@ -29,46 +30,50 @@
...
@@ -29,46 +30,50 @@
%label
.control-label
Import project from
%label
.control-label
Import project from
.col-sm-10
.col-sm-10
-
if
github_import_enabled?
-
if
github_import_enabled?
=
link_to
status_import_github_path
,
class:
'btn'
do
-
if
github_import_configured?
=
link_to
status_import_github_path
,
class:
'btn import_github'
do
%i
.fa.fa-github
%i
.fa.fa-github
GitHub
GitHub
-
else
-
else
=
link_to
'#'
,
class:
'how_to_import_link light btn
'
do
=
link_to
'#'
,
class:
'how_to_import_link light btn import_github
'
do
%i
.fa.fa-github
%i
.fa.fa-github
GitHub
GitHub
=
render
'github_import_modal'
=
render
'github_import_modal'
-
if
bitbucket_import_enabled?
-
if
bitbucket_import_enabled?
=
link_to
status_import_bitbucket_path
,
class:
'btn'
,
"data-no-turbolink"
=>
"true"
do
-
if
bitbucket_import_configured?
=
link_to
status_import_bitbucket_path
,
class:
'btn import_bitbucket'
,
"data-no-turbolink"
=>
"true"
do
%i
.fa.fa-bitbucket
%i
.fa.fa-bitbucket
Bitbucket
Bitbucket
-
else
-
else
=
link_to
'#'
,
class:
'how_to_import_link light btn'
do
=
link_to
status_import_bitbucket_path
,
class:
'how_to_import_link light btn import_bitbucket'
,
"data-no-turbolink"
=>
"true"
do
%i
.fa.fa-bitbucket
%i
.fa.fa-bitbucket
Bitbucket
Bitbucket
=
render
'bitbucket_import_modal'
=
render
'bitbucket_import_modal'
-
unless
request
.
host
==
'gitlab.com'
-
if
gitlab_import_enabled?
-
if
gitlab_import_enabled?
=
link_to
status_import_gitlab_path
,
class:
'btn'
do
-
if
gitlab_import_configured?
=
link_to
status_import_gitlab_path
,
class:
'btn import_gitlab'
do
%i
.fa.fa-heart
%i
.fa.fa-heart
GitLab.com
GitLab.com
-
else
-
else
=
link_to
'#'
,
class:
'how_to_import_link light btn
'
do
=
link_to
status_import_gitlab_path
,
class:
'how_to_import_link light btn import_gitlab
'
do
%i
.fa.fa-heart
%i
.fa.fa-heart
GitLab.com
GitLab.com
=
render
'gitlab_import_modal'
=
render
'gitlab_import_modal'
=
link_to
new_import_gitorious_path
,
class:
'btn'
do
-
if
gitorious_import_enabled?
=
link_to
new_import_gitorious_path
,
class:
'btn import_gitorious'
do
%i
.icon-gitorious.icon-gitorious-small
%i
.icon-gitorious.icon-gitorious-small
Gitorious.org
Gitorious.org
=
link_to
new_import_google_code_path
,
class:
'btn'
do
-
if
google_code_import_enabled?
=
link_to
new_import_google_code_path
,
class:
'btn import_google_code'
do
%i
.fa.fa-google
%i
.fa.fa-google
Google Code
Google Code
=
link_to
"#"
,
class:
'btn js-toggle-button'
do
-
if
git_import_enabled?
=
link_to
"#"
,
class:
'btn js-toggle-button import_git'
do
%i
.fa.fa-git
%i
.fa.fa-git
%span
Any repo by URL
%span
Any repo by URL
...
...
features/dashboard/new_project.feature
View file @
e238a8da
...
@@ -4,10 +4,27 @@ Background:
...
@@ -4,10 +4,27 @@ Background:
Given
I sign in as a user
Given
I sign in as a user
And
I own project
"Shop"
And
I own project
"Shop"
And
I visit dashboard page
And
I visit dashboard page
And
I click
"New project"
link
@javascript
@javascript
Scenario
:
I
should see New projects page
Scenario
:
I
should see New projects page
Given
I click
"New project"
link
Then
I see
"New project"
page
Then
I see
"New project"
page
Then
I see all possible import optios
@javascript
Scenario
:
I
should see instructions on how to import from Git URL
Given
I see
"New project"
page
When
I click on
"Any repo by URL"
Then
I see instructions on how to import from Git URL
@javascript
Scenario
:
I
should see instructions on how to import from GitHub
Given
I see
"New project"
page
When
I click on
"Import project from GitHub"
When
I click on
"Import project from GitHub"
Then
I see instructions on how to import from GitHub
Then
I see instructions on how to import from GitHub
@javascript
Scenario
:
I
should see Google Code import page
Given
I see
"New project"
page
When
I click on
"Google Code"
Then
I redirected to Google Code import page
features/steps/dashboard/new_project.rb
View file @
e238a8da
...
@@ -13,8 +13,17 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps
...
@@ -13,8 +13,17 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps
expect
(
page
).
to
have_content
(
'Project path'
)
expect
(
page
).
to
have_content
(
'Project path'
)
end
end
step
'I see all possible import optios'
do
expect
(
page
).
to
have_link
(
'GitHub'
)
expect
(
page
).
to
have_link
(
'Bitbucket'
)
expect
(
page
).
to
have_link
(
'GitLab.com'
)
expect
(
page
).
to
have_link
(
'Gitorious.org'
)
expect
(
page
).
to
have_link
(
'Google Code'
)
expect
(
page
).
to
have_link
(
'Any repo by URL'
)
end
step
'I click on "Import project from GitHub"'
do
step
'I click on "Import project from GitHub"'
do
first
(
'.
how_to_import_link
'
).
click
first
(
'.
import_github
'
).
click
end
end
step
'I see instructions on how to import from GitHub'
do
step
'I see instructions on how to import from GitHub'
do
...
@@ -26,4 +35,24 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps
...
@@ -26,4 +35,24 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps
expect
(
element
).
not_to
be_visible
unless
element
==
github_modal
expect
(
element
).
not_to
be_visible
unless
element
==
github_modal
end
end
end
end
step
'I click on "Any repo by URL"'
do
first
(
'.import_git'
).
click
end
step
'I see instructions on how to import from Git URL'
do
git_import_instructions
=
first
(
'.js-toggle-content'
)
expect
(
git_import_instructions
).
to
be_visible
expect
(
git_import_instructions
).
to
have_content
"Git repository URL"
expect
(
git_import_instructions
).
to
have_content
"The repository must be accessible over HTTP(S). If it is not publicly accessible, you can add authentication information to the URL:"
end
step
'I click on "Google Code"'
do
first
(
'.import_google_code'
).
click
end
step
'I redirected to Google Code import page'
do
expect
(
current_path
).
to
eq
new_import_google_code_path
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment