You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/05/14 16:21:27 UTC

[GitHub] [superset] suddjian commented on a change in pull request #14626: fix(dashboard): check edit permissions correctly on frontend

suddjian commented on a change in pull request #14626:
URL: https://github.com/apache/superset/pull/14626#discussion_r632644723



##########
File path: superset-frontend/src/common/hooks/apiResources/dashboards.ts
##########
@@ -25,8 +25,9 @@ export const useDashboard = (idOrSlug: string | number) =>
     useApiV1Resource<Dashboard>(`/api/v1/dashboard/${idOrSlug}`),
     dashboard => ({
       ...dashboard,
-      metadata: JSON.parse(dashboard.json_metadata),
-      position_data: JSON.parse(dashboard.position_json),
+      metadata: dashboard.json_metadata && JSON.parse(dashboard.json_metadata),

Review comment:
       I assume you mean if the metadata is undefined (if the dashboard is undefined it will be a 404). I don't think it should be initialized like that, null is different from an empty object.
   
   This is not actually new behavior, I just had to write this guard to appease the type system since I corrected the types of some dashboard fields to be nullable.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org