rusackas commented on code in PR #41352:
URL: https://github.com/apache/superset/pull/41352#discussion_r3545526663
##########
superset-frontend/src/explore/components/SaveModal.test.tsx:
##########
@@ -350,6 +350,27 @@ test('enables overwrite option for admin non-owner', () =>
{
expect(getByRole('radio', { name: 'Save (Overwrite)' })).toBeEnabled();
});
+test('enables overwrite option for owner when owners are objects', () => {
+ // The Slice type declares `owners: { id: number }[]`, and the explore
+ // bootstrap can deliver owners in object form. A chart owner must still be
+ // able to overwrite their own chart in that case.
Review Comment:
Slice.owners is number[] per src/types/Chart.ts — fixed the comment to say
that instead of claiming the type is object-shaped.
##########
superset-frontend/src/explore/components/SaveModal.tsx:
##########
@@ -227,14 +227,27 @@ const SaveModal = ({
const history = useHistory();
const theme = useTheme();
+ const isCurrentUserOwner = useCallback((): boolean => {
+ const userId = 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.
Review Comment:
Fair — SLICE_UPDATED actually normalizes owners to numeric ids before they
land in state.slice. Reworded to point at the API Owner shape instead of that
reducer path.
--
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]