0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Restore icon in views that use slim_header.html

Previously removed in 8a7dd1f5a1 and
663f9603ca
This commit is contained in:
Sage Abdullah 2024-02-23 16:56:07 +00:00 committed by Thibaud Colas
parent 24deedea78
commit 6c0e638c9a
5 changed files with 32 additions and 19 deletions

View File

@ -17,7 +17,7 @@
{% endfragment %}
{# Ensure all necessary variables are passed explicitly here #}
{% include "wagtailadmin/shared/headers/slim_header.html" with breadcrumbs_items=breadcrumbs_items side_panels=side_panels history_url=history_url title=header_title search_url=index_results_url search_form=search_form filters=filters actions=actions only %}
{% include "wagtailadmin/shared/headers/slim_header.html" with breadcrumbs_items=breadcrumbs_items side_panels=side_panels history_url=history_url title=header_title search_url=index_results_url search_form=search_form filters=filters actions=actions icon_name=header_icon only %}
{% endif %}
{% endblock %}
{% block main_header %}

View File

@ -6,6 +6,7 @@
{% if breadcrumbs_items %}
<div class="w-header nice-padding w-mt-8">
<h2 class="w-header__title" id="header-title">
{% icon classname="w-header__glyph" name=header_icon %}
{{ page_subtitle }}
</h2>
</div>

View File

@ -11,6 +11,7 @@
- `search_url` - URL to the search view, should respond with a partial template for the results
- `search_form` - form to be rendered for search
- `filters` - filters to be rendered
- `icon_name` - name of the icon to be used in the header
When including this template, use the `only` parameter whenever possible to
ensure that the above variables are indeed the only ones needed for this
@ -40,7 +41,7 @@
{% block breadcrumbs %}
{% if breadcrumbs_items %}
{% breadcrumbs breadcrumbs_items %}
{% breadcrumbs breadcrumbs_items icon_name=icon_name %}
{% endif %}
{% endblock %}

View File

@ -2410,7 +2410,14 @@ class TestEditDraftStateSnippet(BaseTestSnippetEditView):
# Should use the latest draft content for the title
self.assertContains(
response,
'<h2 class="w-header__title" id="header-title">Draft-enabled Bar, In Draft</h2>',
"""
<h2 class="w-header__title" id="header-title">
<svg class="icon icon-snippet w-header__glyph" aria-hidden="true">
<use href="#icon-snippet"></use>
</svg>
Draft-enabled Bar, In Draft
</h2>
""",
html=True,
)

View File

@ -69,8 +69,6 @@ class BaseSnippetViewSetTests(WagtailTestUtils, TestCase):
class TestCustomIcon(BaseSnippetViewSetTests):
# TODO: decide what to do with this test, since the new designs after
# Universal Listings and unified breadcrumbs/header don't have icons
model = FullFeaturedSnippet
def setUp(self):
@ -84,26 +82,28 @@ class TestCustomIcon(BaseSnippetViewSetTests):
def test_get_views(self):
pk = quote(self.object.pk)
views = [
# TODO: Some of these views have been migrated to use the slim_header
# only, so there is no header_icon anymore.
# ("list", []),
# ("add", []),
# ("edit", [pk]),
# ("delete", [pk]),
# ("usage", [pk]),
("unpublish", [pk]),
("workflow_history", [pk]),
# ("revisions_revert", [pk, self.revision_1.id]),
("revisions_compare", [pk, self.revision_1.id, self.revision_2.id]),
("revisions_unschedule", [pk, self.revision_2.id]),
("list", [], "headers/slim_header.html"),
("add", [], "headers/slim_header.html"),
("edit", [pk], "headers/slim_header.html"),
("delete", [pk], "header.html"),
("usage", [pk], "headers/slim_header.html"),
("unpublish", [pk], "header.html"),
("workflow_history", [pk], "header.html"),
("revisions_revert", [pk, self.revision_1.id], "headers/slim_header.html"),
(
"revisions_compare",
[pk, self.revision_1.id, self.revision_2.id],
"header.html",
),
("revisions_unschedule", [pk, self.revision_2.id], "header.html"),
]
for view_name, args in views:
for view_name, args, header in views:
with self.subTest(view_name=view_name):
response = self.client.get(self.get_url(view_name, args))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["header_icon"], "cog")
self.assertContains(response, "icon icon-cog", count=1)
self.assertTemplateUsed(response, "wagtailadmin/shared/header.html")
self.assertTemplateUsed(response, f"wagtailadmin/shared/{header}")
def test_get_history(self):
response = self.client.get(self.get_url("history", [quote(self.object.pk)]))
@ -112,6 +112,10 @@ class TestCustomIcon(BaseSnippetViewSetTests):
response,
"wagtailadmin/shared/headers/slim_header.html",
)
# History view icon is not configurable for consistency with pages
self.assertEqual(response.context["header_icon"], "history")
self.assertContains(response, "icon icon-history")
self.assertNotContains(response, "icon icon-cog")
self.assertTemplateNotUsed(response, "wagtailadmin/shared/header.html")
def test_get_workflow_history_detail(self):