Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL Lab] Implement refetch results button properly #9220

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 36 additions & 16 deletions superset-frontend/src/SqlLab/components/ResultSet.jsx
Expand Up @@ -64,6 +64,11 @@ export default class ResultSet extends React.PureComponent {
showExploreResultsButton: false,
data: null,
};

this.changeSearch = this.changeSearch.bind(this);
this.fetchResults = this.fetchResults.bind(this);
this.popSelectStar = this.popSelectStar.bind(this);
this.reFetchQueryResults = this.reFetchQueryResults.bind(this);
this.toggleExploreResultsButton = this.toggleExploreResultsButton.bind(
this,
);
Expand Down Expand Up @@ -171,7 +176,7 @@ export default class ResultSet extends React.PureComponent {
{this.props.search && (
<input
type="text"
onChange={this.changeSearch.bind(this)}
onChange={this.changeSearch}
value={this.state.searchText}
className="form-control input-sm"
placeholder={t('Filter Results')}
Expand Down Expand Up @@ -219,7 +224,7 @@ export default class ResultSet extends React.PureComponent {
<Button
bsSize="small"
className="m-r-5"
onClick={this.popSelectStar.bind(this)}
onClick={this.popSelectStar}
>
{t('Query in a new tab')}
</Button>
Expand All @@ -240,7 +245,7 @@ export default class ResultSet extends React.PureComponent {
: [];
return (
<>
{this.renderControls.bind(this)()}
{this.renderControls()}
{sql}
<FilterableTable
data={data}
Expand All @@ -258,19 +263,34 @@ export default class ResultSet extends React.PureComponent {
}
}
if (query.cached || (query.state === 'success' && !query.results)) {
return (
<Button
bsSize="sm"
className="fetch"
bsStyle="primary"
onClick={this.reFetchQueryResults.bind(this, {
...query,
isDataPreview: true,
})}
>
{t('Fetch data preview')}
</Button>
);
if (query.isDataPreview) {
return (
<Button
bsSize="sm"
className="fetch"
bsStyle="primary"
onClick={() =>
this.reFetchQueryResults({
...query,
isDataPreview: true,
})
}
>
{t('Fetch data preview')}
</Button>
);
} else if (query.resultsKey) {
return (
<Button
bsSize="sm"
className="fetch"
bsStyle="primary"
onClick={() => this.fetchResults(query)}
>
{t('Refetch Results')}
</Button>
);
}
}
let progressBar;
let trackingUrl;
Expand Down