From 8a7dd1f5a1272f3701cde369c3ea314baec1f2ca Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Thu, 14 Dec 2023 16:37:55 +0000 Subject: [PATCH] Don't use legacy header when breadcrumbs are used --- client/scss/components/_header.scss | 3 ++- .../templates/wagtailadmin/generic/base.html | 7 ++--- .../templates/wagtailadmin/generic/form.html | 12 +++++++++ .../templates/wagtailadmin/generic/index.html | 8 +++++- .../wagtailadmin/generic/listing.html | 4 ++- .../tests/viewsets/test_model_viewset.py | 26 +++++++++++++++--- wagtail/snippets/tests/test_snippets.py | 27 +++++++++---------- wagtail/snippets/tests/test_usage.py | 9 +++---- wagtail/snippets/tests/test_viewset.py | 22 ++++++++------- wagtail/snippets/views/snippets.py | 2 ++ 10 files changed, 81 insertions(+), 39 deletions(-) diff --git a/client/scss/components/_header.scss b/client/scss/components/_header.scss index 5f07ff6407..197031d0d0 100644 --- a/client/scss/components/_header.scss +++ b/client/scss/components/_header.scss @@ -11,7 +11,8 @@ margin: 0; } - h1 { + h1, + .w-header__title { @apply w-h1; position: relative; } diff --git a/wagtail/admin/templates/wagtailadmin/generic/base.html b/wagtail/admin/templates/wagtailadmin/generic/base.html index cef1557c02..e2c574ce3e 100644 --- a/wagtail/admin/templates/wagtailadmin/generic/base.html +++ b/wagtail/admin/templates/wagtailadmin/generic/base.html @@ -34,12 +34,13 @@ {% endfragment %} {# Ensure all necessary variables are passed explicitly here #} - {# TODO: Pass `title=header_title` once slim_header and main_header are mutually exclusive (to prevent multiple h1) #} - {% include "wagtailadmin/shared/headers/slim_header.html" with breadcrumbs_items=breadcrumbs_items side_panels=side_panels history_url=history_url 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 only %} {% endif %} {% endblock %} {% block main_header %} - {% include "wagtailadmin/shared/header.html" with title=page_title subtitle=page_subtitle icon=header_icon only %} + {% if not breadcrumbs_items %} + {% include "wagtailadmin/shared/header.html" with title=page_title subtitle=page_subtitle icon=header_icon only %} + {% endif %} {% endblock %} {% endblock %} diff --git a/wagtail/admin/templates/wagtailadmin/generic/form.html b/wagtail/admin/templates/wagtailadmin/generic/form.html index 4f5173c8c8..30f728f563 100644 --- a/wagtail/admin/templates/wagtailadmin/generic/form.html +++ b/wagtail/admin/templates/wagtailadmin/generic/form.html @@ -2,6 +2,18 @@ {% load i18n wagtailadmin_tags %} {% block bodyclass %}editor-view{% endblock %} +{% block main_header %} + {% if breadcrumbs_items %} +
+

+ {{ page_subtitle }} +

+
+ {% else %} + {{ block.super }} + {% endif %} +{% endblock %} + {% block main_content %} {% block before_form %}{% endblock %}
diff --git a/wagtail/admin/templates/wagtailadmin/generic/index.html b/wagtail/admin/templates/wagtailadmin/generic/index.html index f95b7ac394..8e4f5d3a87 100644 --- a/wagtail/admin/templates/wagtailadmin/generic/index.html +++ b/wagtail/admin/templates/wagtailadmin/generic/index.html @@ -16,12 +16,18 @@ {% endif %} {% endblock %} {% endfragment %} - {% include "wagtailadmin/shared/header.html" with title=page_title subtitle=page_subtitle action_url=header_action_url action_text=header_action_label action_icon=header_action_icon base_actions=base_actions extra_actions=extra_actions icon=header_icon search_url=search_url search_form=search_form search_results_url=index_results_url only %} + {% if not breadcrumbs_items %} + {% include "wagtailadmin/shared/header.html" with title=page_title subtitle=page_subtitle action_url=header_action_url action_text=header_action_label action_icon=header_action_icon base_actions=base_actions extra_actions=extra_actions icon=header_icon search_url=search_url search_form=search_form search_results_url=index_results_url only %} + {% endif %} {% endblock %} {% block listing %}