Enable breadcrumbs by default

pull/12721/head
Sage Abdullah 2024-12-06 15:54:48 +00:00 zatwierdzone przez Matt Westcott
rodzic 58d9f9bc72
commit 130a9ebd93
13 zmienionych plików z 20 dodań i 33 usunięć

Wyświetl plik

@ -50,7 +50,6 @@ class Create(CreateView):
edit_url_name = "wagtailadmin_collections:edit"
index_url_name = "wagtailadmin_collections:index"
header_icon = "folder-open-1"
_show_breadcrumbs = True
def get_form(self, form_class=None):
form = super().get_form(form_class)
@ -80,7 +79,6 @@ class Edit(EditView):
delete_url_name = "wagtailadmin_collections:delete"
context_object_name = "collection"
header_icon = "folder-open-1"
_show_breadcrumbs = True
def _user_may_move_collection(self, user, instance):
"""

Wyświetl plik

@ -41,9 +41,17 @@ class WagtailAdminTemplateMixin(TemplateResponseMixin, ContextMixin):
page_title = ""
page_subtitle = ""
header_icon = ""
# Breadcrumbs are opt-in until we have a design that can be consistently applied
_show_breadcrumbs = False
breadcrumbs_items = [{"url": reverse_lazy("wagtailadmin_home"), "label": _("Home")}]
"""
The base set of breadcrumbs items to be displayed on the page.
The property can be overridden by subclasses and viewsets to provide
custom base items, e.g. page tree breadcrumbs or add the "Snippets" item.
Views should copy and append to this list in :meth:`get_breadcrumbs_items()`
to define the path to the current view.
"""
template_name = "wagtailadmin/generic/base.html"
header_buttons = []
header_more_buttons = []
@ -65,6 +73,12 @@ class WagtailAdminTemplateMixin(TemplateResponseMixin, ContextMixin):
return self.header_icon
def get_breadcrumbs_items(self):
"""
Define the current path to the view by copying the base
:attr:`breadcrumbs_items` and appending the list.
If breadcrumbs are not required, return an empty list.
"""
return self.breadcrumbs_items
def get_header_buttons(self):
@ -92,14 +106,11 @@ class WagtailAdminTemplateMixin(TemplateResponseMixin, ContextMixin):
context["page_title"] = self.get_page_title()
context["page_subtitle"] = self.get_page_subtitle()
context["header_icon"] = self.get_header_icon()
# Once all appropriate views use "wagtailadmin/generic/base.html" and
# the slim_header.html, _show_breadcrumbs can be removed
context["header_title"] = self.get_header_title()
context["breadcrumbs_items"] = None
if self._show_breadcrumbs:
context["breadcrumbs_items"] = self.get_breadcrumbs_items()
context["header_buttons"] = self.get_header_buttons()
# Breadcrumbs are enabled by default.
context["breadcrumbs_items"] = self.get_breadcrumbs_items()
context["header_buttons"] = self.get_header_buttons()
return context
def get_template_names(self):
@ -203,7 +214,6 @@ class BaseListingView(WagtailAdminTemplateMixin, BaseListView):
default_ordering = None
filterset_class = None
verbose_name_plural = None
_show_breadcrumbs = True
def get_template_names(self):
if self.results_only:

Wyświetl plik

@ -415,7 +415,6 @@ class WorkflowHistoryDetailView(
page_title = gettext_lazy("Workflow progress")
header_icon = "list-ul"
object_icon = "doc-empty-inverse"
_show_breadcrumbs = True
@cached_property
def index_url(self):

Wyświetl plik

@ -50,7 +50,6 @@ class GenericPageBreadcrumbsMixin:
item of the generic view's generated breadcrumbs items.
"""
_show_breadcrumbs = True
breadcrumbs_items_to_take = 1
@cached_property

Wyświetl plik

@ -175,7 +175,6 @@ class Create(CreateView):
index_url_name = "wagtailadmin_workflows:index"
header_icon = "tasks"
edit_handler = None
_show_breadcrumbs = True
def get_edit_handler(self):
if not self.edit_handler:
@ -263,7 +262,6 @@ class Edit(EditView):
header_more_buttons = []
edit_handler = None
MAX_PAGES = 5
_show_breadcrumbs = True
def get_edit_handler(self):
if not self.edit_handler:
@ -647,7 +645,6 @@ class CreateTask(CreateView):
edit_url_name = "wagtailadmin_workflows:edit_task"
index_url_name = "wagtailadmin_workflows:task_index"
header_icon = "thumbtack"
_show_breadcrumbs = True
@cached_property
def model(self):
@ -710,7 +707,6 @@ class EditTask(EditView):
enable_url_name = "wagtailadmin_workflows:enable_task"
header_icon = "thumbtack"
header_more_buttons = []
_show_breadcrumbs = True
@cached_property
def model(self):

Wyświetl plik

@ -63,9 +63,6 @@ class ModelViewSet(ViewSet):
#: The view class to use for the inspect view; must be a subclass of ``wagtail.admin.views.generic.InspectView``.
inspect_view_class = generic.InspectView
# Breadcrumbs can be turned off until we have a design that can be consistently applied
_show_breadcrumbs = True
#: The prefix of template names to look for when rendering the admin views.
template_prefix = ""
@ -136,7 +133,6 @@ class ModelViewSet(ViewSet):
"edit_url_name": self.get_url_name("edit"),
"delete_url_name": self.get_url_name("delete"),
"header_icon": self.icon,
"_show_breadcrumbs": self._show_breadcrumbs,
**kwargs,
}
)

Wyświetl plik

@ -31,7 +31,6 @@ class PageListingViewSet(ViewSet):
def get_common_view_kwargs(self, **kwargs):
return super().get_common_view_kwargs(
**{
"_show_breadcrumbs": True,
"header_icon": self.icon,
"model": self.model,
"index_url_name": self.get_url_name("index"),

Wyświetl plik

@ -145,7 +145,6 @@ class EditView(generic.EditView):
pk_url_kwarg = "redirect_id"
error_message = gettext_lazy("The redirect could not be saved due to errors.")
header_icon = "redirect"
_show_breadcrumbs = True
def get_success_message(self):
return _("Redirect '%(redirect_title)s' updated.") % {
@ -196,7 +195,6 @@ class CreateView(generic.CreateView):
edit_url_name = "wagtailredirects:edit"
error_message = gettext_lazy("The redirect could not be created due to errors.")
header_icon = "redirect"
_show_breadcrumbs = True
def get_success_message(self, instance):
return _("Redirect '%(redirect_title)s' added.") % {

Wyświetl plik

@ -84,7 +84,6 @@ class EditView(generic.EditView):
edit_url_name = "wagtailsettings:edit"
error_message = gettext_lazy("The setting could not be saved due to errors.")
permission_required = "change"
_show_breadcrumbs = True
def setup(self, request, app_name, model_name, *args, **kwargs):
self.app_name = app_name

Wyświetl plik

@ -162,7 +162,6 @@ class CreateView(generic.CreateView):
error_message = gettext_lazy("The document could not be created due to errors.")
template_name = "wagtaildocs/documents/add.html"
header_icon = "doc-full-inverse"
_show_breadcrumbs = True
@cached_property
def model(self):
@ -197,7 +196,6 @@ class EditView(generic.EditView):
delete_url_name = "wagtaildocs:delete"
header_icon = "doc-full-inverse"
context_object_name = "document"
_show_breadcrumbs = True
@cached_property
def model(self):

Wyświetl plik

@ -25,7 +25,6 @@ class AddView(WagtailAdminTemplateMixin, BaseAddView):
template_name = "wagtaildocs/multiple/add.html"
header_icon = "doc-full-inverse"
page_title = gettext_lazy("Add documents")
_show_breadcrumbs = True
index_url_name = "wagtaildocs:index"
edit_object_url_name = "wagtaildocs:edit_multiple"

Wyświetl plik

@ -134,7 +134,6 @@ class EditView(generic.EditView):
url_generator_url_name = "wagtailimages:url_generator"
header_icon = "image"
context_object_name = "image"
_show_breadcrumbs = True
@cached_property
def model(self):
@ -212,7 +211,6 @@ class URLGeneratorView(generic.InspectView):
template_name = "wagtailimages/images/url_generator.html"
index_url_name = "wagtailimages:index"
edit_url_name = "wagtailimages:edit"
_show_breadcrumbs = True
def get_page_subtitle(self):
return self.object.title
@ -346,7 +344,6 @@ class CreateView(generic.CreateView):
error_message = gettext_lazy("The image could not be created due to errors.")
template_name = "wagtailimages/images/add.html"
header_icon = "image"
_show_breadcrumbs = True
@cached_property
def model(self):

Wyświetl plik

@ -27,7 +27,6 @@ class AddView(WagtailAdminTemplateMixin, BaseAddView):
template_name = "wagtailimages/multiple/add.html"
header_icon = "image"
page_title = gettext_lazy("Add images")
_show_breadcrumbs = True
index_url_name = "wagtailimages:index"
edit_object_url_name = "wagtailimages:edit_multiple"