Commit 2e417808 authored by Dylan Griffith's avatar Dylan Griffith

Add link to basic search when no results

For https://gitlab.com/gitlab-org/gitlab/issues/33678 this will allow us
to roll out Elasticsearch more confidently as users can always revert
back if there is a problem with the Elasticsearch results.
parent c8aad010
- if @search_objects.to_a.empty?
= render partial: "search/results/empty"
= render_if_exists 'shared/promotions/promote_advanced_search'
= render_if_exists 'search/form_revert_to_basic'
- else
.row-content-block.d-md-flex.text-left.align-items-center
- unless @search_objects.is_a?(Kaminari::PaginatableWithoutCount)
......
# frozen_string_literal: true
module Search
module Elasticsearchable
def use_elasticsearch?
......
- if search_service.use_elasticsearch?
- query_string = URI.parse(request.url).query
- query_params = Rack::Utils.parse_query(query_string)
- url = url_for :only_path => false, :params => query_params.merge(basic_search: 'true')
- begin_link = '<a href="%{url}">'.html_safe % { url: url }
- end_link = '</a>'.html_safe
%p.text-center
= _('You can try again using %{begin_link}basic search%{end_link}').html_safe % { begin_link: begin_link, end_link: end_link }
......@@ -219,4 +219,24 @@ describe 'Global elastic search', :elastic do
expect(page).to have_content('Users 0')
end
end
describe 'When requesting basic search' do
it 'does not use Elasticsearch' do
create(:issue, project: project, title: 'project issue')
visit dashboard_projects_path
submit_search('project')
# Project won't be found since ES index is not up to date
expect(page).not_to have_content('Projects 1')
# Since there are no results you have the option to instead use basic
# search
click_link 'basic search'
# Project is found now that we are using basic search
expect(page).to have_content('Projects 1')
end
end
end
......@@ -19073,6 +19073,9 @@ msgstr ""
msgid "You can test your .gitlab-ci.yml in %{linkStart}CI Lint%{linkEnd}."
msgstr ""
msgid "You can try again using %{begin_link}basic search%{end_link}"
msgstr ""
msgid "You cannot access the raw file. Please wait a minute."
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment