You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "justinpark (via GitHub)" <gi...@apache.org> on 2023/04/12 20:55:12 UTC

[GitHub] [superset] justinpark commented on a diff in pull request #23634: feat: Makes "Add to dashboard" in Save chart modal paginated

justinpark commented on code in PR #23634:
URL: https://github.com/apache/superset/pull/23634#discussion_r1164644543


##########
superset-frontend/src/explore/components/SaveModal.tsx:
##########
@@ -117,30 +116,20 @@ class SaveModal extends React.Component<SaveModalProps, SaveModalState> {
     );
   }
 
-  componentDidMount() {
-    this.props.actions.fetchDashboards(this.props.userId).then(() => {
-      if (ensureIsArray(this.props.dashboards).length === 0) {
-        return;
-      }
-      const dashboardIds = this.props.dashboards?.map(
-        dashboard => dashboard.value,
-      );
+  async componentDidMount() {
+    let { dashboardId } = this.props;
+    if (!dashboardId) {
       const lastDashboard = sessionStorage.getItem(SK_DASHBOARD_ID);
-      let recentDashboard = lastDashboard && parseInt(lastDashboard, 10);
-
-      if (this.props.dashboardId) {
-        recentDashboard = this.props.dashboardId;
-      }
-
-      if (
-        recentDashboard !== null &&
-        dashboardIds.indexOf(recentDashboard) !== -1
-      ) {
+      dashboardId = lastDashboard && parseInt(lastDashboard, 10);
+    }
+    if (dashboardId) {
+      const { result } = await this.loadDashboard(dashboardId);

Review Comment:
   It should be better to add the error message.
   
   ```suggestion
      try {
        const { result } = await this.loadDashboard(dashboardId);
        if (result) {
            ...
        }
        catch (e) {
          this.props.addDangerToast(t('An error occurred while loading dashboard information.'));
        }
   ```



-- 
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-unsubscribe@superset.apache.org

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