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
Léo-Paul Géneau
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
"
#{
namespace
}
/
#{
name
}
"
end
def
github_project_link
(
path_with_namespace
)
link_to
path_with_namespace
,
github_project_url
(
path_with_namespace
),
target:
'_blank'
end
def
provider_project_link
(
provider
,
path_with_namespace
)
url
=
__send__
(
"
#{
provider
}
_project_url"
,
path_with_namespace
)
def
gitea_project_link
(
path_with_namespace
)
link_to
path_with_namespace
,
gitea_project_url
(
path_with_namespace
),
target:
'_blank'
link_to
path_with_namespace
,
url
,
target:
'_blank'
end
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 @@
=
custom_icon
(
'go_logo'
)
Import Projects from Gitea
%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 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}"
}
}
=
render
'import/githubish_status'
,
provider:
'gitea'
app/views/import/github/status.html.haml
View file @
20aff5cd
...
...
@@ -3,61 +3,4 @@
%h3
.page-title
=
icon
'github'
,
text:
'Import Projects from GitHub'
%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 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}"
}
}
=
render
'import/githubish_status'
,
provider:
'github'
spec/helpers/import_helper_spec.rb
View file @
20aff5cd
...
...
@@ -25,24 +25,37 @@ describe ImportHelper do
end
end
describe
'#github_project_link'
do
context
'when provider does not specify a custom URL'
do
it
'uses default GitHub URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
describe
'#provider_project_link'
do
context
'when provider is "github"'
do
context
'when provider does not specify a custom URL'
do
it
'uses default GitHub URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
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"'
)
end
end
end
context
'when provider specify a custom URL'
do
it
'uses custom URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
context
'when provider specify a custom URL'
do
it
'uses custom URL'
do
allow
(
Gitlab
.
config
.
omniauth
).
to
receive
(
:providers
).
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"'
)
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
...
...
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