betodealmeida commented on a change in pull request #11755:
URL: 
https://github.com/apache/incubator-superset/pull/11755#discussion_r527253758



##########
File path: superset-frontend/src/SqlLab/components/ResultSet.tsx
##########
@@ -166,14 +194,126 @@ export default class ResultSet extends 
React.PureComponent<
     }
   }
 
+  handleOverwriteDatasetOption(data, option) {
+    this.setState({ datasetToOverwrite: option })
+  }
+
+  handleOverwriteDataset() {
+    const { sql, results } = this.props.query;
+    const { datasetToOverwrite } = this.state
+
+    // HACK: to clear the columns in the previous dataset and update
+    // it with the new selected columns from the query
+    // Todo: move this to actions file
+    SupersetClient.put({
+      endpoint: `api/v1/dataset/${datasetToOverwrite.dataSetId}`,
+      headers: { 'Content-Type': 'application/json' },
+      body: JSON.stringify({
+        columns: [],
+      }),
+    })
+      .then(d => {
+        console.log(d);
+      })
+      .catch(err => console.log(err));
+
+    SupersetClient.put({
+      endpoint: `api/v1/dataset/${datasetToOverwrite.dataSetId}`,
+      headers: { 'Content-Type': 'application/json' },
+      body: JSON.stringify({
+        sql,
+        columns: results.selected_columns.map(d => ({column_name: d.name}))
+      }),
+    }).then(d => {
+        console.log(d);
+      })
+      .catch(err => console.log(err));
+  }
+
+  handleSaveInDataset() {
+    // if user wants to overwrite a dataset we need to prompt them
+    if (this.state.saveDatasetRadioBtnState === 2) {

Review comment:
       What does 2 mean? Can we make it into an enum?




----------------------------------------------------------------
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:
[email protected]



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

Reply via email to