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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
20aff5cd
Commit
20aff5cd
authored
Dec 16, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce duplication for GitHubish import status view
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
8fc63d1f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
131 deletions
+89
-131
app/helpers/import_helper.rb
app/helpers/import_helper.rb
+3
-5
app/views/import/_githubish_status.html.haml
app/views/import/_githubish_status.html.haml
+61
-0
app/views/import/gitea/status.html.haml
app/views/import/gitea/status.html.haml
+1
-58
app/views/import/github/status.html.haml
app/views/import/github/status.html.haml
+1
-58
spec/helpers/import_helper_spec.rb
spec/helpers/import_helper_spec.rb
+23
-10
No files found.
app/helpers/import_helper.rb
View file @
20aff5cd
...
@@ -4,12 +4,10 @@ module ImportHelper
...
@@ -4,12 +4,10 @@ module ImportHelper
"
#{
namespace
}
/
#{
name
}
"
"
#{
namespace
}
/
#{
name
}
"
end
end
def
github_project_link
(
path_with_namespace
)
def
provider_project_link
(
provider
,
path_with_namespace
)
link_to
path_with_namespace
,
github_project_url
(
path_with_namespace
),
target:
'_blank'
url
=
__send__
(
"
#{
provider
}
_project_url"
,
path_with_namespace
)
end
def
gitea_project_link
(
path_with_namespace
)
link_to
path_with_namespace
,
url
,
target:
'_blank'
link_to
path_with_namespace
,
gitea_project_url
(
path_with_namespace
),
target:
'_blank'
end
end
private
private
...
...
app/views/import/_githubish_status.html.haml
0 → 100644
View file @
20aff5cd
-
provider
=
local_assigns
.
fetch
(
:provider
)
-
provider_title
=
Gitlab
::
ImportSources
.
title
(
provider
)
%p
.light
Select projects you want to import.
%hr
%p
=
button_tag
class:
"btn btn-import btn-success js-import-all"
do
Import all projects
=
icon
(
"spinner spin"
,
class:
"loading-icon"
)
.table-responsive
%table
.table.import-jobs
%colgroup
.import-jobs-from-col
%colgroup
.import-jobs-to-col
%colgroup
.import-jobs-status-col
%thead
%tr
%th
=
"From
#{
provider_title
}
"
%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
=
provider_project_link
(
provider
,
project
.
import_source
)
%td
=
link_to
project
.
path_with_namespace
,
[
project
.
namespace
.
becomes
(
Namespace
),
project
]
%td
.job-status
-
if
project
.
import_status
==
'finished'
%span
%i
.fa.fa-check
done
-
elsif
project
.
import_status
==
'started'
%i
.fa.fa-spinner.fa-spin
started
-
else
=
project
.
human_import_status_name
-
@repos
.
each
do
|
repo
|
%tr
{
id:
"repo_#{repo.id}"
}
%td
=
provider_project_link
(
provider
,
repo
.
full_name
)
%td
.import-target
%fieldset
.row
.input-group
.project-path.input-group-btn
-
if
current_user
.
can_select_namespace?
-
selected
=
params
[
:namespace_id
]
||
:current_user
-
opts
=
current_user
.
can_create_group?
?
{
extra_group:
Group
.
new
(
name:
repo
.
owner
.
login
,
path:
repo
.
owner
.
login
)
}
:
{}
=
select_tag
:namespace_id
,
namespaces_options
(
selected
,
opts
.
merge
({
display_path:
true
})),
{
class:
'select2 js-select-namespace'
,
tabindex:
1
}
-
else
=
text_field_tag
:path
,
current_user
.
namespace_path
,
class:
"input-large form-control"
,
tabindex:
1
,
disabled:
true
%span
.input-group-addon
/
=
text_field_tag
:path
,
repo
.
name
,
class:
"input-mini form-control"
,
tabindex:
2
,
autofocus:
true
,
required:
true
%td
.import-actions.job-status
=
button_tag
class:
"btn btn-import js-add-to-import"
do
Import
=
icon
(
"spinner spin"
,
class:
"loading-icon"
)
.js-importer-status
{
data:
{
jobs_import_path:
"#{url_for([:jobs, :import, provider])}"
,
import_path:
"#{url_for([:import, provider])}"
}
}
app/views/import/gitea/status.html.haml
View file @
20aff5cd
...
@@ -4,61 +4,4 @@
...
@@ -4,61 +4,4 @@
=
custom_icon
(
'go_logo'
)
=
custom_icon
(
'go_logo'
)
Import Projects from Gitea
Import Projects from Gitea
%p
.light
=
render
'import/githubish_status'
,
provider:
'gitea'
Select projects you want to import.
%hr
%p
=
button_tag
class:
"btn btn-import btn-success js-import-all"
do
Import all projects
=
icon
(
"spinner spin"
,
class:
"loading-icon"
)
.table-responsive
%table
.table.import-jobs
%colgroup
.import-jobs-from-col
%colgroup
.import-jobs-to-col
%colgroup
.import-jobs-status-col
%thead
%tr
%th
From Gitea
%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
=
gitea_project_link
(
project
.
import_source
)
%td
=
link_to
project
.
path_with_namespace
,
[
project
.
namespace
.
becomes
(
Namespace
),
project
]
%td
.job-status
-
if
project
.
import_status
==
'finished'
%span
%i
.fa.fa-check
done
-
elsif
project
.
import_status
==
'started'
%i
.fa.fa-spinner.fa-spin
started
-
else
=
project
.
human_import_status_name
-
@repos
.
each
do
|
repo
|
%tr
{
id:
"repo_#{repo.id}"
}
%td
=
gitea_project_link
(
repo
.
full_name
)
%td
.import-target
%fieldset
.row
.input-group
.project-path.input-group-btn
-
if
current_user
.
can_select_namespace?
-
selected
=
params
[
:namespace_id
]
||
:current_user
-
opts
=
current_user
.
can_create_group?
?
{
extra_group:
Group
.
new
(
name:
repo
.
owner
.
login
,
path:
repo
.
owner
.
login
)
}
:
{}
=
select_tag
:namespace_id
,
namespaces_options
(
selected
,
opts
.
merge
({
display_path:
true
})),
{
class:
'select2 js-select-namespace'
,
tabindex:
1
}
-
else
=
text_field_tag
:path
,
current_user
.
namespace_path
,
class:
"input-large form-control"
,
tabindex:
1
,
disabled:
true
%span
.input-group-addon
/
=
text_field_tag
:path
,
repo
.
name
,
class:
"input-mini form-control"
,
tabindex:
2
,
autofocus:
true
,
required:
true
%td
.import-actions.job-status
=
button_tag
class:
"btn btn-import js-add-to-import"
do
Import
=
icon
(
"spinner spin"
,
class:
"loading-icon"
)
.js-importer-status
{
data:
{
jobs_import_path:
"#{jobs_import_gitea_path}"
,
import_path:
"#{import_gitea_path}"
}
}
app/views/import/github/status.html.haml
View file @
20aff5cd
...
@@ -3,61 +3,4 @@
...
@@ -3,61 +3,4 @@
%h3
.page-title
%h3
.page-title
=
icon
'github'
,
text:
'Import Projects from GitHub'
=
icon
'github'
,
text:
'Import Projects from GitHub'
%p
.light
=
render
'import/githubish_status'
,
provider:
'github'
Select projects you want to import.
%hr
%p
=
button_tag
class:
"btn btn-import btn-success js-import-all"
do
Import all projects
=
icon
(
"spinner spin"
,
class:
"loading-icon"
)
.table-responsive
%table
.table.import-jobs
%colgroup
.import-jobs-from-col
%colgroup
.import-jobs-to-col
%colgroup
.import-jobs-status-col
%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
=
github_project_link
(
project
.
import_source
)
%td
=
link_to
project
.
path_with_namespace
,
[
project
.
namespace
.
becomes
(
Namespace
),
project
]
%td
.job-status
-
if
project
.
import_status
==
'finished'
%span
%i
.fa.fa-check
done
-
elsif
project
.
import_status
==
'started'
%i
.fa.fa-spinner.fa-spin
started
-
else
=
project
.
human_import_status_name
-
@repos
.
each
do
|
repo
|
%tr
{
id:
"repo_#{repo.id}"
}
%td
=
github_project_link
(
repo
.
full_name
)
%td
.import-target
%fieldset
.row
.input-group
.project-path.input-group-btn
-
if
current_user
.
can_select_namespace?
-
selected
=
params
[
:namespace_id
]
||
:current_user
-
opts
=
current_user
.
can_create_group?
?
{
extra_group:
Group
.
new
(
name:
repo
.
owner
.
login
,
path:
repo
.
owner
.
login
)
}
:
{}
=
select_tag
:namespace_id
,
namespaces_options
(
selected
,
opts
.
merge
({
display_path:
true
})),
{
class:
'select2 js-select-namespace'
,
tabindex:
1
}
-
else
=
text_field_tag
:path
,
current_user
.
namespace_path
,
class:
"input-large form-control"
,
tabindex:
1
,
disabled:
true
%span
.input-group-addon
/
=
text_field_tag
:path
,
repo
.
name
,
class:
"input-mini form-control"
,
tabindex:
2
,
autofocus:
true
,
required:
true
%td
.import-actions.job-status
=
button_tag
class:
"btn btn-import js-add-to-import"
do
Import
=
icon
(
"spinner spin"
,
class:
"loading-icon"
)
.js-importer-status
{
data:
{
jobs_import_path:
"#{jobs_import_github_path}"
,
import_path:
"#{import_github_path}"
}
}
spec/helpers/import_helper_spec.rb
View file @
20aff5cd
...
@@ -25,24 +25,37 @@ describe ImportHelper do
...
@@ -25,24 +25,37 @@ describe ImportHelper do
end
end
end
end
describe
'#github_project_link'
do
describe
'#provider_project_link'
do
context
'when provider does not specify a custom URL'
do
context
'when provider is "github"'
do
it
'uses default GitHub URL'
do
context
'when provider does not specify a custom URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
it
'uses default GitHub URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
and_return
([
Settingslogic
.
new
(
'name'
=>
'github'
)])
and_return
([
Settingslogic
.
new
(
'name'
=>
'github'
)])
expect
(
helper
.
github_project_link
(
'octocat/Hello-World'
)).
expect
(
helper
.
provider_project_link
(
'github'
,
'octocat/Hello-World'
)).
to
include
(
'href="https://github.com/octocat/Hello-World"'
)
to
include
(
'href="https://github.com/octocat/Hello-World"'
)
end
end
end
end
context
'when provider specify a custom URL'
do
context
'when provider specify a custom URL'
do
it
'uses custom URL'
do
it
'uses custom URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
and_return
([
Settingslogic
.
new
(
'name'
=>
'github'
,
'url'
=>
'https://github.company.com'
)])
and_return
([
Settingslogic
.
new
(
'name'
=>
'github'
,
'url'
=>
'https://github.company.com'
)])
expect
(
helper
.
github_project_link
(
'octocat/Hello-World'
)).
expect
(
helper
.
provider_project_link
(
'github'
,
'octocat/Hello-World'
)).
to
include
(
'href="https://github.company.com/octocat/Hello-World"'
)
to
include
(
'href="https://github.company.com/octocat/Hello-World"'
)
end
end
end
context
'when provider is "gitea"'
do
before
do
assign
(
:gitea_host_url
,
'https://try.gitea.io/'
)
end
it
'uses given host'
do
expect
(
helper
.
provider_project_link
(
'gitea'
,
'octocat/Hello-World'
)).
to
include
(
'href="https://try.gitea.io/octocat/Hello-World"'
)
end
end
end
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