Commit 91a270b1 authored by Markus Koller's avatar Markus Koller

Use search scope label in empty results message

Instead of a generic and misleading "results", use the label for the
currently selected search scope.
parent 14763c73
...@@ -34,15 +34,15 @@ module SearchHelper ...@@ -34,15 +34,15 @@ module SearchHelper
from: from, from: from,
to: to, to: to,
count: count, count: count,
scope: search_entries_info_label(scope, count), scope: search_entries_scope_label(scope, count),
term: term term: term
} }
end end
def search_entries_info_label(scope, count) def search_entries_scope_label(scope, count)
case scope case scope
when 'blobs', 'snippet_blobs', 'wiki_blobs' when 'blobs'
ns_('SearchResults|result', 'SearchResults|results', count) ns_('SearchResults|code result', 'SearchResults|code results', count)
when 'commits' when 'commits'
ns_('SearchResults|commit', 'SearchResults|commits', count) ns_('SearchResults|commit', 'SearchResults|commits', count)
when 'issues' when 'issues'
...@@ -55,10 +55,14 @@ module SearchHelper ...@@ -55,10 +55,14 @@ module SearchHelper
ns_('SearchResults|comment', 'SearchResults|comments', count) ns_('SearchResults|comment', 'SearchResults|comments', count)
when 'projects' when 'projects'
ns_('SearchResults|project', 'SearchResults|projects', count) ns_('SearchResults|project', 'SearchResults|projects', count)
when 'snippet_blobs'
ns_('SearchResults|snippet result', 'SearchResults|snippet results', count)
when 'snippet_titles' when 'snippet_titles'
ns_('SearchResults|snippet', 'SearchResults|snippets', count) ns_('SearchResults|snippet', 'SearchResults|snippets', count)
when 'users' when 'users'
ns_('SearchResults|user', 'SearchResults|users', count) ns_('SearchResults|user', 'SearchResults|users', count)
when 'wiki_blobs'
ns_('SearchResults|wiki result', 'SearchResults|wiki results', count)
else else
raise "Unrecognized search scope '#{scope}'" raise "Unrecognized search scope '#{scope}'"
end end
...@@ -72,6 +76,13 @@ module SearchHelper ...@@ -72,6 +76,13 @@ module SearchHelper
end end
end end
def search_entries_empty_message(scope, term)
(s_("SearchResults|We couldn't find any %{scope} matching %{term}") % {
scope: search_entries_scope_label(scope, 0),
term: "<code>#{term}</code>"
}).html_safe
end
def find_project_for_result_blob(projects, result) def find_project_for_result_blob(projects, result)
@project @project
end end
......
...@@ -2,5 +2,4 @@ ...@@ -2,5 +2,4 @@
.search_glyph .search_glyph
%h4 %h4
= icon('search') = icon('search')
= _("We couldn't find any results matching") = search_entries_empty_message(@scope, @search_term)
%code= @search_term
---
title: Use search scope label in empty results message
merge_request: 16324
author:
type: changed
...@@ -13509,6 +13509,14 @@ msgstr "" ...@@ -13509,6 +13509,14 @@ msgstr ""
msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\"" msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\""
msgstr "" msgstr ""
msgid "SearchResults|We couldn't find any %{scope} matching %{term}"
msgstr ""
msgid "SearchResults|code result"
msgid_plural "SearchResults|code results"
msgstr[0] ""
msgstr[1] ""
msgid "SearchResults|comment" msgid "SearchResults|comment"
msgid_plural "SearchResults|comments" msgid_plural "SearchResults|comments"
msgstr[0] "" msgstr[0] ""
...@@ -13539,13 +13547,13 @@ msgid_plural "SearchResults|projects" ...@@ -13539,13 +13547,13 @@ msgid_plural "SearchResults|projects"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
msgid "SearchResults|result" msgid "SearchResults|snippet"
msgid_plural "SearchResults|results" msgid_plural "SearchResults|snippets"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
msgid "SearchResults|snippet" msgid "SearchResults|snippet result"
msgid_plural "SearchResults|snippets" msgid_plural "SearchResults|snippet results"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
...@@ -13554,6 +13562,11 @@ msgid_plural "SearchResults|users" ...@@ -13554,6 +13562,11 @@ msgid_plural "SearchResults|users"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
msgid "SearchResults|wiki result"
msgid_plural "SearchResults|wiki results"
msgstr[0] ""
msgstr[1] ""
msgid "Seats currently in use" msgid "Seats currently in use"
msgstr "" msgstr ""
...@@ -17438,9 +17451,6 @@ msgstr "" ...@@ -17438,9 +17451,6 @@ msgstr ""
msgid "We could not determine the path to remove the issue" msgid "We could not determine the path to remove the issue"
msgstr "" msgstr ""
msgid "We couldn't find any results matching"
msgstr ""
msgid "We created a short guided tour that will help you learn the basics of GitLab and how it will help you be better at your job. It should only take a couple of minutes. You will be guided by two types of helpers, best recognized by their color." msgid "We created a short guided tour that will help you learn the basics of GitLab and how it will help you be better at your job. It should only take a couple of minutes. You will be guided by two types of helpers, best recognized by their color."
msgstr "" msgstr ""
......
...@@ -103,19 +103,17 @@ describe SearchHelper do ...@@ -103,19 +103,17 @@ describe SearchHelper do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
where(:scope, :label) do where(:scope, :label) do
'blobs' | 'code result'
'commits' | 'commit' 'commits' | 'commit'
'issues' | 'issue' 'issues' | 'issue'
'merge_requests' | 'merge request' 'merge_requests' | 'merge request'
'milestones' | 'milestone' 'milestones' | 'milestone'
'notes' | 'comment'
'projects' | 'project' 'projects' | 'project'
'snippet_blobs' | 'snippet result'
'snippet_titles' | 'snippet' 'snippet_titles' | 'snippet'
'users' | 'user' 'users' | 'user'
'wiki_blobs' | 'wiki result'
'blobs' | 'result'
'snippet_blobs' | 'result'
'wiki_blobs' | 'result'
'notes' | 'comment'
end end
with_them do with_them do
...@@ -140,6 +138,15 @@ describe SearchHelper do ...@@ -140,6 +138,15 @@ describe SearchHelper do
end end
end end
describe 'search_entries_empty_message' do
it 'returns the formatted entry message' do
message = search_entries_empty_message('projects', 'foo')
expect(message).to eq("We couldn't find any projects matching <code>foo</code>")
expect(message).to be_html_safe
end
end
describe 'search_filter_input_options' do describe 'search_filter_input_options' do
context 'project' do context 'project' do
before do before do
......
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