Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
[Revert] Allow resizing width of SQL Lab left bar / editor apache#8099
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace Guo committed Aug 29, 2019
1 parent 56566c2 commit 47e588b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 74 deletions.
7 changes: 0 additions & 7 deletions superset/assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions superset/assets/spec/javascripts/sqllab/SqlEditor_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { shallow } from 'enzyme';

import { defaultQueryEditor, initialState, queries, table } from './fixtures';
import {
SQL_EDITOR_VERTICAL_GUTTER_HEIGHT,
SQL_EDITOR_VERTICAL_GUTTER_MARGIN,
SQL_EDITOR_GUTTER_HEIGHT,
SQL_EDITOR_GUTTER_MARGIN,
SQL_TOOLBAR_HEIGHT,
} from '../../../src/SqlLab/constants';
import AceEditorWrapper from '../../../src/SqlLab/components/AceEditorWrapper';
Expand Down Expand Up @@ -73,8 +73,8 @@ describe('SqlEditor', () => {
const totalSize = parseFloat(wrapper.find(AceEditorWrapper).props().height)
+ wrapper.find(SouthPane).props().height
+ SQL_TOOLBAR_HEIGHT
+ (SQL_EDITOR_VERTICAL_GUTTER_MARGIN * 2)
+ SQL_EDITOR_VERTICAL_GUTTER_HEIGHT;
+ (SQL_EDITOR_GUTTER_MARGIN * 2)
+ SQL_EDITOR_GUTTER_HEIGHT;
expect(totalSize).toEqual(MOCKED_SQL_EDITOR_HEIGHT);
});
it('does not overflow the editor window after resizing', () => {
Expand All @@ -83,8 +83,8 @@ describe('SqlEditor', () => {
const totalSize = parseFloat(wrapper.find(AceEditorWrapper).props().height)
+ wrapper.find(SouthPane).props().height
+ SQL_TOOLBAR_HEIGHT
+ (SQL_EDITOR_VERTICAL_GUTTER_MARGIN * 2)
+ SQL_EDITOR_VERTICAL_GUTTER_HEIGHT;
+ (SQL_EDITOR_GUTTER_MARGIN * 2)
+ SQL_EDITOR_GUTTER_HEIGHT;
expect(totalSize).toEqual(450);
});
it('render a LimitControl with default limit', () => {
Expand Down
60 changes: 22 additions & 38 deletions superset/assets/src/SqlLab/components/SqlEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,18 @@ import SqlEditorLeftBar from './SqlEditorLeftBar';
import AceEditorWrapper from './AceEditorWrapper';
import {
STATE_BSSTYLE_MAP,
SQL_EDITOR_VERTICAL_GUTTER_HEIGHT,
SQL_EDITOR_VERTICAL_GUTTER_MARGIN,
SQL_EDITOR_GUTTER_HEIGHT,
SQL_EDITOR_GUTTER_MARGIN,
SQL_TOOLBAR_HEIGHT,
SQL_EDITOR_HORIZONTAL_GUTTER_WIDTH,
} from '../constants';
import RunQueryActionButton from './RunQueryActionButton';
import { FeatureFlag, isFeatureEnabled } from '../../featureFlags';

const SQL_EDITOR_PADDING = 10;
const INITIAL_NORTH_PERCENT = 30;
const INITIAL_SOUTH_PERCENT = 70;
const INITIAL_WEST_PERCENT = 20;
const INITIAL_EAST_PERCENT = 80;
const VALIDATION_DEBOUNCE_MS = 600;
const WINDOW_RESIZE_THROTTLE_MS = 100;
const SQL_EDITOR_MIN_SIZE = 300;

const propTypes = {
actions: PropTypes.object.isRequired,
Expand Down Expand Up @@ -107,7 +103,6 @@ class SqlEditor extends React.PureComponent {
this.onSqlChanged = this.onSqlChanged.bind(this);
this.setQueryEditorSql = this.setQueryEditorSql.bind(this);
this.queryPane = this.queryPane.bind(this);
this.leftBar = this.leftBar.bind(this);
this.getAceEditorAndSouthPaneHeights = this.getAceEditorAndSouthPaneHeights.bind(this);
this.getSqlEditorHeight = this.getSqlEditorHeight.bind(this);
this.requestValidation = debounce(
Expand Down Expand Up @@ -169,10 +164,10 @@ class SqlEditor extends React.PureComponent {
getAceEditorAndSouthPaneHeights(height, northPercent, southPercent) {
return {
aceEditorHeight: height * northPercent / 100
- (SQL_EDITOR_VERTICAL_GUTTER_HEIGHT / 2 + SQL_EDITOR_VERTICAL_GUTTER_MARGIN)
- (SQL_EDITOR_GUTTER_HEIGHT / 2 + SQL_EDITOR_GUTTER_MARGIN)
- SQL_TOOLBAR_HEIGHT,
southPaneHeight: height * southPercent / 100
- (SQL_EDITOR_VERTICAL_GUTTER_HEIGHT / 2 + SQL_EDITOR_VERTICAL_GUTTER_MARGIN),
- (SQL_EDITOR_GUTTER_HEIGHT / 2 + SQL_EDITOR_GUTTER_MARGIN),
};
}
getHotkeyConfig() {
Expand Down Expand Up @@ -220,7 +215,7 @@ class SqlEditor extends React.PureComponent {
}
elementStyle(dimension, elementSize, gutterSize) {
return {
[dimension]: `calc(${elementSize}% - ${gutterSize + SQL_EDITOR_VERTICAL_GUTTER_MARGIN}px)`,
[dimension]: `calc(${elementSize}% - ${gutterSize + SQL_EDITOR_GUTTER_MARGIN}px)`,
};
}
requestValidation() {
Expand Down Expand Up @@ -292,7 +287,7 @@ class SqlEditor extends React.PureComponent {
elementStyle={this.elementStyle}
minSize={200}
direction="vertical"
gutterSize={SQL_EDITOR_VERTICAL_GUTTER_HEIGHT}
gutterSize={SQL_EDITOR_GUTTER_HEIGHT}
onDragStart={this.onResizeStart}
onDragEnd={this.onResizeEnd}
>
Expand Down Expand Up @@ -321,22 +316,6 @@ class SqlEditor extends React.PureComponent {
</Split>
);
}
leftBar() {
return (
<CSSTransition
classNames="schemaPane"
in={!this.props.hideLeftBar}
timeout={300}
>
<SqlEditorLeftBar
database={this.props.database}
queryEditor={this.props.queryEditor}
tables={this.props.tables}
actions={this.props.actions}
/>
</CSSTransition>
);
}
renderEditorBottomBar(hotkeys) {
let ctasControls;
if (this.props.database && this.props.database.allow_ctas) {
Expand Down Expand Up @@ -476,18 +455,23 @@ class SqlEditor extends React.PureComponent {
}
render() {
return (
<Split
ref={this.sqlEditorRef}
className={this.props.hideLeftBar ? 'SqlEditor-expanded' : 'SqlEditor'}
sizes={[INITIAL_WEST_PERCENT, INITIAL_EAST_PERCENT]}
direction="horizontal"
minSize={SQL_EDITOR_MIN_SIZE}
gutterSize={SQL_EDITOR_HORIZONTAL_GUTTER_WIDTH}
snapOffset={0}
>
{this.leftBar()}
<div ref={this.sqlEditorRef} className="SqlEditor">
<CSSTransition
classNames="schemaPane"
in={!this.props.hideLeftBar}
timeout={300}
>
<div className="schemaPane">
<SqlEditorLeftBar
database={this.props.database}
queryEditor={this.props.queryEditor}
tables={this.props.tables}
actions={this.props.actions}
/>
</div>
</CSSTransition>
{this.queryPane()}
</Split>
</div>
);
}
}
Expand Down
5 changes: 2 additions & 3 deletions superset/assets/src/SqlLab/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ export const TIME_OPTIONS = [
];

// SqlEditor layout constants
export const SQL_EDITOR_VERTICAL_GUTTER_HEIGHT = 5;
export const SQL_EDITOR_VERTICAL_GUTTER_MARGIN = 3;
export const SQL_EDITOR_GUTTER_HEIGHT = 5;
export const SQL_EDITOR_GUTTER_MARGIN = 3;
export const SQL_TOOLBAR_HEIGHT = 51;
export const SQL_EDITOR_HORIZONTAL_GUTTER_WIDTH = 5;

// kilobyte storage
export const KB_STORAGE = 1024;
Expand Down
33 changes: 13 additions & 20 deletions superset/assets/src/SqlLab/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ div.Workspace {
}
}

.SqlEditor, .SqlEditor-expanded {
.SqlEditor {
display: flex;
flex-direction: row;
height: 100%;
Expand All @@ -241,11 +241,14 @@ div.Workspace {
}

.schemaPane {
flex: 0 0 300px;
max-width: 300px;
transition: transform .3s ease-in-out;
}

.queryPane {
flex: 1 1 auto;
padding-left: 10px;
}

.schemaPane-enter-done, .schemaPane-exit {
Expand All @@ -270,29 +273,19 @@ div.Workspace {
.schemaPane-exit-done + .queryPane {
margin-left: 0;
}
}

.SqlEditor .gutter-horizontal {
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
height: 40px;
cursor: col-resize;
margin-right: 10px;
}

.SqlEditor-expanded .gutter-horizontal {
display: none;
}
.gutter {
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
width: 3%;
margin: 3px 47%;
}

.queryPane .gutter-vertical {
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
width: 3%;
margin: 3px 47%;
cursor: row-resize;
.gutter.gutter-vertical {
cursor: row-resize;
}
}


.SqlEditorLeftBar {
height: 100%;
display: flex;
Expand Down

0 comments on commit 47e588b

Please sign in to comment.