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
b26758e0
Commit
b26758e0
authored
Oct 29, 2019
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow switch to basic search on some tabs
Only some tabs support basic search and others need Elasticsearch
parent
7a8be270
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
5 deletions
+49
-5
ee/app/helpers/ee/search_helper.rb
ee/app/helpers/ee/search_helper.rb
+12
-0
ee/app/views/search/_form_revert_to_basic.html.haml
ee/app/views/search/_form_revert_to_basic.html.haml
+1
-1
ee/spec/features/search/elastic/global_search_spec.rb
ee/spec/features/search/elastic/global_search_spec.rb
+13
-4
ee/spec/helpers/search_helper_spec.rb
ee/spec/helpers/search_helper_spec.rb
+23
-0
No files found.
ee/app/helpers/ee/search_helper.rb
View file @
b26758e0
...
...
@@ -3,6 +3,8 @@ module EE
module
SearchHelper
extend
::
Gitlab
::
Utils
::
Override
SWITCH_TO_BASIC_SEARCHABLE_TABS
=
%w[projects issues merge_requests milestones users]
.
freeze
override
:search_filter_input_options
def
search_filter_input_options
(
type
)
options
=
super
...
...
@@ -68,6 +70,16 @@ module EE
search_path
(
search_params
)
end
# Switching to basic search should only be possible for a subset of
# scopes. This method assumes you're already allowed to search within
# this scope but it's just here to determine if you can switch to basic
# search.
def
switch_to_basic_searchable_tab?
(
scope
)
return
true
if
@project
scope
.
in?
(
SWITCH_TO_BASIC_SEARCHABLE_TABS
)
end
private
def
search_multiple_assignees?
(
type
)
...
...
ee/app/views/search/_form_revert_to_basic.html.haml
View file @
b26758e0
-
if
search_service
.
use_elasticsearch?
-
if
search_service
.
use_elasticsearch?
&&
switch_to_basic_searchable_tab?
(
search_service
.
scope
)
-
begin_link
=
'<a href="%{url}">'
.
html_safe
%
{
url:
revert_to_basic_search_filter_url
}
-
end_link
=
'</a>'
.
html_safe
%p
.text-center
...
...
ee/spec/features/search/elastic/global_search_spec.rb
View file @
b26758e0
...
...
@@ -220,10 +220,8 @@ describe 'Global elastic search', :elastic do
end
end
describe
'When requesting basic search'
do
it
'does not use Elasticsearch'
do
create
(
:issue
,
project:
project
,
title:
'project issue'
)
context
'when no results are returned'
do
it
'allows basic search without Elasticsearch'
do
visit
dashboard_projects_path
submit_search
(
'project'
)
...
...
@@ -238,5 +236,16 @@ describe 'Global elastic search', :elastic do
# Project is found now that we are using basic search
expect
(
page
).
to
have_content
(
'Projects 1'
)
end
context
'when performing Commits search'
do
it
'does not allow basic search'
do
visit
dashboard_projects_path
submit_search
(
'project'
)
select_search_scope
(
'Commits'
)
expect
(
page
).
not_to
have_link
(
'basic search'
)
end
end
end
end
ee/spec/helpers/search_helper_spec.rb
View file @
b26758e0
...
...
@@ -175,4 +175,27 @@ describe SearchHelper do
it_behaves_like
'returns old message'
end
end
describe
'#switch_to_basic_searchable_tab?'
do
let
(
:scope
)
{
'commits'
}
subject
{
switch_to_basic_searchable_tab?
(
scope
)
}
context
'when project scope'
do
before
do
@project
=
create
(
:project
)
end
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'when commits tab'
do
it
{
is_expected
.
to
eq
(
false
)
}
end
context
'when issues tab'
do
let
(
:scope
)
{
'issues'
}
it
{
is_expected
.
to
eq
(
true
)
}
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