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 2022/02/02 19:01:00 UTC

[GitHub] [superset] ChristopherCFleming commented on a change in pull request #17939: refactor(ExploreCtasResultsButton): convert to functional component

ChristopherCFleming commented on a change in pull request #17939:
URL: https://github.com/apache/superset/pull/17939#discussion_r797929907



##########
File path: superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.jsx
##########
@@ -35,29 +35,24 @@ const propTypes = {
   templateParams: PropTypes.string,
 };
 
-class ExploreCtasResultsButton extends React.PureComponent {
-  constructor(props) {
-    super(props);
-    this.visualize = this.visualize.bind(this);
-    this.onClick = this.onClick.bind(this);
-  }
-
-  onClick() {
-    this.visualize();
-  }
-
-  buildVizOptions() {
-    return {
-      datasourceName: this.props.table,
-      schema: this.props.schema,
-      dbId: this.props.dbId,
-      templateParams: this.props.templateParams,
-    };
-  }
+function ExploreCtasResultsButton({
+  table,
+  schema,
+  dbId,
+  templateParams,
+  errorMessage,
+  actions,
+}) {
+  const { createCtasDatasource, addInfoToast, addDangerToast } = actions;
+  const buildVizOptions = {
+    datasourceName: table,
+    schema,
+    dbId,
+    templateParams,
+  };
 
-  visualize() {
-    this.props.actions
-      .createCtasDatasource(this.buildVizOptions())
+  const visualize = () => {
+    createCtasDatasource(buildVizOptions())

Review comment:
       Ah! Yes. We were thinking that since the original buildVizOptions just returns an object, why not just create that object, save it as a variable, then pass it as needed. Maybe I should have left it as a function?




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