You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "fisjac (via GitHub)" <gi...@apache.org> on 2024/02/23 21:14:08 UTC

[PR] fix(alerts/reports): removing duplicate notification method options [superset]

fisjac opened a new pull request, #27239:
URL: https://github.com/apache/superset/pull/27239

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   When adding notification methods to an alert or report, a user can select duplicate methods (select email twice or slack twice). This PR updates the behavior to exclude notification methods that are already being used.
   
   Additionally, the delete notification method for additional methods only appears after a user has selected a notification method. This PR changes this so that the ability to delete additional notification methods is always available, even if the method has not yet been selected.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   Before:
   https://www.loom.com/share/7bb024ba1d2a483eb6db44be6c137e32?sid=5620dc39-24aa-4165-8b12-39dddf6b48b5
   
   After:
   https://www.loom.com/share/c4c9c68f4f0446f18f5e4cbf1064d052?sid=3caccb4a-e2ec-4cd4-989e-d34ec31e6b7e
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   Ensure that within either your local superset_config.py or docker/pythonpath_dev/superset_config_docker.py files, you have a SLACK_API_TOKEN string filled in. It doesn't need to be an active api token, just any string.
   
   Open superset and navigate to the alerts and reports section.
   Create an alert or report and open the Notification method collapse section.
   Observe that there are two options for notification method.
   Add a new notification method.
   Check the options of the newly added notification method which should exclude the previously added option.
   
   Update the method of the first notification setting, and ensure that subsequent notification settings are being removed, and the add notification method button reappears.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [x] Required feature flags: "ALERT_REPORTS": True
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #27239:
URL: https://github.com/apache/superset/pull/27239


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #27239:
URL: https://github.com/apache/superset/pull/27239#issuecomment-1969484134

   /testenv up FEATURE_ALERT_REPORTS=true


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on PR #27239:
URL: https://github.com/apache/superset/pull/27239#issuecomment-2038449555

   @fisjac I think you're going to need to rebase to bring in the other required CI checks. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "fisjac (via GitHub)" <gi...@apache.org>.
fisjac commented on code in PR #27239:
URL: https://github.com/apache/superset/pull/27239#discussion_r1540441179


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -498,9 +493,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
   >([]);
   const onNotificationAdd = () => {
     const settings: NotificationSetting[] = notificationSettings.slice();

Review Comment:
   changed the pattern to use filter and reduce instead of slice



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #27239:
URL: https://github.com/apache/superset/pull/27239#issuecomment-2021153660

   Let's rebase this with master to unstuck CI


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27239:
URL: https://github.com/apache/superset/pull/27239#issuecomment-1969499874

   @geido Ephemeral environment spinning up at http://34.220.95.81:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "fisjac (via GitHub)" <gi...@apache.org>.
fisjac closed pull request #27239: fix(alerts/reports): removing duplicate notification method options
URL: https://github.com/apache/superset/pull/27239


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #27239:
URL: https://github.com/apache/superset/pull/27239#discussion_r1503487125


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -548,8 +550,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
     setting: NotificationSetting,
   ) => {
     const settings = notificationSettings.slice();
-
+    // if you've changed notification method
+    if (settings[index].method !== setting.method) {
+      // remove subsequent notification methods
+      while (settings.length - 1 > index) {
+        settings.pop();
+        setNotificationAddState('active');
+      }
+    }

Review Comment:
   as much as possible, I would recommend using array.map and filter for most of this logic instead of making copies of arrays and then adding and removing elements with slice, pop, etc.. It's ok to rewrite the existing patterns here. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27239:
URL: https://github.com/apache/superset/pull/27239#issuecomment-2025439867

   Ephemeral environment shutdown and build artifacts deleted.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #27239:
URL: https://github.com/apache/superset/pull/27239#issuecomment-1962070217

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/27239?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `55.55556%` with `4 lines` in your changes are missing coverage. Please review.
   > Project coverage is 67.33%. Comparing base [(`744f68d`)](https://app.codecov.io/gh/apache/superset/commit/744f68d63784cf90a200db134655147641cef12f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`642b9d3`)](https://app.codecov.io/gh/apache/superset/pull/27239?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 15 commits behind head on master.
   
   | [Files](https://app.codecov.io/gh/apache/superset/pull/27239?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...-frontend/src/features/alerts/AlertReportModal.tsx](https://app.codecov.io/gh/apache/superset/pull/27239?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2ZlYXR1cmVzL2FsZXJ0cy9BbGVydFJlcG9ydE1vZGFsLnRzeA==) | 50.00% | [2 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/superset/pull/27239?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #27239      +/-   ##
   ==========================================
   + Coverage   67.21%   67.33%   +0.11%     
   ==========================================
     Files        1905     1908       +3     
     Lines       74528    74452      -76     
     Branches     8337     8311      -26     
   ==========================================
   + Hits        50096    50130      +34     
   + Misses      22383    22267     -116     
   - Partials     2049     2055       +6     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/27239/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/27239/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.18% <55.55%> (+0.20%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/27239?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #27239:
URL: https://github.com/apache/superset/pull/27239#discussion_r1503489044


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -498,9 +493,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
   >([]);
   const onNotificationAdd = () => {
     const settings: NotificationSetting[] = notificationSettings.slice();

Review Comment:
   I know this is existing code, but since we're reusing this pattern, if we need to make a copy for immutability, I would suggest using destructuring over slice. But if you can use map and filter on notificationSettings, that would be all the better. And those methods also make a copy, so would still work as a pattern for keeping notificationSettings immutable if you needed it. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts/reports): removing duplicate notification method options [superset]

Posted by "fisjac (via GitHub)" <gi...@apache.org>.
fisjac commented on code in PR #27239:
URL: https://github.com/apache/superset/pull/27239#discussion_r1540440994


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -548,8 +550,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
     setting: NotificationSetting,
   ) => {
     const settings = notificationSettings.slice();
-
+    // if you've changed notification method
+    if (settings[index].method !== setting.method) {
+      // remove subsequent notification methods
+      while (settings.length - 1 > index) {
+        settings.pop();
+        setNotificationAddState('active');
+      }
+    }

Review Comment:
   Changed the pattern to use filter rather than slice and pop



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org