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
70261ff1
Commit
70261ff1
authored
Aug 14, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add users search results to global search
parent
c5370439
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
1 deletion
+58
-1
app/services/search/global_service.rb
app/services/search/global_service.rb
+1
-1
app/views/search/_category.html.haml
app/views/search/_category.html.haml
+5
-0
app/views/search/results/_user.html.haml
app/views/search/results/_user.html.haml
+8
-0
lib/gitlab/search_results.rb
lib/gitlab/search_results.rb
+14
-0
spec/features/global_search_spec.rb
spec/features/global_search_spec.rb
+18
-0
spec/lib/gitlab/search_results_spec.rb
spec/lib/gitlab/search_results_spec.rb
+12
-0
No files found.
app/services/search/global_service.rb
View file @
70261ff1
...
...
@@ -23,7 +23,7 @@ module Search
def
allowed_scopes
strong_memoize
(
:allowed_scopes
)
do
%w[issues merge_requests milestones]
%w[issues merge_requests milestones
users
]
end
end
...
...
app/views/search/_category.html.haml
View file @
70261ff1
...
...
@@ -78,3 +78,8 @@
=
_
(
"Milestones"
)
%span
.badge.badge-pill
=
limited_count
(
@search_results
.
limited_milestones_count
)
%li
{
class:
active_when
(
@scope
==
'users'
)
}
=
link_to
search_filter_path
(
scope:
'users'
)
do
Users
%span
.badge.badge-pill
=
limited_count
(
@search_results
.
limited_users_count
)
app/views/search/results/_user.html.haml
0 → 100644
View file @
70261ff1
%ul
.content-list
%li
.avatar-cell.d-none.d-sm-block
=
user_avatar
(
user:
user
,
user_name:
user
.
name
,
css_class:
'd-none d-sm-inline avatar s40'
)
.user-info
=
link_to
user_path
(
user
),
class:
'd-none d-sm-inline'
do
.item-title
=
user
.
name
.cgray
=
user
.
to_reference
lib/gitlab/search_results.rb
View file @
70261ff1
...
...
@@ -32,6 +32,8 @@ module Gitlab
merge_requests
.
page
(
page
).
per
(
per_page
)
when
'milestones'
milestones
.
page
(
page
).
per
(
per_page
)
when
'users'
users
.
page
(
page
).
per
(
per_page
)
else
Kaminari
.
paginate_array
([]).
page
(
page
).
per
(
per_page
)
end
...
...
@@ -71,6 +73,12 @@ module Gitlab
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
def
limited_users_count
@limited_users_count
||=
users
.
limit
(
count_limit
).
count
end
# rubocop:enable CodeReuse/ActiveRecord
def
single_commit_result?
false
end
...
...
@@ -129,6 +137,12 @@ module Gitlab
end
# rubocop: enable CodeReuse/ActiveRecord
def
users
return
[]
unless
Ability
.
allowed?
(
current_user
,
:read_users_list
)
UsersFinder
.
new
(
current_user
,
search:
query
).
execute
end
def
default_scope
'projects'
end
...
...
spec/features/global_search_spec.rb
View file @
70261ff1
...
...
@@ -25,4 +25,22 @@ describe 'Global search' do
expect
(
page
).
to
have_selector
(
'.gl-pagination .next'
)
end
end
describe
'users search'
do
it
'shows the found user under the Users tab'
do
create
(
:user
,
username:
'gob_bluth'
,
name:
'Gob Bluth'
)
visit
dashboard_projects_path
fill_in
'search'
,
with:
'gob'
click_button
'Go'
expect
(
page
).
to
have_content
(
'Users 1'
)
click_on
(
'Users 1'
)
expect
(
page
).
to
have_content
(
'Gob Bluth'
)
expect
(
page
).
to
have_content
(
'@gob_bluth'
)
end
end
end
spec/lib/gitlab/search_results_spec.rb
View file @
70261ff1
...
...
@@ -121,6 +121,18 @@ describe Gitlab::SearchResults do
results
.
objects
(
'issues'
)
end
end
describe
'#users'
do
it
'returns an empty array when the current_user is not allowed to read users list'
do
expect
(
results
.
objects
(
'users'
)).
to
be_empty
end
it
'calls the UsersFinder'
do
expect
(
UsersFinder
).
to
receive
(
:new
).
with
(
user
,
search:
'foo'
).
and_call_original
results
.
objects
(
'users'
)
end
end
end
it
'does not list issues on private projects'
do
...
...
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