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(
self,
component,
title=None,
image=None,
description=None,
meta=constants.DEFAULT_META_LIST,
component: Optional[Union[Component, ComponentCallable]] = None,
title: str = constants.TITLE_404,
image: str = constants.FAVICON_404,
description: str = constants.DESCRIPTION_404,
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.
@ -420,25 +423,19 @@ class App(Base):
title: The title of the page.
description: The description of 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.
"""
title = title or constants.TITLE_404
image = image or constants.FAVICON_404
description = description or constants.DESCRIPTION_404
component = component if isinstance(component, Component) else component()
compiler_utils.add_meta(
component,
title=title,
image=image,
description=description,
self.add_page(
component=component if component else Fragment.create(),
route=constants.SLUG_404,
title=title or constants.TITLE_404,
image=image or constants.FAVICON_404,
description=description or constants.DESCRIPTION_404,
on_load=on_load,
meta=meta,
)
froute = format.format_route
self.pages[froute(constants.SLUG_404)] = component
def setup_admin_dash(self):
"""Setup the admin dash."""
# Get the config.