betodealmeida commented on a change in pull request #11755:
URL:
https://github.com/apache/incubator-superset/pull/11755#discussion_r537757981
##########
File path: superset-frontend/src/SqlLab/components/ResultSet.tsx
##########
@@ -32,13 +36,33 @@ import FilterableTable from
'../../components/FilterableTable/FilterableTable';
import QueryStateLabel from './QueryStateLabel';
import CopyToClipboard from '../../components/CopyToClipboard';
import { prepareCopyToClipboardTabularData } from '../../utils/common';
+import { exploreChart } from '../../explore/exploreUtils';
import { CtasEnum } from '../actions/sqlLab';
import { Query } from '../types';
const SEARCH_HEIGHT = 46;
+const SAVE_NEW_DATASET_RADIO_STATE = 1;
+const OVERWRITE_DATASET_RADIO_STATE = 2;
Review comment:
Nit: it might be better to make this into an enum, since the constants
are related:
```javascript
enum DatasetRadioState {
SAVE_NEW = 1,
OVERWRITE_DATASET = 2,
};
```
##########
File path: superset-frontend/src/SqlLab/components/ResultSet.tsx
##########
@@ -87,6 +120,17 @@ export default class ResultSet extends React.PureComponent<
searchText: '',
showExploreResultsButton: false,
data: [],
+ showSaveDatasetModal: false,
+ newSaveDatasetName: `${props.query.tab} ${moment().format(
+ 'MM/DD/YYYY HH:mm:ss',
+ )}`,
Review comment:
One thought that occurred me: if the query has a name should we use it
to name the dataset?
##########
File path: superset-frontend/src/SqlLab/components/ResultSet.tsx
##########
@@ -96,11 +140,45 @@ export default class ResultSet extends React.PureComponent<
this.toggleExploreResultsButton = this.toggleExploreResultsButton.bind(
this,
);
+ this.handleSaveInDataset = this.handleSaveInDataset.bind(this);
+ this.handleHideSaveModal = this.handleHideSaveModal.bind(this);
+ this.handleDatasetNameChange = this.handleDatasetNameChange.bind(this);
+ this.handleSaveDatasetRadioBtnState =
this.handleSaveDatasetRadioBtnState.bind(
+ this,
+ );
+ this.handleOverwriteCancel = this.handleOverwriteCancel.bind(this);
+ this.handleOverwriteDataset = this.handleOverwriteDataset.bind(this);
+ this.handleOverwriteDatasetOption = this.handleOverwriteDatasetOption.bind(
+ this,
+ );
+ this.handleSaveDatasetModalSearch = this.handleSaveDatasetModalSearch.bind(
+ this,
+ );
+ this.handleFilterAutocompleteOption =
this.handleFilterAutocompleteOption.bind(
+ this,
+ );
+ this.handleOnChangeAutoComplete = this.handleOnChangeAutoComplete.bind(
+ this,
+ );
}
- componentDidMount() {
+ async componentDidMount() {
// only do this the first time the component is rendered/mounted
this.reRunQueryIfSessionTimeoutErrorOnMount();
+
+ const appContainer = document.getElementById('app');
+ const bootstrapData = JSON.parse(
+ appContainer?.getAttribute('data-bootstrap') || '{}',
+ );
+
+ const datasets = await getByUser(bootstrapData.user.userId);
+ const userDatasetsOwned = datasets.map(
+ (r: { table_name: string; id: number }) => {
+ return { datasetName: r.table_name, datasetId: r.id };
+ },
Review comment:
You can also do:
```javascript
(r: { table_name: string; id: number }) => (
{ datasetName: r.table_name, datasetId: r.id };
),
```
----------------------------------------------------------------
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]