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
2b41db92
Commit
2b41db92
authored
Sep 06, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search project groups
parent
73c4da17
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
8 deletions
+61
-8
app/controllers/projects/project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+41
-8
spec/features/projects/members/group_links_spec.rb
spec/features/projects/members/group_links_spec.rb
+20
-0
No files found.
app/controllers/projects/project_members_controller.rb
View file @
2b41db92
...
@@ -10,23 +10,30 @@ class Projects::ProjectMembersController < Projects::ApplicationController
...
@@ -10,23 +10,30 @@ class Projects::ProjectMembersController < Projects::ApplicationController
project_members
=
@project
.
project_members
project_members
=
@project
.
project_members
project_members
=
project_members
.
non_invite
unless
can?
(
current_user
,
:admin_project
,
@project
)
project_members
=
project_members
.
non_invite
unless
can?
(
current_user
,
:admin_project
,
@project
)
if
params
[
:search
].
present?
users
=
@project
.
users
.
search
(
params
[
:search
]).
to_a
project_members
=
project_members
.
where
(
user_id:
users
)
end
members_ids
=
project_members
.
pluck
(
:id
)
group
=
@project
.
group
group
=
@project
.
group
if
group
if
group
group_members
=
group
.
group_members
group_members
=
group
.
group_members
group_members
=
group_members
.
non_invite
unless
can?
(
current_user
,
:admin_project
,
@project
)
group_members
=
group_members
.
non_invite
unless
can?
(
current_user
,
:admin_project
,
@project
)
end
if
params
[
:search
].
present?
if
params
[
:search
].
present?
groups_id
=
@groups
.
pluck
(
:group_id
)
groups
=
Group
.
where
(
id:
groups_id
).
search
(
params
[
:search
]).
to_a
@groups
=
@project
.
project_group_links
.
where
(
group_id:
groups
)
users
=
@project
.
users
.
search
(
params
[
:search
]).
to_a
project_members
=
project_members
.
where
(
user_id:
users
)
if
group_members
users
=
group
.
users
.
search
(
params
[
:search
]).
to_a
users
=
group
.
users
.
search
(
params
[
:search
]).
to_a
group_members
=
group_members
.
where
(
user_id:
users
)
group_members
=
group_members
.
where
(
user_id:
users
)
end
end
end
members_ids
=
project_members
.
pluck
(
:id
)
if
group_members
members_ids
<<
group_members
.
pluck
(
:id
)
members_ids
<<
group_members
.
pluck
(
:id
)
end
end
...
@@ -48,6 +55,17 @@ class Projects::ProjectMembersController < Projects::ApplicationController
...
@@ -48,6 +55,17 @@ class Projects::ProjectMembersController < Projects::ApplicationController
current_user:
current_user
current_user:
current_user
)
)
group_ids
=
params
[
:group_ids
].
split
(
','
)
groups
=
Group
.
where
(
id:
group_ids
)
groups
.
each
do
|
group
|
project
.
project_group_links
.
create
(
group:
group
,
group_access:
params
[
:access_level
],
expires_at:
params
[
:expires_at
]
)
end
redirect_to
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
redirect_to
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
end
end
...
@@ -101,6 +119,21 @@ class Projects::ProjectMembersController < Projects::ApplicationController
...
@@ -101,6 +119,21 @@ class Projects::ProjectMembersController < Projects::ApplicationController
notice:
notice
)
notice:
notice
)
end
end
def
options
users
=
User
.
all
users
=
users
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
users
=
users
.
page
(
1
)
groups
=
Group
.
all
groups
=
groups
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
groups
=
groups
.
page
(
1
)
render
json:
{
Groups
:
groups
.
as_json
(
only:
[
:id
,
:name
],
methods:
[
:avatar_url
]),
Users
:
users
.
as_json
(
only:
[
:id
,
:name
,
:username
],
methods:
[
:avatar_url
]),
}
end
protected
protected
def
member_params
def
member_params
...
...
spec/features/projects/members/group_links_spec.rb
View file @
2b41db92
...
@@ -43,4 +43,24 @@ feature 'Projects > Members > Anonymous user sees members', feature: true, js: t
...
@@ -43,4 +43,24 @@ feature 'Projects > Members > Anonymous user sees members', feature: true, js: t
expect
(
page
).
not_to
have_selector
(
'.group_member'
)
expect
(
page
).
not_to
have_selector
(
'.group_member'
)
end
end
context
'search'
do
it
'finds no results'
do
page
.
within
'.member-search-form'
do
fill_in
'search'
,
with:
'testing 123'
find
(
'.member-search-btn'
).
click
end
expect
(
page
).
not_to
have_selector
(
'.group_member'
)
end
it
'finds results'
do
page
.
within
'.member-search-form'
do
fill_in
'search'
,
with:
group
.
name
find
(
'.member-search-btn'
).
click
end
expect
(
page
).
to
have_selector
(
'.group_member'
,
count:
1
)
end
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