hughhhh commented on a change in pull request #5523: [sql lab] simplify the 
visualize flow
URL: 
https://github.com/apache/incubator-superset/pull/5523#discussion_r206782869
 
 

 ##########
 File path: superset/assets/src/SqlLab/components/ExploreResultsButton.jsx
 ##########
 @@ -0,0 +1,167 @@
+/* eslint no-undef: 2 */
+import moment from 'moment';
+import React from 'react';
+import PropTypes from 'prop-types';
+import { bindActionCreators } from 'redux';
+import { connect } from 'react-redux';
+import { Alert } from 'react-bootstrap';
+import Dialog from 'react-bootstrap-dialog';
+
+import shortid from 'shortid';
+import { exportChart } from '../../explore/exploreUtils';
+import * as actions from '../actions';
+import InfoTooltipWithTrigger from '../../components/InfoTooltipWithTrigger';
+import { t } from '../../locales';
+import Button from '../../components/Button';
+
+const propTypes = {
+  actions: PropTypes.object.isRequired,
+  query: PropTypes.object,
+  errorMessage: PropTypes.string,
+  timeout: PropTypes.number,
+  database: PropTypes.object.isRequired,
+};
+const defaultProps = {
+  query: {},
+};
+
+class ExploreResultsButton extends React.PureComponent {
+  constructor(props) {
+    super(props);
+    this.state = {
+      hints: [],
+    };
+    this.visualize = this.visualize.bind(this);
+    this.onClick = this.onClick.bind(this);
+  }
+  onClick() {
+    const timeout = this.props.timeout;
+    if (Math.round(this.getQueryDuration()) > timeout) {
+      this.dialog.show({
+        title: 'Explore',
+        body: this.renderTimeoutWarning(),
+        actions: [
+          Dialog.CancelAction(),
+          Dialog.OKAction(() => {
+            this.visualize();
+          }),
+        ],
+        bsSize: 'large',
+        onHide: (dialog) => {
+          dialog.hide();
+        },
+      });
+    } else {
+      this.visualize();
+    }
+  }
+  getColumns() {
+    const props = this.props;
+    if (props.query && props.query.results && props.query.results.columns) {
+      return props.query.results.columns;
+    }
+    return [];
+  }
+  getQueryDuration() {
+    return moment.duration(this.props.query.endDttm - 
this.props.query.startDttm).asSeconds();
+  }
+  datasourceName() {
+    const { query } = this.props;
+    const uniqueId = shortid.generate();
+    let datasourceName = uniqueId;
+    if (query) {
+      datasourceName = query.user ? `${query.user}-` : '';
+      datasourceName += `${query.tab}-${uniqueId}`;
+    }
+    return datasourceName;
+  }
+  buildVizOptions() {
+    const { schema, sql, dbId, templateParams } = this.props.query;
 
 Review comment:
   nit: 
   ```
   return {
       ...this.props.query,
       datasourceName: this.datasourceName(),
       columns: this.getColumns(),
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to