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
Boxiang Sun
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
Hide 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
...
@@ -8,6 +8,7 @@ class @UsersSelect
@
groupId
=
$
(
select
).
data
(
'group-id'
)
@
groupId
=
$
(
select
).
data
(
'group-id'
)
showNullUser
=
$
(
select
).
data
(
'null-user'
)
showNullUser
=
$
(
select
).
data
(
'null-user'
)
showAnyUser
=
$
(
select
).
data
(
'any-user'
)
showAnyUser
=
$
(
select
).
data
(
'any-user'
)
showEmailUser
=
$
(
select
).
data
(
'email-user'
)
firstUser
=
$
(
select
).
data
(
'first-user'
)
firstUser
=
$
(
select
).
data
(
'first-user'
)
$
(
select
).
select2
$
(
select
).
select2
...
@@ -19,20 +20,6 @@ class @UsersSelect
...
@@ -19,20 +20,6 @@ class @UsersSelect
data
=
{
results
:
users
}
data
=
{
results
:
users
}
if
query
.
term
.
length
==
0
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
if
firstUser
# Move current user to the front of the list
# Move current user to the front of the list
for
obj
,
index
in
data
.
results
for
obj
,
index
in
data
.
results
...
@@ -40,11 +27,34 @@ class @UsersSelect
...
@@ -40,11 +27,34 @@ class @UsersSelect
data
.
results
.
splice
(
index
,
1
)
data
.
results
.
splice
(
index
,
1
)
data
.
results
.
unshift
(
obj
)
data
.
results
.
unshift
(
obj
)
break
break
if
showNullUser
if
showNullUser
nullUser
=
{
name
:
'Unassigned'
,
avatar
:
null
,
username
:
'none'
,
id
:
0
}
data
.
results
.
unshift
(
nullUser
)
data
.
results
.
unshift
(
nullUser
)
if
showAnyUser
if
showAnyUser
anyUser
=
{
name
:
'Any'
,
avatar
:
null
,
username
:
'none'
,
id
:
null
}
data
.
results
.
unshift
(
anyUser
)
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
)
query
.
callback
(
data
)
initSelection
:
(
element
,
callback
)
=>
initSelection
:
(
element
,
callback
)
=>
...
...
app/controllers/projects/project_members_controller.rb
View file @
87dd3f21
...
@@ -36,8 +36,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
...
@@ -36,8 +36,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
end
end
def
create
def
create
users
=
User
.
where
(
id:
params
[
:user_ids
].
split
(
','
))
@project
.
team
.
add_users
(
params
[
:user_ids
].
split
(
','
),
params
[
:access_level
],
current_user
)
@project
.
team
<<
[
users
,
params
[
:access_level
]]
redirect_to
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
redirect_to
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
end
end
...
...
app/helpers/selects_helper.rb
View file @
87dd3f21
...
@@ -8,6 +8,7 @@ module SelectsHelper
...
@@ -8,6 +8,7 @@ module SelectsHelper
null_user
=
opts
[
:null_user
]
||
false
null_user
=
opts
[
:null_user
]
||
false
any_user
=
opts
[
:any_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
first_user
=
opts
[
:first_user
]
&&
current_user
?
current_user
.
username
:
false
html
=
{
html
=
{
...
@@ -15,6 +16,7 @@ module SelectsHelper
...
@@ -15,6 +16,7 @@ module SelectsHelper
'data-placeholder'
=>
placeholder
,
'data-placeholder'
=>
placeholder
,
'data-null-user'
=>
null_user
,
'data-null-user'
=>
null_user
,
'data-any-user'
=>
any_user
,
'data-any-user'
=>
any_user
,
'data-email-user'
=>
email_user
,
'data-first-user'
=>
first_user
'data-first-user'
=>
first_user
}
}
...
...
app/models/group.rb
View file @
87dd3f21
...
@@ -47,10 +47,24 @@ class Group < Namespace
...
@@ -47,10 +47,24 @@ class Group < Namespace
end
end
def
add_users
(
user_ids
,
access_level
,
current_user
=
nil
)
def
add_users
(
user_ids
,
access_level
,
current_user
=
nil
)
user_ids
.
compact
.
each
do
|
user_id
|
users
=
user_ids
.
map
do
|
user_id
|
member
=
self
.
group_members
.
find_or_initialize_by
(
user_id:
user_id
)
(
user_id
if
user_id
.
is_a?
(
User
))
||
member
.
access_level
=
access_level
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
.
created_by
||=
current_user
member
.
access_level
=
access_level
member
.
save
member
.
save
end
end
end
end
...
...
app/models/members/project_member.rb
View file @
87dd3f21
...
@@ -60,12 +60,28 @@ class ProjectMember < Member
...
@@ -60,12 +60,28 @@ class ProjectMember < Member
raise
"Non valid access"
raise
"Non valid access"
end
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
ProjectMember
.
transaction
do
project_ids
.
each
do
|
project_id
|
project_ids
.
each
do
|
project_id
|
user_ids
.
each
do
|
user_id
|
project
=
Project
.
find
(
project_id
)
member
=
ProjectMember
.
new
(
access_level:
access_level
,
user_id:
user_id
)
member
.
source_id
=
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
.
created_by
||=
current_user
member
.
access_level
=
access_level
member
.
save
member
.
save
end
end
end
end
...
...
app/views/admin/groups/show.html.haml
View file @
87dd3f21
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
=
form_tag
members_update_admin_group_path
(
@group
),
id:
"new_project_member"
,
class:
"bulk_import"
,
method: :put
do
=
form_tag
members_update_admin_group_path
(
@group
),
id:
"new_project_member"
,
class:
"bulk_import"
,
method: :put
do
%div
%div
=
users_select_tag
(
:user_ids
,
multiple:
true
)
=
users_select_tag
(
:user_ids
,
multiple:
true
,
email_user:
true
)
%div
.prepend-top-10
%div
.prepend-top-10
=
select_tag
:access_level
,
options_for_select
(
GroupMember
.
access_level_roles
),
class:
"project-access-select select2"
=
select_tag
:access_level
,
options_for_select
(
GroupMember
.
access_level_roles
),
class:
"project-access-select select2"
%hr
%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_for
@group_member
,
url:
group_group_members_path
(
@group
),
html:
{
class:
'form-horizontal users-group-form'
}
do
|
f
|
.form-group
.form-group
=
f
.
label
:user_ids
,
"People"
,
class:
'control-label'
=
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
.form-group
=
f
.
label
:access_level
,
"Group Access"
,
class:
'control-label'
=
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_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
.form-group
=
f
.
label
:user_ids
,
"People"
,
class:
'control-label'
=
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
.form-group
=
f
.
label
:access_level
,
"Project Access"
,
class:
'control-label'
=
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