fix: Grab datasets initially onMount (#13160)

This commit is contained in:
Hugh A. Miles II
2021-02-17 21:12:06 -05:00
committed by GitHub
parent ad4ca2223e
commit d48b894573

View File

@@ -159,9 +159,11 @@ export default class ResultSet extends React.PureComponent<
this.handleExploreBtnClick = this.handleExploreBtnClick.bind(this);
}
componentDidMount() {
async componentDidMount() {
// only do this the first time the component is rendered/mounted
this.reRunQueryIfSessionTimeoutErrorOnMount();
const userDatasetsOwned = await this.getUserDatasets();
this.setState({ userDatasetOptions: userDatasetsOwned });
}
UNSAFE_componentWillReceiveProps(nextProps: ResultSetProps) {
@@ -296,7 +298,7 @@ export default class ResultSet extends React.PureComponent<
});
};
handleSaveDatasetModalSearch = async (searchText: string) => {
getUserDatasets = async (searchText = '') => {
// Making sure that autocomplete input has a value before rendering the dropdown
// Transforming the userDatasetsOwned data for SaveModalComponent)
const appContainer = document.getElementById('app');
@@ -327,15 +329,18 @@ export default class ResultSet extends React.PureComponent<
endpoint: '/api/v1/dataset',
})(`q=${queryParams}`);
const userDatasetsOwned = response.result.map(
(r: { table_name: string; id: number }) => ({
value: r.table_name,
datasetId: r.id,
}),
);
this.setState({ userDatasetOptions: userDatasetsOwned });
return response.result.map((r: { table_name: string; id: number }) => ({
value: r.table_name,
datasetId: r.id,
}));
}
return null;
};
handleSaveDatasetModalSearch = async (searchText: string) => {
const userDatasetsOwned = await this.getUserDatasets(searchText);
this.setState({ userDatasetOptions: userDatasetsOwned });
};
handleFilterAutocompleteOption = (