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/09/15 21:49:45 UTC

[GitHub] [incubator-superset] ktmud commented on a change in pull request #10836: feat: Stop pending queries when user close dashboard

ktmud commented on a change in pull request #10836:
URL: https://github.com/apache/incubator-superset/pull/10836#discussion_r488990858



##########
File path: superset-frontend/src/dashboard/components/Dashboard.jsx
##########
@@ -153,16 +151,30 @@ class Dashboard extends React.PureComponent {
     }
 
     if (hasUnsavedChanges) {
-      Dashboard.onBeforeUnload(true);
+      window.addEventListener('beforeunload', Dashboard.showUnsavedMessage);
+    } else {
+      window.removeEventListener('beforeunload', Dashboard.showUnsavedMessage);
+    }
+
+    if (this.canStopPendingQueries && isDashboardLoading(charts)) {
+      window.addEventListener('beforeunload', this.onStopPendingQueries);
     } else {
-      Dashboard.onBeforeUnload(false);
+      window.removeEventListener('beforeunload', this.onStopPendingQueries);
     }
   }
 
   componentWillUnmount() {
     window.removeEventListener('visibilitychange', this.onVisibilityChange);
   }
 
+  onStopPendingQueries() {

Review comment:
       I think it's the `beforeunload` event that triggers the `stopPendingQueries` action. So maybe we can just call this method `stopPendingQueries`?

##########
File path: superset/db_engine_specs/base.py
##########
@@ -1001,3 +1001,13 @@ def get_extra_params(database: "Database") -> Dict[str, Any]:
                 logger.error(ex)
                 raise ex
         return extra
+
+    @classmethod
+    def stop_queries(cls, username: str, dashboard_id: int) -> None:

Review comment:
       Can we name this `stop_dashboard_queries` since it accepts `dashboard_id` as a required parameter? Also, would `user_id` be better suited for this API than `username`?




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