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
Kazuhiko Shiozaki
gitlab-ce
Commits
87dd3f21
Commit
87dd3f21
authored
Apr 10, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let members be invited from Add members pane.
parent
717fa136
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
25 deletions
+72
-25
app/assets/javascripts/users_select.js.coffee
app/assets/javascripts/users_select.js.coffee
+24
-14
app/controllers/projects/project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+1
-2
app/helpers/selects_helper.rb
app/helpers/selects_helper.rb
+2
-0
app/models/group.rb
app/models/group.rb
+17
-3
app/models/members/project_member.rb
app/models/members/project_member.rb
+19
-3
app/views/admin/groups/show.html.haml
app/views/admin/groups/show.html.haml
+1
-1
app/views/groups/group_members/_new_group_member.html.haml
app/views/groups/group_members/_new_group_member.html.haml
+4
-1
app/views/projects/project_members/_new_project_member.html.haml
...ws/projects/project_members/_new_project_member.html.haml
+4
-1
No files found.
app/assets/javascripts/users_select.js.coffee
View file @
87dd3f21
...
...
@@ -8,6 +8,7 @@ class @UsersSelect
@
groupId
=
$
(
select
).
data
(
'group-id'
)
showNullUser
=
$
(
select
).
data
(
'null-user'
)
showAnyUser
=
$
(
select
).
data
(
'any-user'
)
showEmailUser
=
$
(
select
).
data
(
'email-user'
)
firstUser
=
$
(
select
).
data
(
'first-user'
)
$
(
select
).
select2
...
...
@@ -19,20 +20,6 @@ class @UsersSelect
data
=
{
results
:
users
}
if
query
.
term
.
length
==
0
anyUser
=
{
name
:
'Any'
,
avatar
:
null
,
username
:
'none'
,
id
:
null
}
nullUser
=
{
name
:
'Unassigned'
,
avatar
:
null
,
username
:
'none'
,
id
:
0
}
if
firstUser
# Move current user to the front of the list
for
obj
,
index
in
data
.
results
...
...
@@ -40,11 +27,34 @@ class @UsersSelect
data
.
results
.
splice
(
index
,
1
)
data
.
results
.
unshift
(
obj
)
break
if
showNullUser
nullUser
=
{
name
:
'Unassigned'
,
avatar
:
null
,
username
:
'none'
,
id
:
0
}
data
.
results
.
unshift
(
nullUser
)
if
showAnyUser
anyUser
=
{
name
:
'Any'
,
avatar
:
null
,
username
:
'none'
,
id
:
null
}
data
.
results
.
unshift
(
anyUser
)
if
showEmailUser
&&
data
.
results
.
length
==
0
&&
query
.
term
.
match
(
/^[^@]+@[^@]+$/
)
emailUser
=
{
name
:
"Invite
\"
#{
query
.
term
}
\"
"
,
avatar
:
null
,
username
:
query
.
term
,
id
:
query
.
term
}
data
.
results
.
unshift
(
emailUser
)
query
.
callback
(
data
)
initSelection
:
(
element
,
callback
)
=>
...
...
app/controllers/projects/project_members_controller.rb
View file @
87dd3f21
...
...
@@ -36,8 +36,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
end
def
create
users
=
User
.
where
(
id:
params
[
:user_ids
].
split
(
','
))
@project
.
team
<<
[
users
,
params
[
:access_level
]]
@project
.
team
.
add_users
(
params
[
:user_ids
].
split
(
','
),
params
[
:access_level
],
current_user
)
redirect_to
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
end
...
...
app/helpers/selects_helper.rb
View file @
87dd3f21
...
...
@@ -8,6 +8,7 @@ module SelectsHelper
null_user
=
opts
[
:null_user
]
||
false
any_user
=
opts
[
:any_user
]
||
false
email_user
=
opts
[
:email_user
]
||
false
first_user
=
opts
[
:first_user
]
&&
current_user
?
current_user
.
username
:
false
html
=
{
...
...
@@ -15,6 +16,7 @@ module SelectsHelper
'data-placeholder'
=>
placeholder
,
'data-null-user'
=>
null_user
,
'data-any-user'
=>
any_user
,
'data-email-user'
=>
email_user
,
'data-first-user'
=>
first_user
}
...
...
app/models/group.rb
View file @
87dd3f21
...
...
@@ -47,10 +47,24 @@ class Group < Namespace
end
def
add_users
(
user_ids
,
access_level
,
current_user
=
nil
)
user_ids
.
compact
.
each
do
|
user_id
|
member
=
self
.
group_members
.
find_or_initialize_by
(
user_id:
user_id
)
member
.
access_level
=
access_level
users
=
user_ids
.
map
do
|
user_id
|
(
user_id
if
user_id
.
is_a?
(
User
))
||
User
.
find_by
(
id:
user_id
)
||
User
.
find_by
(
email:
user_id
)
||
user_id
end
users
.
compact
.
each
do
|
user
|
if
user
.
is_a?
(
User
)
member
=
self
.
group_members
.
find_or_initialize_by
(
user_id:
user
.
id
)
else
member
=
self
.
group_members
.
build
member
.
invite_email
=
user
end
member
.
created_by
||=
current_user
member
.
access_level
=
access_level
member
.
save
end
end
...
...
app/models/members/project_member.rb
View file @
87dd3f21
...
...
@@ -60,12 +60,28 @@ class ProjectMember < Member
raise
"Non valid access"
end
users
=
user_ids
.
map
do
|
user_id
|
(
user_id
if
user_id
.
is_a?
(
User
))
||
User
.
find_by
(
id:
user_id
)
||
User
.
find_by
(
email:
user_id
)
||
user_id
end
ProjectMember
.
transaction
do
project_ids
.
each
do
|
project_id
|
user_ids
.
each
do
|
user_id
|
member
=
ProjectMember
.
new
(
access_level:
access_level
,
user_id:
user_id
)
member
.
source_id
=
project_id
project
=
Project
.
find
(
project_id
)
users
.
each
do
|
user
|
if
user
.
is_a?
(
User
)
member
=
project
.
project_members
.
find_or_initialize_by
(
user_id:
user
.
id
)
else
member
=
project
.
project_members
.
build
member
.
invite_email
=
user
end
member
.
created_by
||=
current_user
member
.
access_level
=
access_level
member
.
save
end
end
...
...
app/views/admin/groups/show.html.haml
View file @
87dd3f21
...
...
@@ -60,7 +60,7 @@
=
form_tag
members_update_admin_group_path
(
@group
),
id:
"new_project_member"
,
class:
"bulk_import"
,
method: :put
do
%div
=
users_select_tag
(
:user_ids
,
multiple:
true
)
=
users_select_tag
(
:user_ids
,
multiple:
true
,
email_user:
true
)
%div
.prepend-top-10
=
select_tag
:access_level
,
options_for_select
(
GroupMember
.
access_level_roles
),
class:
"project-access-select select2"
%hr
...
...
app/views/groups/group_members/_new_group_member.html.haml
View file @
87dd3f21
=
form_for
@group_member
,
url:
group_group_members_path
(
@group
),
html:
{
class:
'form-horizontal users-group-form'
}
do
|
f
|
.form-group
=
f
.
label
:user_ids
,
"People"
,
class:
'control-label'
.col-sm-10
=
users_select_tag
(
:user_ids
,
multiple:
true
,
class:
'input-large'
,
scope: :all
)
.col-sm-10
=
users_select_tag
(
:user_ids
,
multiple:
true
,
class:
'input-large'
,
scope: :all
,
email_user:
true
)
.help-block
Search for existing users or invite new ones using their email address.
.form-group
=
f
.
label
:access_level
,
"Group Access"
,
class:
'control-label'
...
...
app/views/projects/project_members/_new_project_member.html.haml
View file @
87dd3f21
=
form_for
@project_member
,
as: :project_member
,
url:
namespace_project_project_members_path
(
@project
.
namespace
,
@project
),
html:
{
class:
'form-horizontal users-project-form'
}
do
|
f
|
.form-group
=
f
.
label
:user_ids
,
"People"
,
class:
'control-label'
.col-sm-10
=
users_select_tag
(
:user_ids
,
multiple:
true
,
class:
'input-large'
,
scope: :all
)
.col-sm-10
=
users_select_tag
(
:user_ids
,
multiple:
true
,
class:
'input-large'
,
scope: :all
,
email_user:
true
)
.help-block
Search for existing users or invite new ones using their email address.
.form-group
=
f
.
label
:access_level
,
"Project Access"
,
class:
'control-label'
...
...
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