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

Added cache prop to ResultSet #1552

Merged
merged 3 commits into from
Nov 7, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions caravel/assets/javascripts/SqlLab/components/ResultSet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const propTypes = {
searchText: React.PropTypes.string,
showSql: React.PropTypes.bool,
visualize: React.PropTypes.bool,
cache: React.PropTypes.bool,
};
const defaultProps = {
search: true,
Expand All @@ -22,6 +23,7 @@ const defaultProps = {
csv: true,
searchText: '',
actions: {},
cache: false,
};


Expand All @@ -36,7 +38,7 @@ class ResultSet extends React.PureComponent {
}
componentWillReceiveProps(nextProps) {
// when new results comes in, save them locally and clear in store
if ((!nextProps.query.cached)
if (this.props.cache && (!nextProps.query.cached)
&& nextProps.query.results
&& nextProps.query.results.data.length > 0) {
this.setState(
Expand Down Expand Up @@ -125,7 +127,8 @@ class ResultSet extends React.PureComponent {
}
render() {
const query = this.props.query;
const results = (this.props.query.cached) ? this.state.results : query.results;
const results =
(this.props.cache && this.props.query.cached) ? this.state.results : query.results;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit this.props.query.cached -> query.cached

let sql;

if (this.props.showSql) {
Expand Down
2 changes: 1 addition & 1 deletion caravel/assets/javascripts/SqlLab/components/SouthPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SouthPane extends React.PureComponent {
eventKey={query.id}
key={query.id}
>
<ResultSet query={query} visualize={false} csv={false} actions={props.actions} />
<ResultSet query={query} visualize={false} csv={false} actions={props.actions} cache />
</Tab>
));

Expand Down