Commit 53faa9c8 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '30666-fix-sr-term-style' into 'master'

Code tag styling for search term

Closes #30666

See merge request gitlab-org/gitlab!20416
parents 620d73bb 992db004
...@@ -31,13 +31,14 @@ module SearchHelper ...@@ -31,13 +31,14 @@ module SearchHelper
from = collection.offset_value + 1 from = collection.offset_value + 1
to = collection.offset_value + collection.to_a.size to = collection.offset_value + collection.to_a.size
count = collection.total_count count = collection.total_count
term_element = "<span>&nbsp;<code>#{h(term)}</code>&nbsp;</span>".html_safe
search_entries_info_template(collection) % { search_entries_info_template(collection) % {
from: from, from: from,
to: to, to: to,
count: count, count: count,
scope: search_entries_scope_label(scope, count), scope: search_entries_scope_label(scope, count),
term: term term_element: term_element
} }
end end
...@@ -72,9 +73,9 @@ module SearchHelper ...@@ -72,9 +73,9 @@ module SearchHelper
def search_entries_info_template(collection) def search_entries_info_template(collection)
if collection.total_pages > 1 if collection.total_pages > 1
s_("SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\"") s_("SearchResults|Showing %{from} - %{to} of %{count} %{scope} for%{term_element}").html_safe
else else
s_("SearchResults|Showing %{count} %{scope} for \"%{term}\"") s_("SearchResults|Showing %{count} %{scope} for%{term_element}").html_safe
end end
end end
......
---
title: Changes to how the search term is styled in the results
merge_request: 20416
author:
type: changed
...@@ -56,9 +56,9 @@ module EE ...@@ -56,9 +56,9 @@ module EE
return super unless gitlab_com_snippet_db_search? return super unless gitlab_com_snippet_db_search?
if collection.total_pages > 1 if collection.total_pages > 1
s_("SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\" in your personal and project snippets") s_("SearchResults|Showing %{from} - %{to} of %{count} %{scope} for%{term_element} in your personal and project snippets").html_safe
else else
s_("SearchResults|Showing %{count} %{scope} for \"%{term}\" in your personal and project snippets") s_("SearchResults|Showing %{count} %{scope} for%{term_element} in your personal and project snippets").html_safe
end end
end end
......
...@@ -119,7 +119,7 @@ describe SearchHelper do ...@@ -119,7 +119,7 @@ describe SearchHelper do
let(:show_snippets) { true } let(:show_snippets) { true }
let(:collection) { Kaminari.paginate_array([:foo]).page(1).per(10) } let(:collection) { Kaminari.paginate_array([:foo]).page(1).per(10) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:message) { "Showing %{count} %{scope} for \"%{term}\"" } let(:message) { "Showing %{count} %{scope} for%{term_element}" }
let(:new_message) { message + " in your personal and project snippets" } let(:new_message) { message + " in your personal and project snippets" }
subject { search_entries_info_template(collection) } subject { search_entries_info_template(collection) }
......
...@@ -15325,16 +15325,16 @@ msgstr "" ...@@ -15325,16 +15325,16 @@ msgstr ""
msgid "SearchCodeResults|of %{link_to_project}" msgid "SearchCodeResults|of %{link_to_project}"
msgstr "" msgstr ""
msgid "SearchResults|Showing %{count} %{scope} for \"%{term}\"" msgid "SearchResults|Showing %{count} %{scope} for%{term_element}"
msgstr "" msgstr ""
msgid "SearchResults|Showing %{count} %{scope} for \"%{term}\" in your personal and project snippets" msgid "SearchResults|Showing %{count} %{scope} for%{term_element} in your personal and project snippets"
msgstr "" msgstr ""
msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\"" msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for%{term_element}"
msgstr "" msgstr ""
msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\" in your personal and project snippets" msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for%{term_element} in your personal and project snippets"
msgstr "" msgstr ""
msgid "SearchResults|We couldn't find any %{scope} matching %{term}" msgid "SearchResults|We couldn't find any %{scope} matching %{term}"
......
...@@ -122,13 +122,13 @@ describe SearchHelper do ...@@ -122,13 +122,13 @@ describe SearchHelper do
it 'uses the correct singular label' do it 'uses the correct singular label' do
collection = Kaminari.paginate_array([:foo]).page(1).per(10) collection = Kaminari.paginate_array([:foo]).page(1).per(10)
expect(search_entries_info(collection, scope, 'foo')).to eq("Showing 1 #{label} for \"foo\"") expect(search_entries_info(collection, scope, 'foo')).to eq("Showing 1 #{label} for<span>&nbsp;<code>foo</code>&nbsp;</span>")
end end
it 'uses the correct plural label' do it 'uses the correct plural label' do
collection = Kaminari.paginate_array([:foo] * 23).page(1).per(10) collection = Kaminari.paginate_array([:foo] * 23).page(1).per(10)
expect(search_entries_info(collection, scope, 'foo')).to eq("Showing 1 - 10 of 23 #{label.pluralize} for \"foo\"") expect(search_entries_info(collection, scope, 'foo')).to eq("Showing 1 - 10 of 23 #{label.pluralize} for<span>&nbsp;<code>foo</code>&nbsp;</span>")
end end
end end
......
...@@ -16,7 +16,7 @@ describe 'search/_results' do ...@@ -16,7 +16,7 @@ describe 'search/_results' do
it 'displays the page size' do it 'displays the page size' do
render render
expect(rendered).to have_content('Showing 1 - 2 of 3 issues for "foo"') expect(rendered).to have_content('Showing 1 - 2 of 3 issues for foo')
end end
context 'when search results do not have a count' do context 'when search results do not have a count' 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