Skip to content

Commit

Permalink
fix(bootstrap-data): always check flashes (#22659)
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Jan 10, 2023
1 parent 0b22287 commit 73e53fa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,12 @@ def menu_data(user: User) -> Dict[str, Any]:


@cache_manager.cache.memoize(timeout=60)
def common_bootstrap_payload(user: User) -> Dict[str, Any]:
def cached_common_bootstrap_data(user: User) -> Dict[str, Any]:
"""Common data always sent to the client
The function is memoized as the return value only changes based
on configuration and feature flag values.
The function is memoized as the return value only changes when user permissions
or configuration values change.
"""
messages = get_flashed_messages(with_categories=True)
locale = str(get_locale())

# should not expose API TOKEN to frontend
Expand All @@ -418,7 +417,6 @@ def common_bootstrap_payload(user: User) -> Dict[str, Any]:
frontend_config["HAS_GSHEETS_INSTALLED"] = bool(available_specs[GSheetsEngineSpec])

bootstrap_data = {
"flash_messages": messages,
"conf": frontend_config,
"locale": locale,
"language_pack": get_language_pack(locale),
Expand All @@ -432,6 +430,13 @@ def common_bootstrap_payload(user: User) -> Dict[str, Any]:
return bootstrap_data


def common_bootstrap_payload(user: User) -> Dict[str, Any]:
return {
**(cached_common_bootstrap_data(user)),
"flash_messages": get_flashed_messages(with_categories=True),
}


def get_error_level_from_status_code( # pylint: disable=invalid-name
status: int,
) -> ErrorLevel:
Expand Down

0 comments on commit 73e53fa

Please sign in to comment.