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
a30257c0
Commit
a30257c0
authored
Aug 15, 2017
by
Rubén Dávila
Committed by
Mike Greiling
Aug 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some data attributes for options in namespace selector
parent
2be34630
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
17 deletions
+18
-17
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+18
-17
No files found.
app/helpers/namespaces_helper.rb
View file @
a30257c0
...
@@ -5,6 +5,8 @@ module NamespacesHelper
...
@@ -5,6 +5,8 @@ module NamespacesHelper
def
namespaces_options
(
selected
=
:current_user
,
display_path:
false
,
extra_group:
nil
)
def
namespaces_options
(
selected
=
:current_user
,
display_path:
false
,
extra_group:
nil
)
groups
=
current_user
.
owned_groups
+
current_user
.
masters_groups
groups
=
current_user
.
owned_groups
+
current_user
.
masters_groups
users
=
[
current_user
.
namespace
]
options
=
[]
unless
extra_group
.
nil?
||
extra_group
.
is_a?
(
Group
)
unless
extra_group
.
nil?
||
extra_group
.
is_a?
(
Group
)
extra_group
=
Group
.
find
(
extra_group
)
if
Namespace
.
find
(
extra_group
).
kind
==
'group'
extra_group
=
Group
.
find
(
extra_group
)
if
Namespace
.
find
(
extra_group
).
kind
==
'group'
...
@@ -14,22 +16,8 @@ module NamespacesHelper
...
@@ -14,22 +16,8 @@ module NamespacesHelper
groups
|=
[
extra_group
]
groups
|=
[
extra_group
]
end
end
users
=
[
current_user
.
namespace
]
options
<<
options_for_group
(
groups
,
display_path
)
options
<<
options_for_group
(
users
,
display_path
)
data_attr_group
=
{
'data-options-parent'
=>
'groups'
}
data_attr_users
=
{
'data-options-parent'
=>
'users'
}
group_opts
=
[
"Groups"
,
groups
.
sort_by
(
&
:human_name
).
map
{
|
g
|
[
display_path
?
g
.
full_path
:
g
.
human_name
,
g
.
id
,
data_attr_group
]
}
]
users_opts
=
[
"Users"
,
users
.
sort_by
(
&
:human_name
).
map
{
|
u
|
[
display_path
?
u
.
path
:
u
.
human_name
,
u
.
id
,
data_attr_users
]
}
]
options
=
[]
options
<<
group_opts
options
<<
users_opts
if
selected
==
:current_user
&&
current_user
.
namespace
if
selected
==
:current_user
&&
current_user
.
namespace
selected
=
current_user
.
namespace
.
id
selected
=
current_user
.
namespace
.
id
...
@@ -45,4 +33,17 @@ module NamespacesHelper
...
@@ -45,4 +33,17 @@ module NamespacesHelper
avatar_icon
(
namespace
.
owner
.
email
,
size
)
avatar_icon
(
namespace
.
owner
.
email
,
size
)
end
end
end
end
private
def
options_for_group
(
namespaces
,
display_path
)
type
=
namespaces
.
first
.
is_a?
(
Group
)
?
'group'
:
'users'
elements
=
namespaces
.
sort_by
(
&
:human_name
).
map!
do
|
n
|
[
display_path
?
n
.
full_path
:
n
.
human_name
,
n
.
id
,
data:
{
options_parent:
type
,
visibility_level:
n
.
visibility_level_value
,
name:
n
.
human_name
}]
end
[
type
.
camelize
,
elements
]
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