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
9 changes: 8 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,13 @@ def add_hooks(self) -> list[str | Var]:
"""
toast_id = "websocket-error"
target_url = WebsocketTargetURL.create()
config = get_config()
is_dev_mode = environment.REFLEX_ENV_MODE.get().value == constants.Env.DEV
props = ToastProps(
description=LiteralVar.create(
f"Check if server is reachable at {target_url}",
f"Check if server is reachable at {target_url}"
if is_dev_mode or not config.connection_error_message
else config.connection_error_message
),
close_button=True,
duration=120000,
Expand Down Expand Up @@ -135,6 +140,8 @@ def add_hooks(self) -> list[str | Var]:
else:
loading_message = Var.create(
f"Cannot connect to server: {connection_error}."
if is_dev_mode or not config.connection_error_message
else ""
)
toast_var = Var(
f"toast?.error({loading_message!s}, {{...toast_props, onDismiss: () => setUserDismissed(true)}},)"
Expand Down
2 changes: 2 additions & 0 deletions reflex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ class BaseConfig:

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

connection_error_message: str | None = None


_PLUGINS_ENABLED_BY_DEFAULT = [
SitemapPlugin,
Expand Down