Skip to content

Commit

Permalink
fix(alerts&reports): tabs with userfriendly urls (apache#31350)
Browse files Browse the repository at this point in the history
Co-authored-by: Erkka Tahvanainen <[email protected]>
  • Loading branch information
tahvane1 and Erkka Tahvanainen authored Dec 9, 2024
1 parent b54a97b commit 3bfead6
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions superset/commands/report/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def _get_url(
if (
dashboard_state := self._report_schedule.extra.get("dashboard")
) and feature_flag_manager.is_feature_enabled("ALERT_REPORT_TABS"):
return self._get_tab_url(dashboard_state)
return self._get_tab_url(dashboard_state, user_friendly=user_friendly)

dashboard = self._report_schedule.dashboard
dashboard_id_or_slug = (
Expand All @@ -234,7 +234,7 @@ def get_dashboard_urls(
if anchor := dashboard_state.get("anchor"):
try:
anchor_list: list[str] = json.loads(anchor)
return self._get_tabs_urls(anchor_list)
return self._get_tabs_urls(anchor_list, user_friendly=user_friendly)
except json.JSONDecodeError:
logger.debug("Anchor value is not a list, Fall back to single tab")
return [self._get_tab_url(dashboard_state)]
Expand All @@ -254,17 +254,25 @@ def get_dashboard_urls(
)
]

def _get_tab_url(self, dashboard_state: DashboardPermalinkState) -> str:
def _get_tab_url(
self, dashboard_state: DashboardPermalinkState, user_friendly: bool = False
) -> str:
"""
Get one tab url
"""
permalink_key = CreateDashboardPermalinkCommand(
dashboard_id=str(self._report_schedule.dashboard.uuid),
state=dashboard_state,
).run()
return get_url_path("Superset.dashboard_permalink", key=permalink_key)
return get_url_path(
"Superset.dashboard_permalink",
key=permalink_key,
user_friendly=user_friendly,
)

def _get_tabs_urls(self, tab_anchors: list[str]) -> list[str]:
def _get_tabs_urls(
self, tab_anchors: list[str], user_friendly: bool = False
) -> list[str]:
"""
Get multple tabs urls
"""
Expand All @@ -275,7 +283,8 @@ def _get_tabs_urls(self, tab_anchors: list[str]) -> list[str]:
"dataMask": None,
"activeTabs": None,
"urlParams": None,
}
},
user_friendly=user_friendly,
)
for tab_anchor in tab_anchors
]
Expand Down

0 comments on commit 3bfead6

Please sign in to comment.