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 2020/08/04 18:19:30 UTC

[GitHub] [incubator-superset] nytai commented on a change in pull request #10510: feat: add favorite star to dashboard and chart lists

nytai commented on a change in pull request #10510:
URL: https://github.com/apache/incubator-superset/pull/10510#discussion_r465241504



##########
File path: superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx
##########
@@ -106,6 +110,61 @@ class DashboardList extends React.PureComponent<Props, State> {
   initialSort = [{ id: 'changed_on_delta_humanized', desc: true }];
 
   columns = [
+    {
+      Cell: ({ row: { original } }: any) => {
+        // TODO: return null if no user is logged in
+        const fetchFaveStar = (id: number) => {
+          SupersetClient.get({
+            endpoint: `${FAVESTAR_BASE_URL}/${id}/count/`,
+          })
+            .then(({ json }) => {
+              const faves = {
+                ...this.state.favoriteStatus,
+              };
+
+              faves[id] = json.count > 0;
+
+              this.setState({
+                favoriteStatus: faves,
+              });
+            })
+            .catch(() => {});

Review comment:
       let's handle this exception. Swallowed exceptions make debugging very difficult. There should be other examples of handling promise errors in this component.  




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