Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion reflex/components/core/banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from reflex.components.radix.themes.layout.flex import Flex
from reflex.components.radix.themes.typography.text import Text
from reflex.components.sonner.toast import ToastProps, toast_ref
from reflex.config import get_config
from reflex.constants import Dirs, Hooks, Imports
from reflex.constants.compiler import CompileVars
from reflex.environment import environment
Expand Down Expand Up @@ -100,9 +101,11 @@ def add_hooks(self) -> list[str | Var]:
"""
toast_id = "websocket-error"
target_url = WebsocketTargetURL.create()
config = get_config()
props = ToastProps(
description=LiteralVar.create(
f"Check if server is reachable at {target_url}",
config.connection_error_message
or f"Check if server is reachable at {target_url}"
),
close_button=True,
duration=120000,
Expand Down Expand Up @@ -135,6 +138,8 @@ def add_hooks(self) -> list[str | Var]:
else:
loading_message = Var.create(
f"Cannot connect to server: {connection_error}."
if not config.connection_error_message
else ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be connection error message?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would duplicate the error message. The connection error toast has two parts, title and description, but since I'm setting one error message in rxconfig I figured just pass the message in the title and leave the description empty.

)
toast_var = Var(
f"toast?.error({loading_message!s}, {{...toast_props, onDismiss: () => setUserDismissed(true)}},)"
Expand Down
3 changes: 3 additions & 0 deletions reflex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ class BaseConfig:

_prefixes: ClassVar[list[str]] = ["REFLEX_"]

# The message to display in the frontend when a connection error occurs.
connection_error_message: str | None = None


_PLUGINS_ENABLED_BY_DEFAULT = [
SitemapPlugin,
Expand Down