-
Notifications
You must be signed in to change notification settings - Fork 17.4k
fix: Disable Slack notification method if no api token #16367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,5 +21,5 @@ import { useSelector } from 'react-redux'; | |
| import { ViewState } from 'src/views/types'; | ||
|
|
||
| export function useCommonConf() { | ||
| return useSelector((state: ViewState) => state.common.conf); | ||
| return useSelector((state: ViewState) => state?.common?.conf); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did we need to add
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will break unit test |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,7 @@ | |
| SupersetSecurityException, | ||
| ) | ||
| from superset.models.helpers import ImportExportMixin | ||
| from superset.models.reports import ReportRecipientType | ||
| from superset.translations.utils import get_language_pack | ||
| from superset.typing import FlaskResponse | ||
| from superset.utils import core as utils | ||
|
|
@@ -346,9 +347,21 @@ def common_bootstrap_payload() -> Dict[str, Any]: | |
| messages = get_flashed_messages(with_categories=True) | ||
| locale = str(get_locale()) | ||
|
|
||
| # should not expose API TOKEN to frontend | ||
| frontend_config = {k: conf.get(k) for k in FRONTEND_CONF_KEYS} | ||
| if conf.get("SLACK_API_TOKEN"): | ||
| frontend_config["ALERT_REPORTS_NOTIFICATION_METHODS"] = [ | ||
| ReportRecipientType.EMAIL, | ||
| ReportRecipientType.SLACK, | ||
| ] | ||
| else: | ||
| frontend_config["ALERT_REPORTS_NOTIFICATION_METHODS"] = [ | ||
| ReportRecipientType.EMAIL, | ||
| ] | ||
|
Comment on lines
+353
to
+360
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does this need to live in the frontend config/bootstrap data? i'm not super familiar with the reports/alerts code, but it seems like they might call apis on load, which would mean we could just get this configuration via an api request instead of bundling it in the bootstrap data on every superset page.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this |
||
|
|
||
| bootstrap_data = { | ||
| "flash_messages": messages, | ||
| "conf": {k: conf.get(k) for k in FRONTEND_CONF_KEYS}, | ||
| "conf": frontend_config, | ||
| "locale": locale, | ||
| "language_pack": get_language_pack(locale), | ||
| "feature_flags": get_feature_flags(), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if changing the default is a breaking change, but since we should probably never hit this code path (can the page render without the config options actually here?) it's likely fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if system admin didn't set slack API token in config, user did saw Slack option before, but they can't see report in slack.