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

   ### SUMMARY
   After a page reload, the "Manage email report" menu on dashboards and charts 
always falls back to "Set up an email report" even when a report schedule 
already exists (#43344). The fetch does fire and `GET /api/v1/report/` returns 
the schedule, but the `SET_REPORT` reducer drops it: since the TypeScript 
migration in #37625 it matches results by `r.dashboard`/`r.chart`, while the 
list endpoint serializes the linked resource as `dashboard_id`/`chart_id` (see 
`list_columns` in `superset/reports/api.py`). The pre-migration JS reducer 
matched on `report[filterField]`, which is exactly those fields; this PR 
restores that behavior.
   
   The same failed match also took the stale-cleanup branch in the reducer, so 
toggling a schedule active (which refetches through `structureFetchAction`) 
wiped the report from the store and flipped the menu back to "Set up" without 
any reload involved.
   
   I also extended the `DELETE_REPORT` key derivation to understand the list 
shape, so a report stored from a fetch can be removed from the store when 
deleted.
   
   About the issue's diagnosis: the reporter traced this (impressively, from 
the minified 6.1.0 bundle) to the `usePrevious` fetch gate in 
`HeaderReportDropdown`. That gate is real code, but on a normal SPA load the 
user state hydrates synchronously from bootstrap, so the fetch fires and the 
trigger window isn't missed; what produces the symptom is the reducer dropping 
the response. I left the gate untouched to keep this change surgical.
   
   One pre-existing gap I'm deliberately not touching: the edit modal seeds its 
form from the stored report, and the list payload doesn't include 
`report_format`/`custom_width`, so editing a schedule after a reload falls back 
to the default format. That predates the TS migration (those fields were never 
in `list_columns`) and deserves its own change.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Coming shortly (before: menu stuck on "Set up an email report" after reload 
on a dashboard that already has a schedule; after: the manage entries with the 
active checkbox).
   
   ### TESTING INSTRUCTIONS
   1. Enable the `ALERT_REPORTS` feature flag, open a dashboard and use the ⋯ 
menu → "Manage email report" → "Set up an email report" to create a schedule.
   2. Reload the page and open the ⋯ menu again. Before this fix it shows "Set 
up an email report"; with it, you get "Email reports active", "Edit email 
report" and "Delete email report".
   3. Toggle "Email reports active" off and on. Before the fix the menu 
reverted to "Set up" after the refetch; now it stays on the manage entries with 
the checkbox reflecting the state.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue: Fixes #43344
   - [x] Required feature flags: `ALERT_REPORTS`
   - [ ] 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to