diff --git a/superset/assets/javascripts/SqlLab/components/App.jsx b/superset/assets/javascripts/SqlLab/components/App.jsx index 7eba77fd5a..32bc709bbf 100644 --- a/superset/assets/javascripts/SqlLab/components/App.jsx +++ b/superset/assets/javascripts/SqlLab/components/App.jsx @@ -1,3 +1,4 @@ +const $ = window.$ = require('jquery'); import * as Actions from '../actions'; import React from 'react'; @@ -14,13 +15,29 @@ class App extends React.PureComponent { super(props); this.state = { hash: window.location.hash, + contentHeight: this.getHeight(), }; } componentDidMount() { + /* eslint-disable react/no-did-mount-set-state */ + this.setState({ contentHeight: this.getHeight() }); window.addEventListener('hashchange', this.onHashChanged.bind(this)); + window.addEventListener('resize', this.handleResize.bind(this)); } componentWillUnmount() { window.removeEventListener('hashchange', this.onHashChanged.bind(this)); + window.removeEventListener('resize', this.handleResize.bind(this)); + } + getHeight() { + const navHeight = 90; + const headerHeight = $('.nav-tabs').outerHeight() ? + $('.nav-tabs').outerHeight() : $('#search-header').outerHeight(); + const warningHeight = $('#navbar-warning').outerHeight(); + const alertHeight = $('#sqllab-alerts').outerHeight(); + return `${window.innerHeight - navHeight - headerHeight - warningHeight - alertHeight}px`; + } + handleResize() { + this.setState({ contentHeight: this.getHeight() }); } onHashChanged() { this.setState({ hash: window.location.hash }); @@ -32,7 +49,7 @@ class App extends React.PureComponent {
- +
@@ -41,13 +58,13 @@ class App extends React.PureComponent { content = (
- +
); } return (
- +
{content}
diff --git a/superset/assets/javascripts/SqlLab/components/QuerySearch.jsx b/superset/assets/javascripts/SqlLab/components/QuerySearch.jsx index 1fd81185ca..2ed9253a81 100644 --- a/superset/assets/javascripts/SqlLab/components/QuerySearch.jsx +++ b/superset/assets/javascripts/SqlLab/components/QuerySearch.jsx @@ -127,7 +127,7 @@ class QuerySearch extends React.PureComponent { render() { return (
-
+