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
a42ce8d3
Commit
a42ce8d3
authored
Apr 29, 2021
by
Terri Chu
Committed by
Dylan Griffith
Apr 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep Search Scope Tab Order Consistent
parent
98643f5b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
9 deletions
+129
-9
app/views/search/_category.html.haml
app/views/search/_category.html.haml
+8
-6
changelogs/unreleased/300716-consistent-global-search-tab-order.yml
.../unreleased/300716-consistent-global-search-tab-order.yml
+5
-0
ee/app/views/search/_category_code.html.haml
ee/app/views/search/_category_code.html.haml
+2
-0
ee/app/views/search/_category_elasticsearch.html.haml
ee/app/views/search/_category_elasticsearch.html.haml
+1
-3
ee/app/views/search/_category_wiki.html.haml
ee/app/views/search/_category_wiki.html.haml
+2
-0
ee/spec/controllers/ee/search_controller_spec.rb
ee/spec/controllers/ee/search_controller_spec.rb
+111
-0
No files found.
app/views/search/_category.html.haml
View file @
a42ce8d3
...
...
@@ -13,23 +13,25 @@
=
search_filter_link
'issues'
,
_
(
"Issues"
)
-
if
project_search_tabs?
(
:merge_requests
)
=
search_filter_link
'merge_requests'
,
_
(
"Merge requests"
)
-
if
project_search_tabs?
(
:milestones
)
=
search_filter_link
'milestones'
,
_
(
"Milestones"
)
-
if
project_search_tabs?
(
:notes
)
=
search_filter_link
'notes'
,
_
(
"Comments"
)
-
if
project_search_tabs?
(
:wiki
)
=
search_filter_link
'wiki_blobs'
,
_
(
"Wiki"
)
-
if
project_search_tabs?
(
:commits
)
=
search_filter_link
'commits'
,
_
(
"Commits"
)
-
if
project_search_tabs?
(
:notes
)
=
search_filter_link
'notes'
,
_
(
"Comments"
)
-
if
project_search_tabs?
(
:milestones
)
=
search_filter_link
'milestones'
,
_
(
"Milestones"
)
=
users
-
elsif
@show_snippets
=
search_filter_link
'snippet_titles'
,
_
(
"Titles and Descriptions"
),
search:
{
snippets:
true
,
group_id:
nil
,
project_id:
nil
}
-
else
=
search_filter_link
'projects'
,
_
(
"Projects"
),
data:
{
qa_selector:
'projects_tab'
}
=
render_if_exists
'search/category_code'
=
render_if_exists
'search/epics_filter_link'
=
search_filter_link
'issues'
,
_
(
"Issues"
)
=
search_filter_link
'merge_requests'
,
_
(
"Merge requests"
)
=
search_filter_link
'milestones'
,
_
(
"Milestones"
)
=
render_if_exists
'search/epics_filter_link'
=
render_if_exists
'search/category_wiki'
=
render_if_exists
'search/category_elasticsearch'
=
search_filter_link
'milestones'
,
_
(
"Milestones"
)
=
users
changelogs/unreleased/300716-consistent-global-search-tab-order.yml
0 → 100644
View file @
a42ce8d3
---
title
:
Keep consistent Global Search tab order
merge_request
:
60319
author
:
type
:
changed
ee/app/views/search/_category_code.html.haml
0 → 100644
View file @
a42ce8d3
-
if
search_service
.
show_elasticsearch_tabs?
=
search_filter_link
'blobs'
,
_
(
"Code"
),
data:
{
qa_selector:
'code_tab'
}
ee/app/views/search/_category_elasticsearch.html.haml
View file @
a42ce8d3
-
if
search_service
.
show_elasticsearch_tabs?
=
search_filter_link
'notes'
,
_
(
"Comments"
)
=
search_filter_link
'blobs'
,
_
(
"Code"
),
data:
{
qa_selector:
'code_tab'
}
=
search_filter_link
'commits'
,
_
(
"Commits"
)
=
search_filter_link
'
wiki_blobs'
,
_
(
"Wiki
"
)
=
search_filter_link
'
notes'
,
_
(
"Comments
"
)
ee/app/views/search/_category_wiki.html.haml
0 → 100644
View file @
a42ce8d3
-
if
search_service
.
show_elasticsearch_tabs?
=
search_filter_link
'wiki_blobs'
,
_
(
"Wiki"
)
ee/spec/controllers/ee/search_controller_spec.rb
View file @
a42ce8d3
...
...
@@ -113,10 +113,46 @@ RSpec.describe SearchController, :elastic do
end
end
shared_examples
'search tabs displayed in consistent order'
do
render_views
let
(
:scope
)
{
'issues'
}
subject
{
get
:show
,
params:
request_params
,
format: :html
}
it
'keeps search tab order'
do
subject
# this order should be consistent across global, group, and project scoped searches
# though all tabs may not be available depending on the search scope and features enabled (epics, advanced search)
global_expected_order
=
%w[projects blobs epics issues merge_requests wiki_blobs commits notes milestones users]
tabs
=
response
.
body
.
scan
(
/search\?.*scope=(\w*)&/
).
flatten
expect
(
tabs
).
to
eq
(
global_expected_order
&
tabs
)
end
end
context
'global search'
do
let
(
:request_params
)
{
{
scope:
scope
,
search:
'term'
}
}
it_behaves_like
'renders the elasticsearch tabs if elasticsearch is enabled'
context
'scope tab order'
do
context
'when elasticsearch is disabled'
do
before
do
stub_ee_application_setting
(
elasticsearch_search:
false
,
elasticsearch_indexing:
false
)
end
it_behaves_like
'search tabs displayed in consistent order'
end
context
'when elasticsearch is enabled'
do
before
do
stub_ee_application_setting
(
elasticsearch_search:
true
,
elasticsearch_indexing:
true
)
end
it_behaves_like
'search tabs displayed in consistent order'
end
end
end
context
'group search'
do
...
...
@@ -125,6 +161,81 @@ RSpec.describe SearchController, :elastic do
let
(
:request_params
)
{
{
group_id:
group
.
id
,
scope:
scope
,
search:
'term'
}
}
it_behaves_like
'renders the elasticsearch tabs if elasticsearch is enabled'
context
'scope tab order'
do
context
'when elasticsearch is disabled'
do
before
do
stub_ee_application_setting
(
elasticsearch_search:
false
,
elasticsearch_indexing:
false
)
end
context
'when epics are disabled'
do
before
do
stub_licensed_features
(
epics:
false
)
end
it_behaves_like
'search tabs displayed in consistent order'
end
context
'when epics are enabled'
do
before
do
stub_licensed_features
(
epics:
true
)
end
it_behaves_like
'search tabs displayed in consistent order'
end
end
context
'when elasticsearch is enabled'
do
before
do
stub_ee_application_setting
(
elasticsearch_search:
true
,
elasticsearch_indexing:
true
)
end
context
'when epics are disabled'
do
before
do
stub_licensed_features
(
epics:
false
)
end
it_behaves_like
'search tabs displayed in consistent order'
end
context
'when epics are enabled'
do
before
do
stub_licensed_features
(
epics:
true
)
end
it_behaves_like
'search tabs displayed in consistent order'
end
end
end
end
context
'project search'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:request_params
)
{
{
project_id:
project
.
id
,
group_id:
project
.
group
,
scope:
scope
,
search:
'term'
}
}
before
do
project
.
add_developer
(
user
)
end
context
'scope tab order'
do
context
'when elasticsearch is disabled'
do
before
do
stub_ee_application_setting
(
elasticsearch_search:
false
,
elasticsearch_indexing:
false
)
end
it_behaves_like
'search tabs displayed in consistent order'
end
context
'when elasticsearch is enabled'
do
before
do
stub_ee_application_setting
(
elasticsearch_search:
true
,
elasticsearch_indexing:
true
)
end
it_behaves_like
'search tabs displayed in consistent order'
end
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