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

[query-search] fix scrolling on query search and pagination styling #2646

Merged
merged 4 commits into from
Apr 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 11 additions & 6 deletions superset/assets/javascripts/SqlLab/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class App extends React.PureComponent {
super(props);
this.state = {
hash: window.location.hash,
contentHeight: this.getHeight(),
contentHeight: '0px',
};
}
componentDidMount() {
Expand All @@ -32,11 +32,16 @@ class App extends React.PureComponent {
this.setState({ hash: window.location.hash });
}
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();
const warningEl = $('#navbar-warning');
Copy link
Member

Choose a reason for hiding this comment

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

[optional] would it make more sense to put most of this stuff in one div and look for the outerHeight of that div. Or maybe put a common CSS class on all of the and summing outerHeight over that simple selector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all of these elements wouldn't work in a single div. i think it makes more sense to be explicit about what elements we are including in this calculation, rather than a using single class to mark them in the templates.

const navTabsEl = $('.nav-tabs');
const searchHeaderEl = $('#search-header');
const alertEl = $('#sqllab-alerts');
const headerNavEl = $('header .navbar');
const navHeight = headerNavEl.outerHeight() + parseInt(headerNavEl.css('marginBottom'), 10);
const searchHeaderHeight = searchHeaderEl.outerHeight() + parseInt(searchHeaderEl.css('marginBottom'), 10);
const headerHeight = navTabsEl.outerHeight() ? navTabsEl.outerHeight() : searchHeaderHeight;
const warningHeight = warningEl.length > 0 ? warningEl.outerHeight() : 0;
const alertHeight = alertEl.length > 0 ? alertEl.outerHeight() : 0;
return `${window.innerHeight - navHeight - headerHeight - warningHeight - alertHeight}px`;
}
handleResize() {
Expand Down
12 changes: 6 additions & 6 deletions superset/assets/javascripts/SqlLab/components/QuerySearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const $ = window.$ = require('jquery');

const propTypes = {
actions: React.PropTypes.object.isRequired,
height: React.PropTypes.integer,
height: React.PropTypes.number.isRequired,
};

class QuerySearch extends React.PureComponent {
Expand Down Expand Up @@ -192,11 +192,11 @@ class QuerySearch extends React.PureComponent {
(<img className="loading" alt="Loading..." src="/static/assets/images/loading.gif" />)
:
(
<div
style={{ height: this.props.height }}
className="scrollbar-container"
>
<div className="scrollbar-content">
<div className="scrollbar-container">
<div
className="scrollbar-content"
style={{ height: this.props.height }}
>
<QueryTable
columns={[
'state', 'db', 'user', 'time',
Expand Down
5 changes: 3 additions & 2 deletions superset/assets/javascripts/SqlLab/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { initJQueryAjaxCSRF } from '../modules/utils';
import App from './components/App';
import { appSetup } from '../common';

require('./main.css');
require('../components/FilterableTable/FilterableTableStyles.css');
import './main.css';
import './reactable-pagination.css';
import '../components/FilterableTable/FilterableTableStyles.css';

appSetup();
initJQueryAjaxCSRF();
Expand Down
40 changes: 40 additions & 0 deletions superset/assets/javascripts/SqlLab/reactable-pagination.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.reactable-pagination td {
padding: 15px 0 0 0!important;
}
.reactable-pagination a:focus {
text-decoration: none;
color: #555555;
outline: 1;
}
.reactable-page-button,
.reactable-next-page,
.reactable-previous-page {
background: #fff;
border-radius: 2px;
border: 1px solid #b3b3b3;
color: #555555;
display: inline-block;
font-size: 12px;
line-height: 1.5;
margin-right: 5px;
padding: 5px 10px;
text-align: center;
text-decoration: none;
vertical-align: middle;
white-space: nowrap;
}
.reactable-current-page {
border: 1px solid #b3b3b3;
color: #555555;
font-weight: bold;
pointer-events: none;
opacity: 0.65;
}
.reactable-page-button:hover,
.reactable-next-page:hover,
.reactable-previous-page:hover {
background-color: #efefef;
border-color: #949494;
color: #555555;
text-decoration: none;
}