Skip to content

Commit

Permalink
fix #3422 (#3440)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace Guo authored and mistercrunch committed Sep 12, 2017
1 parent 3c0e85e commit 2d6b942
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions superset/assets/javascripts/SqlLab/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const QUERY_EDITOR_SET_TITLE = 'QUERY_EDITOR_SET_TITLE';
export const QUERY_EDITOR_SET_AUTORUN = 'QUERY_EDITOR_SET_AUTORUN';
export const QUERY_EDITOR_SET_SQL = 'QUERY_EDITOR_SET_SQL';
export const QUERY_EDITOR_SET_SELECTED_TEXT = 'QUERY_EDITOR_SET_SELECTED_TEXT';
export const QUERY_EDITOR_PERSIST_HEIGHT = 'QUERY_EDITOR_PERSIST_HEIGHT';

export const SET_DATABASES = 'SET_DATABASES';
export const SET_ACTIVE_QUERY_EDITOR = 'SET_ACTIVE_QUERY_EDITOR';
export const SET_ACTIVE_SOUTHPANE_TAB = 'SET_ACTIVE_SOUTHPANE_TAB';
Expand Down Expand Up @@ -346,6 +348,10 @@ export function refreshQueries(alteredQueries) {
return { type: REFRESH_QUERIES, alteredQueries };
}

export function persistEditorHeight(queryEditor, currentHeight) {
return { type: QUERY_EDITOR_PERSIST_HEIGHT, queryEditor, currentHeight };
}

export function popStoredQuery(urlId) {
return function (dispatch) {
$.ajax({
Expand Down
6 changes: 5 additions & 1 deletion superset/assets/javascripts/SqlLab/components/SqlEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class SqlEditor extends React.PureComponent {
southPaneHeight: height - this.refs.ace.clientHeight,
height,
});

if (this.refs.ace.clientHeight) {
this.props.actions.persistEditorHeight(this.props.queryEditor, this.refs.ace.clientHeight);
}
}
setQueryEditorSql(sql) {
this.props.actions.queryEditorSetSql(this.props.queryEditor, sql);
Expand Down Expand Up @@ -191,7 +195,7 @@ class SqlEditor extends React.PureComponent {
}
render() {
const height = this.sqlEditorHeight();
const defaultNorthHeight = 200;
const defaultNorthHeight = this.props.queryEditor.height || 200;
return (
<div
className="SqlEditor"
Expand Down
3 changes: 3 additions & 0 deletions superset/assets/javascripts/SqlLab/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ export const sqlLabReducer = function (state, action) {
[actions.QUERY_EDITOR_SET_AUTORUN]() {
return alterInArr(state, 'queryEditors', action.queryEditor, { autorun: action.autorun });
},
[actions.QUERY_EDITOR_PERSIST_HEIGHT]() {
return alterInArr(state, 'queryEditors', action.queryEditor, { height: action.currentHeight });
},
[actions.ADD_ALERT]() {
return addToArr(state, 'alerts', action.alert);
},
Expand Down

0 comments on commit 2d6b942

Please sign in to comment.