fix missing on_load parameter in custom_404 (#1541)

This commit is contained in:
Thomas Brandého 2023-08-10 20:21:45 +02:00 committed by GitHub
parent 5330bd01e0
commit cebc5982f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -404,11 +404,14 @@ class App(Base):
def add_custom_404_page( def add_custom_404_page(
self, self,
component, component: Optional[Union[Component, ComponentCallable]] = None,
title=None, title: str = constants.TITLE_404,
image=None, image: str = constants.FAVICON_404,
description=None, description: str = constants.DESCRIPTION_404,
meta=constants.DEFAULT_META_LIST, on_load: Optional[
Union[EventHandler, EventSpec, List[Union[EventHandler, EventSpec]]]
] = None,
meta: List[Dict] = constants.DEFAULT_META_LIST,
): ):
"""Define a custom 404 page for any url having no match. """Define a custom 404 page for any url having no match.
@ -420,25 +423,19 @@ class App(Base):
title: The title of the page. title: The title of the page.
description: The description of the page. description: The description of the page.
image: The image to display on the page. image: The image to display on the page.
on_load: The event handler(s) that will be called each time the page load.
meta: The metadata of the page. meta: The metadata of the page.
""" """
title = title or constants.TITLE_404 self.add_page(
image = image or constants.FAVICON_404 component=component if component else Fragment.create(),
description = description or constants.DESCRIPTION_404 route=constants.SLUG_404,
title=title or constants.TITLE_404,
component = component if isinstance(component, Component) else component() image=image or constants.FAVICON_404,
description=description or constants.DESCRIPTION_404,
compiler_utils.add_meta( on_load=on_load,
component,
title=title,
image=image,
description=description,
meta=meta, meta=meta,
) )
froute = format.format_route
self.pages[froute(constants.SLUG_404)] = component
def setup_admin_dash(self): def setup_admin_dash(self):
"""Setup the admin dash.""" """Setup the admin dash."""
# Get the config. # Get the config.