bito-code-review[bot] commented on PR #41352:
URL: https://github.com/apache/superset/pull/41352#issuecomment-4785732205
<!-- Bito Reply -->
The flagged issue is correct. The `canOverwriteSlice()` method currently
evaluates to `true` for admins even when `this.props.slice` is `null` (a new
chart), which leads to a runtime error when `saveOrOverwrite()` attempts to
destructure `slice_id` from an undefined object. To resolve this, you should
add a check to ensure `this.props.slice` exists before allowing an overwrite.
Here is the corrected implementation for `canOverwriteSlice` in
`superset-frontend/src/explore/components/SaveModal.tsx`:
```typescript
canOverwriteSlice(): boolean {
const canEdit =
this.props.can_overwrite ||
isUserAdmin(this.props.user) ||
this.isCurrentUserOwner();
return !!this.props.slice && canEdit &&
!this.props.slice?.is_managed_externally;
}
```
There are no other review comments in this pull request to address.
**superset-frontend/src/explore/components/SaveModal.tsx**
```
canOverwriteSlice(): boolean {
const canEdit =
this.props.can_overwrite ||
isUserAdmin(this.props.user) ||
this.isCurrentUserOwner();
return !!this.props.slice && canEdit &&
!this.props.slice?.is_managed_externally;
}
```
--
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]