kopia lustrzana https://github.com/wagtail/wagtail
drop buttons_data argument from ButtonWithDropdown in favour of passing Button instances
If Button instances are going to be our standard mechanism for passing the bundle of properties for a menu item, we don't need to invent another one.pull/10939/head
rodzic
0ab4bb8db5
commit
eaaf450c14
|
@ -39,7 +39,7 @@ from wagtail.admin.utils import (
|
|||
get_valid_next_url_from_request,
|
||||
)
|
||||
from wagtail.admin.views.bulk_action.registry import bulk_action_registry
|
||||
from wagtail.admin.widgets import ButtonWithDropdown, PageListingButton
|
||||
from wagtail.admin.widgets import Button, ButtonWithDropdown, PageListingButton
|
||||
from wagtail.coreutils import (
|
||||
camelcase_to_underscore,
|
||||
escape_script,
|
||||
|
@ -540,19 +540,19 @@ def bulk_action_choices(context, app_label, model_name):
|
|||
label=_("More"),
|
||||
attrs={"title": _("More bulk actions")},
|
||||
button_classes={"button", "button-secondary", "button-small"},
|
||||
buttons_data=[
|
||||
{
|
||||
"label": action.display_name,
|
||||
"url": reverse(
|
||||
buttons=[
|
||||
Button(
|
||||
label=action.display_name,
|
||||
url=reverse(
|
||||
"wagtail_bulk_action",
|
||||
args=[app_label, model_name, action.action_type],
|
||||
)
|
||||
+ "?"
|
||||
+ urlencode({"next": next_url}),
|
||||
"attrs": {"aria-label": action.aria_label},
|
||||
"priority": action.action_priority,
|
||||
"classes": {"bulk-action-btn"},
|
||||
}
|
||||
attrs={"aria-label": action.aria_label},
|
||||
priority=action.action_priority,
|
||||
classes={"bulk-action-btn"},
|
||||
)
|
||||
for action in bulk_action_more_list
|
||||
],
|
||||
)
|
||||
|
|
|
@ -112,7 +112,7 @@ class ButtonWithDropdown(BaseDropdownMenuButton):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.button_classes = kwargs.pop("button_classes", set())
|
||||
self.buttons_data = kwargs.pop("buttons_data", [])
|
||||
self.dropdown_buttons = kwargs.pop("buttons", [])
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def get_context_data(self):
|
||||
|
@ -120,10 +120,6 @@ class ButtonWithDropdown(BaseDropdownMenuButton):
|
|||
context["button_classes"] = self.button_classes
|
||||
return context
|
||||
|
||||
@cached_property
|
||||
def dropdown_buttons(self):
|
||||
return [Button(**button) for button in self.buttons_data]
|
||||
|
||||
|
||||
class ButtonWithDropdownFromHook(BaseDropdownMenuButton):
|
||||
template_name = "wagtailadmin/pages/listing/_button_with_dropdown.html"
|
||||
|
|
Ładowanie…
Reference in New Issue