Skip to content
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(alerts/reports): removing duplicate notification method options #27239

Merged
merged 2 commits into from
Apr 10, 2024

Conversation

fisjac
Copy link
Contributor

@fisjac fisjac commented Feb 23, 2024

SUMMARY

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

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

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

  • Has associated issue:
  • Required feature flags: "ALERT_REPORTS": True
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@fisjac fisjac force-pushed the ar-notification-settings-duplicate branch from fd19896 to 642b9d3 Compare February 23, 2024 21:47
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 61.53846% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 69.91%. Comparing base (349e496) to head (59f9cdb).
Report is 39 commits behind head on master.

Files Patch % Lines
...-frontend/src/features/alerts/AlertReportModal.tsx 58.33% 1 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #27239      +/-   ##
==========================================
+ Coverage   69.77%   69.91%   +0.13%     
==========================================
  Files        1911     1913       +2     
  Lines       75056    75698     +642     
  Branches     8362     8638     +276     
==========================================
+ Hits        52374    52923     +549     
- Misses      20630    20684      +54     
- Partials     2052     2091      +39     
Flag Coverage Δ
javascript 57.93% <61.53%> (+0.44%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

settings.pop();
setNotificationAddState('active');
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the pattern to use filter rather than slice and pop

@@ -498,9 +493,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
>([]);
const onNotificationAdd = () => {
const settings: NotificationSetting[] = notificationSettings.slice();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the pattern to use filter and reduce instead of slice

@geido
Copy link
Member

geido commented Feb 28, 2024

/testenv up FEATURE_ALERT_REPORTS=true

Copy link
Contributor

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

@geido geido self-requested a review March 19, 2024 18:12
@geido
Copy link
Member

geido commented Mar 26, 2024

Let's rebase this with master to unstuck CI

@fisjac fisjac force-pushed the ar-notification-settings-duplicate branch from 642b9d3 to 59f9cdb Compare March 27, 2024 04:21
@fisjac fisjac closed this Mar 28, 2024
@fisjac fisjac reopened this Mar 28, 2024
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @fisjac!

@eschutho
Copy link
Member

eschutho commented Apr 4, 2024

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

@fisjac fisjac force-pushed the ar-notification-settings-duplicate branch from 59f9cdb to 215e957 Compare April 9, 2024 15:07
@rusackas rusackas merged commit eb4ca01 into apache:master Apr 10, 2024
29 checks passed
@michael-s-molina michael-s-molina added the v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch label Apr 11, 2024
michael-s-molina pushed a commit that referenced this pull request Apr 16, 2024
@mistercrunch mistercrunch added 🍒 4.0.1 🍒 4.0.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch 🍒 4.0.1 🍒 4.0.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants