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

   ### SUMMARY
   
   The Save chart modal disables **Save (Overwrite)** for users who actually 
own the chart, forcing them into **Save as...**. That's the path behind the 
duplicate/stale-chart mess in #38911.
   
   `canOverwriteSlice()` was checking `slice.owners.includes(user.userId)`. But 
`Slice.owners` is typed as `{ id: number }[]`, and the Explore bootstrap can 
hand us owners in object form — so `includes()` against a numeric `userId` 
never matches. Admins squeaked by on the `isUserAdmin` branch, but plain owners 
didn't, which is exactly the reporter's scenario.
   
   Fix is just to normalize the owner id before comparing, so it works whether 
owners arrive as plain ids or as `{ id }` objects. Pulled the check out into a 
little `isCurrentUserOwner()` helper to keep `canOverwriteSlice()` readable.
   
   ### TESTING INSTRUCTIONS
   
   1. As a non-admin user who owns a chart, open it in Explore and tweak 
something (e.g. a description).
   2. Hit Save — **Save (Overwrite)** should be enabled and selected by default 
rather than disabled.
   
   Also added a unit test that pins the object-shaped-owners case (it fails on 
master, passes here).
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #38911
   - [x] Changes UI


-- 
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