mirror of
https://github.com/apache/superset.git
synced 2026-04-16 22:55:52 +00:00
[sql lab] Make sql editor resizable (#3242)
* Update to the version of react-ace with the fixed sizing issues * Make ace editor resizable * Use small util method for offset calculation instead of $ * Test ResizableAceEditor * Make the right pane of the Sql Lab scrollable * Add default and min height to the ResizableAceEditor * Implement SplitPane * Make Splitter fullscreen * React on resize of the window * Implement min and max * Get rid of a magic number + add margin * Handle resize event with delay + cleanup the code * Make ResultSet adjustable * Make QueryHistory adjustable * Remove ResizableAceEditor * Make linter happy * Test SplitPane * Init sizes properly
This commit is contained in:
committed by
Maxime Beauchemin
parent
6fc837db51
commit
75e69f02e8
@@ -15,14 +15,16 @@ import {
|
||||
|
||||
import Button from '../../components/Button';
|
||||
|
||||
import AceEditorWrapper from './AceEditorWrapper';
|
||||
import SouthPane from './SouthPane';
|
||||
import SplitPane from './SplitPane';
|
||||
import SaveQuery from './SaveQuery';
|
||||
import Timer from '../../components/Timer';
|
||||
import SqlEditorLeftBar from './SqlEditorLeftBar';
|
||||
import AceEditorWrapper from './AceEditorWrapper';
|
||||
import { STATE_BSSTYLE_MAP } from '../constants';
|
||||
import RunQueryActionButton from './RunQueryActionButton';
|
||||
|
||||
|
||||
const propTypes = {
|
||||
actions: PropTypes.object.isRequired,
|
||||
height: PropTypes.string.isRequired,
|
||||
@@ -49,6 +51,7 @@ class SqlEditor extends React.PureComponent {
|
||||
autorun: props.queryEditor.autorun,
|
||||
ctas: '',
|
||||
};
|
||||
this.onSizeChange = this.onSizeChange.bind(this);
|
||||
}
|
||||
componentDidMount() {
|
||||
this.onMount();
|
||||
@@ -60,6 +63,13 @@ class SqlEditor extends React.PureComponent {
|
||||
this.startQuery();
|
||||
}
|
||||
}
|
||||
onSizeChange(newSizes) {
|
||||
const bottomBarHeight = this.refs.editorBottomBar.clientHeight;
|
||||
this.setState({
|
||||
...this.state,
|
||||
editorHeight: newSizes.north - bottomBarHeight,
|
||||
});
|
||||
}
|
||||
setQueryEditorSql(sql) {
|
||||
this.props.actions.queryEditorSetSql(this.props.queryEditor, sql);
|
||||
}
|
||||
@@ -147,7 +157,7 @@ class SqlEditor extends React.PureComponent {
|
||||
);
|
||||
}
|
||||
const editorBottomBar = (
|
||||
<div className="sql-toolbar clearfix" id="js-sql-toolbar">
|
||||
<div ref="editorBottomBar" className="sql-toolbar clearfix" id="js-sql-toolbar">
|
||||
<div className="pull-left">
|
||||
<Form inline>
|
||||
<RunQueryActionButton
|
||||
@@ -212,21 +222,34 @@ class SqlEditor extends React.PureComponent {
|
||||
sm={this.props.hideLeftBar ? 12 : 7}
|
||||
md={this.props.hideLeftBar ? 12 : 8}
|
||||
lg={this.props.hideLeftBar ? 12 : 9}
|
||||
style={{
|
||||
height: this.sqlEditorHeight(),
|
||||
}}
|
||||
>
|
||||
<AceEditorWrapper
|
||||
actions={this.props.actions}
|
||||
onBlur={this.setQueryEditorSql.bind(this)}
|
||||
queryEditor={this.props.queryEditor}
|
||||
onAltEnter={this.runQuery.bind(this)}
|
||||
sql={this.props.queryEditor.sql}
|
||||
tables={this.props.tables}
|
||||
/>
|
||||
{editorBottomBar}
|
||||
<br />
|
||||
<SouthPane
|
||||
editorQueries={this.props.editorQueries}
|
||||
dataPreviewQueries={this.props.dataPreviewQueries}
|
||||
actions={this.props.actions}
|
||||
<SplitPane
|
||||
onSizeChange={this.onSizeChange}
|
||||
minHeight={25}
|
||||
north={
|
||||
<div>
|
||||
<AceEditorWrapper
|
||||
actions={this.props.actions}
|
||||
onBlur={this.setQueryEditorSql.bind(this)}
|
||||
queryEditor={this.props.queryEditor}
|
||||
onAltEnter={this.runQuery.bind(this)}
|
||||
sql={this.props.queryEditor.sql}
|
||||
tables={this.props.tables}
|
||||
height={this.state.editorHeight + 'px'}
|
||||
/>
|
||||
{editorBottomBar}
|
||||
</div>
|
||||
}
|
||||
south={
|
||||
<SouthPane
|
||||
editorQueries={this.props.editorQueries}
|
||||
dataPreviewQueries={this.props.dataPreviewQueries}
|
||||
actions={this.props.actions}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
Reference in New Issue
Block a user