Skip to content

Commit

Permalink
Added scroll bar and option to collapse for Sql Editor tool bar (#1532)
Browse files Browse the repository at this point in the history
* Added scroll bar and option to collapse for Sql Editor tool bar
Done:
 - Added scroll-bar to Sql Editor tool bar
 - Added hide/expand tool bar option to dropdown menu of tab

* Add more margin to give space to scroll-bar

* Add scroll to right panel independently
  • Loading branch information
vera-liu authored Nov 4, 2016
1 parent 69f0a4e commit 593ac08
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 24 deletions.
55 changes: 32 additions & 23 deletions caravel/assets/javascripts/SqlLab/components/SqlEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
OverlayTrigger,
Row,
Tooltip,
Collapse,
} from 'react-bootstrap';

import SouthPane from './SouthPane';
Expand All @@ -28,12 +29,14 @@ const propTypes = {
editorQueries: React.PropTypes.array.isRequired,
dataPreviewQueries: React.PropTypes.array.isRequired,
queryEditor: React.PropTypes.object.isRequired,
hideLeftBar: React.PropTypes.bool,
};

const defaultProps = {
networkOn: true,
database: null,
latestQuery: null,
hideLeftBar: false,
};


Expand Down Expand Up @@ -207,29 +210,35 @@ class SqlEditor extends React.PureComponent {
return (
<div className="SqlEditor" style={{ minHeight: this.sqlEditorHeight() }}>
<Row>
<Col md={3}>
<SqlEditorLeftBar
queryEditor={this.props.queryEditor}
tables={this.props.tables}
networkOn={this.props.networkOn}
actions={this.props.actions}
/>
</Col>
<Col md={9}>
<AceEditorWrapper
tables={this.props.tables}
actions={this.props.actions}
queryEditor={this.props.queryEditor}
sql={this.props.queryEditor.sql}
onBlur={this.setQueryEditorSql.bind(this)}
/>
{editorBottomBar}
<br />
<SouthPane
editorQueries={this.props.editorQueries}
dataPreviewQueries={this.props.dataPreviewQueries}
actions={this.props.actions}
/>
<Collapse
in={!this.props.hideLeftBar}
>
<Col md={3}>
<SqlEditorLeftBar
queryEditor={this.props.queryEditor}
tables={this.props.tables}
networkOn={this.props.networkOn}
actions={this.props.actions}
/>
</Col>
</Collapse>
<Col md={this.props.hideLeftBar ? 12 : 9}>
<div className="scrollbar">
<AceEditorWrapper
tables={this.props.tables}
actions={this.props.actions}
queryEditor={this.props.queryEditor}
sql={this.props.queryEditor.sql}
onBlur={this.setQueryEditorSql.bind(this)}
/>
{editorBottomBar}
<br />
<SouthPane
editorQueries={this.props.editorQueries}
dataPreviewQueries={this.props.dataPreviewQueries}
actions={this.props.actions}
/>
</div>
</Col>
</Row>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class SqlEditorLeftBar extends React.PureComponent {
}
const shouldShowReset = window.location.search === '?reset=1';
return (
<div className="clearfix sql-toolbar">
<div className="clearfix sql-toolbar scrollbar">
{networkAlert}
<div>
<DatabaseSelect
Expand Down
10 changes: 10 additions & 0 deletions caravel/assets/javascripts/SqlLab/components/TabbedSqlEditors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class TabbedSqlEditors extends React.PureComponent {
cleanUri,
query,
queriesArray: [],
hideLeftBar: false,
};
}
componentWillMount() {
Expand Down Expand Up @@ -105,6 +106,9 @@ class TabbedSqlEditors extends React.PureComponent {
removeQueryEditor(qe) {
this.props.actions.removeQueryEditor(qe);
}
toggleLeftBar() {
this.setState({ hideLeftBar: !this.state.hideLeftBar });
}
render() {
const editors = this.props.queryEditors.map((qe, i) => {
const isSelected = (qe.id === this.activeQueryEditor().id);
Expand Down Expand Up @@ -146,6 +150,11 @@ class TabbedSqlEditors extends React.PureComponent {
<i className="fa fa-clipboard" /> <CopyQueryTabUrl queryEditor={qe} />
</MenuItem>
}
<MenuItem eventKey="4" onClick={this.toggleLeftBar.bind(this)}>
<i className="fa fa-cogs" />
&nbsp;
{this.state.hideLeftBar ? 'expand tool bar' : 'hide tool bar'}
</MenuItem>
</DropdownButton>
</div>
);
Expand All @@ -167,6 +176,7 @@ class TabbedSqlEditors extends React.PureComponent {
database={database}
actions={this.props.actions}
networkOn={this.props.networkOn}
hideLeftBar={this.state.hideLeftBar}
/>
}
</div>
Expand Down
12 changes: 12 additions & 0 deletions caravel/assets/javascripts/SqlLab/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
padding-top: 5px;
padding-bottom: 5px;
}

.scrollbar {
position: relative;
width: 100%;
overflow-y: auto;
height: 100%;
}

.Workspace .btn-sm {
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
margin-top: 2px;
Expand Down Expand Up @@ -233,6 +241,10 @@ div.tablePopover:hover {
padding-top: 10px;
}

.TableElement {
margin-right: 10px;
}

.TableElement .well {
margin-top: 5px;
margin-bottom: 5px;
Expand Down

0 comments on commit 593ac08

Please sign in to comment.