rusackas commented on code in PR #41352:
URL: https://github.com/apache/superset/pull/41352#discussion_r3464607499


##########
superset-frontend/src/explore/components/SaveModal.tsx:
##########
@@ -132,15 +132,29 @@ class SaveModal extends Component<SaveModalProps, 
SaveModalState> {
     return typeof dashboard?.value === 'string';
   }
 
-  canOverwriteSlice(): boolean {
-    return (
-      (this.props.can_overwrite ||
-        isUserAdmin(this.props.user) ||
-        this.props.slice?.owners?.includes(this.props.user.userId)) &&
-      !this.props.slice?.is_managed_externally
+  isCurrentUserOwner(): boolean {
+    const userId = this.props.user?.userId;
+    if (userId === undefined) {
+      return false;
+    }
+    // Owners can arrive either as plain ids (number) or as objects depending 
on
+    // where the slice was hydrated from (bootstrap vs. SLICE_UPDATED reducer),
+    // so normalize to the numeric id before comparing.
+    return Boolean(
+      this.props.slice?.owners?.some((owner: number | { id?: number }) =>
+        typeof owner === 'number' ? owner === userId : owner?.id === userId,
+      ),
     );
   }
 
+  canOverwriteSlice(): boolean {
+    const canEdit =
+      this.props.can_overwrite ||
+      isUserAdmin(this.props.user) ||
+      this.isCurrentUserOwner();
+    return canEdit && !this.props.slice?.is_managed_externally;

Review Comment:
   The admin/`can_overwrite` branches here are untouched by this PR, which only 
normalizes owner matching... so this null-slice-overwrite path predates it. 
Worth a separate fix if it actually bites, but out of scope for this one.



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