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

   ### SUMMARY
   
   Follow-up promised in #39118: the `can_export_data` switch for dashboard 
downloads, split out so the permission change can be discussed on its own, and 
this time with the `can_csv` fallback @rusackas asked for.
   
   `superset_can_download` in dashboard hydration now respects 
`GranularExportControls`:
   
   | Flag | can_csv only | can_export_data only | both | neither |
   |------|--------------|----------------------|------|---------|
   | off  | download     | no download          | download | no download |
   | on   | download     | download             | download | no download |
   
   Flag off is byte-for-byte today's behavior. Flag on checks `can_export_data` 
but keeps `can_csv` as a fallback, so enabling the flag never silently removes 
a download button a user already had. That is the breaking scenario 
@sadpandajoe flagged on the original attempt (permissions set up manually, 
migration not run), and the reason the earlier version of this change carried 
`risk:breaking-change`. With the fallback there is no way to lose access by 
turning the flag on, only ways to gain it.
   
   The logic lives in a small `canDownloadData` helper next to `findPermission` 
rather than inline in `hydrate.ts`. One thing worth a maintainer opinion: 
`hydrateExplore.ts` and the `usePermissions` hook currently use a hard switch 
(no `can_csv` fallback when the flag is on), so with this change dashboards 
become the more forgiving path. If the fallback is wanted everywhere, both call 
sites can move to this helper in a follow-up; if the hard switch is the 
intended end state, the fallback here can be treated as a migration bridge. 
Happy to do either.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   No visual change. The download menu item's visibility follows the table 
above.
   
   ### TESTING INSTRUCTIONS
   
   Unit tests cover the permission matrix in 
`superset-frontend/src/utils/findPermission.test.ts` (six cases across flag 
on/off).
   
   Manual: enable `GranularExportControls`, then on a dashboard chart's context 
menu:
   1. Role with `can_csv` only: Download is still there (the fallback).
   2. Role with `can_export_data` only: Download appears.
   3. Neither permission: no Download.
   4. Flag disabled: `can_csv` alone decides, as today.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [x] Required feature flags: `GranularExportControls` (behavior only 
changes when it is enabled)
   - [ ] 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