Fix PublishMenuItem label is not overridable through hook

Fixes #10663
pull/10893/head
SebCorbin 2023-07-12 17:00:19 +02:00 zatwierdzone przez LB (Ben Johnston)
rodzic 72c55dee17
commit f82366e151
4 zmienionych plików z 18 dodań i 1 usunięć

Wyświetl plik

@ -31,6 +31,7 @@ Changelog
* Fix: Avoid an error when the moderation panel (admin dashboard) contains both snippets and private pages (Matt Westcott)
* Fix: When deleting collections, ensure the collection name is correctly shown in the success message (LB (Ben) Johnston)
* Fix: Filter out comments on Page editing counts that do not correspond to a valid field / block path on the page such as when a field has been removed (Matt Westcott)
* Fix: Allow `PublishMenuItem` to more easily support overriding its label via `construct_page_action_menu` (Sébastien Corbin)
* Docs: Document `WAGTAILADMIN_BASE_URL` on "Integrating Wagtail into a Django project" page (Shreshth Srivastava)
* Docs: Replace incorrect screenshot for authors listing on tutorial (Shreshth Srivastava)
* Docs: Add documentation for building non-model-based choosers using the _queryish_ library (Matt Westcott)

Wyświetl plik

@ -44,6 +44,7 @@ depth: 1
* Avoid an error when the moderation panel (admin dashboard) contains both snippets and private pages (Matt Westcott)
* When deleting collections, ensure the collection name is correctly shown in the success message (LB (Ben) Johnston)
* Filter out comments on Page editing counts that do not correspond to a valid field / block path on the page such as when a field has been removed (Matt Westcott)
* Allow `PublishMenuItem` to more easily support overriding its label via `construct_page_action_menu` (Sébastien Corbin)
### Documentation

Wyświetl plik

@ -10,5 +10,5 @@
>
{% if icon_name %}{% icon name=icon_name classname="button-longrunning__icon" %}{% endif %}
{% icon name="spinner" %}
<em data-w-progress-target="label">{% if is_revision %}{% trans 'Publish this version' %}{% else %}{% trans 'Publish' %}{% endif %}</em>
<em data-w-progress-target="label">{% if is_revision %}{% trans 'Publish this version' %}{% else %}{{ label }}{% endif %}</em>
</button>

Wyświetl plik

@ -1891,6 +1891,21 @@ class TestPageEdit(WagtailTestUtils, TestCase):
self.assertContains(response, publish_button, html=True)
self.assertNotContains(response, "<li>%s</li>" % publish_button, html=True)
def test_override_publish_action_menu_item_label(self):
def hook_func(menu_items, request, context):
for item in menu_items:
if item.name == "action-publish":
item.label = "Foobar"
break
with self.register_hook("construct_page_action_menu", hook_func):
response = self.client.get(
reverse("wagtailadmin_pages:edit", args=(self.single_event_page.id,))
)
# publish button should have another label
self.assertContains(response, "Foobar")
def test_edit_alias_page(self):
alias_page = self.event_page.create_alias(update_slug="new-event-page")
response = self.client.get(