Skip to content

Commit

Permalink
load configs in via common param
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreythewang committed Nov 7, 2018
1 parent 7fae380 commit dd66a8e
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 27 deletions.
6 changes: 2 additions & 4 deletions superset/assets/spec/javascripts/sqllab/SqlEditor_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ describe('SqlEditor', () => {
getHeight: () => ('100px'),
editorQueries: [],
dataPreviewQueries: [],
constants: {
defaultQueryLimit: 10000,
maxRow: 100000,
},
defaultQueryLimit: 10000,
maxRow: 100000,
};
it('is valid', () => {
expect(
Expand Down
10 changes: 6 additions & 4 deletions superset/assets/spec/javascripts/sqllab/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,14 @@ export const initialState = {
workspaceQueries: [],
queriesLastUpdate: 0,
activeSouthPaneTab: 'Results',
constants: {
defaultQueryLimit: 10000,
maxRow: 100000,
},
},
messageToasts: [],
common: {
conf: {
DEFAULT_SQLLAB_LIMIT: 10000,
SQL_MAX_ROW: 100000,
},
},
};

export const query = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('sqlLabReducer', () => {
});
it('should not fail while setting queryLimit', () => {
const queryLimit = 101;
newState = r.sqlLabReducer(newState, actions.queryEditorSetQueryLimit(qe, queryLimit));
newState = sqlLabReducer(newState, actions.queryEditorSetQueryLimit(qe, queryLimit));
expect(newState.queryEditors[1].queryLimit).toEqual(queryLimit);
});
it('should set selectedText', () => {
Expand Down
9 changes: 0 additions & 9 deletions superset/assets/src/SqlLab/App.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { createStore, compose, applyMiddleware } from 'redux';
import persistState from 'redux-localstorage';
import { Provider } from 'react-redux';
import thunkMiddleware from 'redux-thunk';
import { hot } from 'react-hot-loader';
Expand Down Expand Up @@ -40,14 +39,6 @@ const sqlLabPersistStateConfig = {
},
};

function loadConstants() {
return (storedState) => {
const newState = Object.assign({}, storedState);
newState.sqlLab.constants = state.constants;
return newState;
};
}

const store = createStore(
rootReducer,
initialState,
Expand Down
3 changes: 2 additions & 1 deletion superset/assets/src/SqlLab/components/LimitControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {
Overlay,
Popover,
} from 'react-bootstrap';
import { t } from '@superset-ui/translation';

import ControlHeader from '../../explore/components/ControlHeader';
import { t } from '../../locales';

const propTypes = {
value: PropTypes.number,
Expand Down
8 changes: 3 additions & 5 deletions superset/assets/src/SqlLab/components/TabbedSqlEditors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class TabbedSqlEditors extends React.PureComponent {
TabbedSqlEditors.propTypes = propTypes;
TabbedSqlEditors.defaultProps = defaultProps;

function mapStateToProps({ sqlLab, constants }) {
function mapStateToProps({ sqlLab, common }) {
return {
databases: sqlLab.databases,
queryEditors: sqlLab.queryEditors,
Expand All @@ -256,10 +256,8 @@ function mapStateToProps({ sqlLab, constants }) {
tables: sqlLab.tables,
defaultDbId: sqlLab.defaultDbId,
offline: sqlLab.offline,
defaultQueryLimit: sqlLab.constants && sqlLab.constants.defaultQueryLimit ||
constants.defaultQueryLimit,
maxRow: sqlLab.constants && sqlLab.constants.maxRow ||
constants.maxRow,
defaultQueryLimit: common.conf.DEFAULT_SQLLAB_LIMIT,
maxRow: common.conf.SQL_MAX_ROW,
};
}
function mapDispatchToProps(dispatch) {
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/src/SqlLab/reducers/getInitialState.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function getInitialState({ defaultDbId, ...restBootstrapData }) {
latestQueryId: null,
autorun: false,
dbId: defaultDbId,
queryLimit: defaultQueryLimit,
queryLimit: restBootstrapData.common.conf.DEFAULT_SQLLAB_LIMIT,
};

return {
Expand Down
2 changes: 2 additions & 0 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
'SUPERSET_WEBSERVER_TIMEOUT',
'SUPERSET_DASHBOARD_POSITION_DATA_LIMIT',
'ENABLE_JAVASCRIPT_CONTROLS',
'DEFAULT_SQLLAB_LIMIT',
'SQL_MAX_ROW',
)


Expand Down
2 changes: 0 additions & 2 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2844,8 +2844,6 @@ def sqllab(self):
"""SQL Editor"""
d = {
'defaultDbId': config.get('SQLLAB_DEFAULT_DBID'),
'defaultQueryLimit': config.get('DEFAULT_SQLLAB_LIMIT'),
'maxRow': config.get('SQL_MAX_ROW'),
'common': self.common_bootsrap_payload(),
}
return self.render_template(
Expand Down

0 comments on commit dd66a8e

Please sign in to comment.