-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
fix: Disable Slack notification method if no api token #16367
fix: Disable Slack notification method if no api token #16367
Conversation
Codecov Report
@@ Coverage Diff @@
## master #16367 +/- ##
==========================================
- Coverage 76.53% 76.31% -0.23%
==========================================
Files 1000 1000
Lines 53500 53511 +11
Branches 6814 6818 +4
==========================================
- Hits 40946 40836 -110
- Misses 12316 12436 +120
- Partials 238 239 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
d6890ef
to
3788e46
Compare
superset/config.py
Outdated
@@ -994,6 +994,8 @@ def CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC( | |||
# If set to true no notification is sent, the worker will just log a message. | |||
# Useful for debugging | |||
ALERT_REPORTS_NOTIFICATION_DRY_RUN = False | |||
# Allowed notification methods: Email, Slack | |||
ALERT_REPORTS_ALERTS_NOTIFICATION_METHODS = ["Email", "Slack"] |
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.
@graceguo-supercat I think it would be preferable to reuse this enum. Also what happens if you make this an empty list?
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.
I agree with John, should we disable the feature if the list is empty?
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.
Based on the new implementation, we will always has 'Email' option, so i don't handle empty case here.
Alternatively, we can show the Slack option only if |
a92cdd9
to
a07c7ec
Compare
8c655f7
to
959f573
Compare
I actually think this is a good idea:
|
959f573
to
10ad1fd
Compare
4e6edb9
to
b2c5901
Compare
ping @betodealmeida and @john-bodley in last 24 ours i have to resolve conflicts twice. please take a look. |
b2c5901
to
d2179a0
Compare
d2179a0
to
5eab082
Compare
frontend_config["ALERT_REPORTS_NOTIFICATION_METHODS"] = [ | ||
ReportRecipientType.EMAIL, | ||
ReportRecipientType.SLACK, | ||
] | ||
else: | ||
frontend_config["ALERT_REPORTS_NOTIFICATION_METHODS"] = [ | ||
ReportRecipientType.EMAIL, | ||
] |
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.
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.
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.
this bootstrap_data
is used by all entry point, includes spa.html. I think populate it with configs not a bad idea.
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.
stamping with a couple nits.
One question i had while looking through this code @dpgaspar was why we couldn't get the possible options for the crud view from the validator in FAB? It seems like we don't do that today, likely because we wouldn't have the validator when creating a new object, but maybe we should consider unifying the validator logic with the logic that generates options for selectors, that way we can only have one source of truth for all these configs
@@ -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); |
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.
why did we need to add ?
here? seems like it worked fine before?
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.
it will break unit test AlertReportModal.test.jsx
: it didn't read conf before this PR.
@@ -397,6 +397,10 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({ | |||
alert = null, | |||
isReport = false, | |||
}) => { | |||
const conf = useCommonConf(); | |||
const allowedNotificationMethods = |
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.
should we cast this as NotificationMethodOption[]
here so that we don't need to cast it multiple times below?
@@ -78,7 +80,7 @@ interface AlertReportModalProps { | |||
show: boolean; | |||
} | |||
|
|||
const NOTIFICATION_METHODS: NotificationMethod[] = ['Email', 'Slack']; | |||
const DEFAULT_NOTIFICATION_METHODS: NotificationMethodOption[] = ['Email']; |
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.
8a60d5f
to
ac5a3ad
Compare
* upstream/master: (25 commits) chore(ci): bump pylint to 2.10.2 (apache#16463) fix: prevent page crash when chart can't render (apache#16464) chore: fixed slack invite link (apache#16466) fix(native-filters): handle null values in value filter (apache#16460) feat: add function list to auto-complete to Clickhouse datasource (apache#16234) refactor(explore): improve typing for Dnd controls (apache#16362) fix(explore): update overwrite button on perm change (apache#16437) feat: Draggable and Resizable Modal (apache#16394) refactor: sql_json view endpoint (apache#16441) fix(dashboard): undo and redo buttons weird alignment (apache#16417) fix: setupPlugin in chart list page (apache#16413) fix: Disable Slack notification method if no api token (apache#16367) feat: add Shillelagh DB engine spec (apache#16416) fix: copy to Clipboard order (apache#16299) docs: make FEATURE_FLAGS.md reference a link (apache#16415) chore(viz): bump superset-ui to 0.17.87 (apache#16420) feat: add activate command (apache#16404) Revert "fix(explore): let admin overwrite slice (apache#16290)" (apache#16408) fix(explore): retain chart ownership on query context update (apache#16419) chore: Removes the TODOs and uses the default page size (apache#16422) ...
* feat: allow company choose alert/report notification methods * fix: disable Slack as notification method if no api token * fix unit test * improve typing
* feat: allow company choose alert/report notification methods * fix: disable Slack as notification method if no api token * fix unit test * improve typing
SUMMARY
If system admin did not set
SLACK_API_TOKEN
config, we should not showSlack
as notification method.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
CI and manual test
ADDITIONAL INFORMATION
cc @john-bodley @m-ajay @betodealmeida