kgabryje commented on code in PR #20448: URL: https://github.com/apache/superset/pull/20448#discussion_r903722450
########## superset-frontend/src/explore/reducers/getInitialState.ts: ########## @@ -52,40 +61,49 @@ export interface ExplorePageBootstrapData extends JsonObject { export default function getInitialState( bootstrapData: ExplorePageBootstrapData, ) { - const { form_data: initialFormData } = bootstrapData; - const { slice } = bootstrapData; - const sliceName = slice ? slice.slice_name : null; + const { + form_data: initialFormData, + common, + user, + datasource, + slice, + } = bootstrapData; const exploreState = { // note this will add `form_data` to state, // which will be manipulatable by future reducers. - ...bootstrapData, - sliceName, - common: { - flash_messages: bootstrapData.common.flash_messages, - conf: bootstrapData.common.conf, - }, + can_add: findPermission('can_write', 'Chart', user?.roles), + can_download: findPermission('can_csv', 'Superset', user?.roles), + can_overwrite: ensureIsArray(slice?.owners).includes( + user?.userId as number, Review Comment: Yeah that's the point - array of owners won't include `undefined` so user who's not logged in won't have `overwrite` permission. If we defaulted to 0, there's a small chance that there's an actual user with id 0 and we'd allow anonymous user to overwrite that user's charts 🙂 -- 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: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org