Skip to content

Commit

Permalink
Do not use persistState for explorev2 (#1894)
Browse files Browse the repository at this point in the history
* Do not use persistState for explorev2

* Change enhancerWithPersistState to enhancer and function name to initEnhancer
  • Loading branch information
vera-liu authored Jan 4, 2017
1 parent a1e3fc1 commit 9bc7ad9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions superset/assets/javascripts/SqlLab/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require('bootstrap');
import React from 'react';
import { render } from 'react-dom';
import { getInitialState, sqlLabReducer } from './reducers';
import { enhancer } from '../reduxUtils';
import { initEnhancer } from '../reduxUtils';
import { createStore, compose, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import thunkMiddleware from 'redux-thunk';
Expand All @@ -20,7 +20,7 @@ const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap'));
const state = Object.assign({}, getInitialState(bootstrapData.defaultDbId), bootstrapData);

let store = createStore(
sqlLabReducer, state, compose(applyMiddleware(thunkMiddleware), enhancer()));
sqlLabReducer, state, compose(applyMiddleware(thunkMiddleware), initEnhancer()));

// jquery hack to highlight the navbar menu
$('a:contains("SQL Lab")').parent().addClass('active');
Expand Down
4 changes: 2 additions & 2 deletions superset/assets/javascripts/explorev2/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createStore, applyMiddleware, compose } from 'redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import { now } from '../modules/dates';
import { enhancer } from '../reduxUtils';
import { initEnhancer } from '../reduxUtils';

// jquery and bootstrap required to make bootstrap dropdown menu's work
const $ = window.$ = require('jquery'); // eslint-disable-line
Expand Down Expand Up @@ -68,7 +68,7 @@ bootstrappedState.viz.form_data.filters =
getFilters(bootstrappedState.viz.form_data, bootstrapData.datasource_type);

const store = createStore(exploreReducer, bootstrappedState,
compose(applyMiddleware(thunk), enhancer())
compose(applyMiddleware(thunk), initEnhancer(false))
);

ReactDOM.render(
Expand Down
8 changes: 4 additions & 4 deletions superset/assets/javascripts/reduxUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ export function addToArr(state, arrKey, obj) {
return Object.assign({}, state, newState);
}

export function enhancer() {
let enhancerWithPersistState = compose(persistState());
export function initEnhancer(persist = true) {
let enhancer = persist ? compose(persistState()) : compose();
if (process.env.NODE_ENV === 'dev') {
/* eslint-disable no-underscore-dangle */
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
/* eslint-enable */
enhancerWithPersistState = composeEnhancers(persistState());
enhancer = persist ? composeEnhancers(persistState()) : composeEnhancers();
}
return enhancerWithPersistState;
return enhancer;
}

export function areArraysShallowEqual(arr1, arr2) {
Expand Down

0 comments on commit 9bc7ad9

Please sign in to comment.