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
1528df0f
Commit
1528df0f
authored
Jul 31, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default to importing to the current project key
parent
852b5613
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+9
-4
app/views/import/bitbucket_server/status.html.haml
app/views/import/bitbucket_server/status.html.haml
+1
-1
spec/helpers/namespaces_helper_spec.rb
spec/helpers/namespaces_helper_spec.rb
+19
-0
No files found.
app/helpers/namespaces_helper.rb
View file @
1528df0f
...
...
@@ -9,6 +9,7 @@ module NamespacesHelper
.
includes
(
:route
)
.
order
(
'routes.path'
)
users
=
[
current_user
.
namespace
]
selected_option
=
nil
unless
extra_group
.
nil?
||
extra_group
.
is_a?
(
Group
)
extra_group
=
Group
.
find
(
extra_group
)
if
Namespace
.
find
(
extra_group
).
kind
==
'group'
...
...
@@ -18,7 +19,11 @@ module NamespacesHelper
# Avoid duplicate groups if one already exists by that name
existing_group
=
Group
.
find_by
(
name:
extra_group
.
name
)
extra_group
=
existing_group
if
existing_group
groups
|=
[
extra_group
]
if
Ability
.
allowed?
(
current_user
,
:read_group
,
extra_group
)
if
Ability
.
allowed?
(
current_user
,
:read_group
,
extra_group
)
groups
|=
[
extra_group
]
selected_option
=
extra_group
.
id
if
selected
==
:extra_group
end
end
options
=
[]
...
...
@@ -27,12 +32,12 @@ module NamespacesHelper
unless
groups_only
options
<<
options_for_group
(
users
,
display_path:
display_path
,
type:
'user'
)
if
selected
==
:current_user
&&
current_user
.
namespace
selected
=
current_user
.
namespace
.
id
if
(
selected
==
:current_user
||
selected_option
.
nil?
)
&&
current_user
.
namespace
selected
_option
=
current_user
.
namespace
.
id
end
end
grouped_options_for_select
(
options
,
selected
)
grouped_options_for_select
(
options
,
selected
_option
)
end
def
namespace_icon
(
namespace
,
size
=
40
)
...
...
app/views/import/bitbucket_server/status.html.haml
View file @
1528df0f
...
...
@@ -58,7 +58,7 @@
.input-group
.project-path.input-group-prepend
-
if
current_user
.
can_select_namespace?
-
selected
=
params
[
:namespace_id
]
||
:
current_user
-
selected
=
params
[
:namespace_id
]
||
:
extra_group
-
opts
=
current_user
.
can_create_group?
?
{
extra_group:
Group
.
new
(
name:
repo
.
project_key
,
path:
repo
.
project_key
)
}
:
{}
=
select_tag
:namespace_id
,
namespaces_options
(
selected
,
opts
.
merge
({
display_path:
true
})),
{
class:
'input-group-text select2 js-select-namespace'
,
tabindex:
1
}
-
else
...
...
spec/helpers/namespaces_helper_spec.rb
View file @
1528df0f
...
...
@@ -40,6 +40,25 @@ describe NamespacesHelper do
expect
(
options
).
to
include
(
admin_group
.
name
)
end
it
'selects extra_group'
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
admin
)
options
=
helper
.
namespaces_options
(
:extra_group
,
display_path:
true
,
extra_group:
user_group
)
expect
(
options
).
to
include
(
"selected=
\"
selected
\"
value=
\"
#{
user_group
.
id
}
\"
"
)
expect
(
options
).
to
include
(
admin_group
.
name
)
end
it
'falls back to current user selection'
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
options
=
helper
.
namespaces_options
(
:extra_group
,
display_path:
true
,
extra_group:
build
(
:group
,
name:
admin_group
.
name
))
expect
(
options
).
to
include
(
user_group
.
name
)
expect
(
options
).
not_to
include
(
admin_group
.
name
)
expect
(
options
).
to
include
(
"selected=
\"
selected
\"
value=
\"
#{
user
.
namespace
.
id
}
\"
"
)
end
it
'returns only groups if groups_only option is true'
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
...
...
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