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

   ### SUMMARY
   When a dashboard is saved with "Save as" and "Also copy (duplicate) existing 
charts" is checked, `DashboardDAO.copy_dashboard` maps the old chart ids to the 
new ones in the layout (and in the legacy `filter_scopes`). It does not do this 
for `native_filter_configuration`, so `scope.excluded` and `chartsInScope` on 
each native filter still point at the original dashboard's charts. The filters 
look fine right after saving because the client still has the right state, but 
once the copy is reopened they no longer apply to the duplicated charts.
   
   This adds the same remapping for native filters in the copy path, using 
`old_to_new_slice_ids`. Ids that aren't in the map are dropped, the same as 
`_remap_chart_ids` does on import (#26338 / #38171). I put it in a small helper 
because the importer's version can't be imported from the DAO (circular 
import), and doing it inline pushed `copy_dashboard` over the C901 limit. The 
plain copy path (without duplicating charts) is unchanged.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Backend only, no UI changes.
   
   ### TESTING INSTRUCTIONS
   1. Open a dashboard with a few charts and a native filter. In the filter's 
scoping, exclude one of the charts.
   2. Use "Save as", check "Also copy (duplicate) existing charts", and save 
under a new name.
   3. Open the new dashboard from the dashboard list (or reload the page) and 
apply the filter. It should affect the duplicated charts and still skip the 
excluded one.
   4. Optionally, check the copy's JSON metadata in Properties: 
`scope.excluded` and `chartsInScope` should hold the new chart ids, not the 
original ones.
   
   Unit test: `pytest tests/unit_tests/dao/dashboard_test.py -k native_filter`
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #44983
   - [ ] Required feature flags:
   - [ ] 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