Files
superset2/caravel/assets/javascripts/SqlLab/components/App.jsx
Maxime Beauchemin 6fb3b305ad [sqllab] add support for results backends (#1377)
* [sqllab] add support for results backends

Long running SQL queries (beyond the scope of a web request) can now use
a k/v store to hold their result sets.

* Addressing comments, fixed js tests

* Fixing mysql has gone away

* Adressing more comments

* Touchups
2016-10-20 23:40:24 -07:00

76 lines
1.7 KiB
JavaScript

import * as Actions from '../actions';
import React from 'react';
import TabbedSqlEditors from './TabbedSqlEditors';
import QueryAutoRefresh from './QueryAutoRefresh';
import QuerySearch from './QuerySearch';
import Alerts from './Alerts';
import DataPreviewModal from './DataPreviewModal';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
hash: window.location.hash,
};
}
componentDidMount() {
window.addEventListener('hashchange', this.onHashChanged.bind(this));
}
componentWillUnmount() {
window.removeEventListener('hashchange', this.onHashChanged.bind(this));
}
onHashChanged() {
this.setState({ hash: window.location.hash });
}
render() {
let content;
if (this.state.hash) {
content = (
<div className="container-fluid">
<div className="row">
<div className="col-md-12">
<QuerySearch />
</div>
</div>
</div>
);
}
content = (
<div>
<QueryAutoRefresh />
<TabbedSqlEditors />
</div>
);
return (
<div className="App SqlLab">
<Alerts alerts={this.props.alerts} />
<DataPreviewModal />
<div className="container-fluid">
{content}
</div>
</div>
);
}
}
App.propTypes = {
alerts: React.PropTypes.array,
};
function mapStateToProps(state) {
return {
alerts: state.alerts,
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(Actions, dispatch),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(App);