Commit b3078831 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'ee-43990-improve-search-empty-message' into 'master'

Use search scope label in empty results message

See merge request gitlab-org/gitlab!16324
parents 7289e72c 91a270b1
......@@ -34,15 +34,15 @@ module SearchHelper
from: from,
to: to,
count: count,
scope: search_entries_info_label(scope, count),
scope: search_entries_scope_label(scope, count),
term: term
}
end
def search_entries_info_label(scope, count)
def search_entries_scope_label(scope, count)
case scope
when 'blobs', 'snippet_blobs', 'wiki_blobs'
ns_('SearchResults|result', 'SearchResults|results', count)
when 'blobs'
ns_('SearchResults|code result', 'SearchResults|code results', count)
when 'commits'
ns_('SearchResults|commit', 'SearchResults|commits', count)
when 'issues'
......@@ -55,10 +55,14 @@ module SearchHelper
ns_('SearchResults|comment', 'SearchResults|comments', count)
when 'projects'
ns_('SearchResults|project', 'SearchResults|projects', count)
when 'snippet_blobs'
ns_('SearchResults|snippet result', 'SearchResults|snippet results', count)
when 'snippet_titles'
ns_('SearchResults|snippet', 'SearchResults|snippets', count)
when 'users'
ns_('SearchResults|user', 'SearchResults|users', count)
when 'wiki_blobs'
ns_('SearchResults|wiki result', 'SearchResults|wiki results', count)
else
raise "Unrecognized search scope '#{scope}'"
end
......@@ -72,6 +76,13 @@ module SearchHelper
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)
@project
end
......
......@@ -2,5 +2,4 @@
.search_glyph
%h4
= icon('search')
= _("We couldn't find any results matching")
%code= @search_term
= search_entries_empty_message(@scope, @search_term)
---
title: Use search scope label in empty results message
merge_request: 16324
author:
type: changed
......@@ -13557,6 +13557,14 @@ msgstr ""
msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\""
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_plural "SearchResults|comments"
msgstr[0] ""
......@@ -13587,13 +13595,13 @@ msgid_plural "SearchResults|projects"
msgstr[0] ""
msgstr[1] ""
msgid "SearchResults|result"
msgid_plural "SearchResults|results"
msgid "SearchResults|snippet"
msgid_plural "SearchResults|snippets"
msgstr[0] ""
msgstr[1] ""
msgid "SearchResults|snippet"
msgid_plural "SearchResults|snippets"
msgid "SearchResults|snippet result"
msgid_plural "SearchResults|snippet results"
msgstr[0] ""
msgstr[1] ""
......@@ -13602,6 +13610,11 @@ msgid_plural "SearchResults|users"
msgstr[0] ""
msgstr[1] ""
msgid "SearchResults|wiki result"
msgid_plural "SearchResults|wiki results"
msgstr[0] ""
msgstr[1] ""
msgid "Seats currently in use"
msgstr ""
......@@ -17519,9 +17532,6 @@ msgstr ""
msgid "We could not determine the path to remove the issue"
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."
msgstr ""
......
......@@ -103,19 +103,17 @@ describe SearchHelper do
using RSpec::Parameterized::TableSyntax
where(:scope, :label) do
'blobs' | 'code result'
'commits' | 'commit'
'issues' | 'issue'
'merge_requests' | 'merge request'
'milestones' | 'milestone'
'notes' | 'comment'
'projects' | 'project'
'snippet_blobs' | 'snippet result'
'snippet_titles' | 'snippet'
'users' | 'user'
'blobs' | 'result'
'snippet_blobs' | 'result'
'wiki_blobs' | 'result'
'notes' | 'comment'
'wiki_blobs' | 'wiki result'
end
with_them do
......@@ -140,6 +138,15 @@ describe SearchHelper do
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
context 'project' 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