This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from kristw/kristw-cherry-sep18
Cherry-picks: Several bug fixes and react HMR
- Loading branch information
Showing
26 changed files
with
385 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"presets" : ["airbnb", "react", "env"], | ||
"plugins": ["syntax-dynamic-import"], | ||
"plugins": ["syntax-dynamic-import", "react-hot-loader/babel"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import { createStore, compose, applyMiddleware } from 'redux'; | ||
import { Provider } from 'react-redux'; | ||
import thunkMiddleware from 'redux-thunk'; | ||
import { hot } from 'react-hot-loader'; | ||
|
||
import getInitialState from './getInitialState'; | ||
import rootReducer from './reducers'; | ||
import { initEnhancer } from '../reduxUtils'; | ||
import { initJQueryAjax } from '../modules/utils'; | ||
import App from './components/App'; | ||
import { appSetup } from '../common'; | ||
|
||
import './main.less'; | ||
import '../../stylesheets/reactable-pagination.css'; | ||
import '../components/FilterableTable/FilterableTableStyles.css'; | ||
|
||
appSetup(); | ||
initJQueryAjax(); | ||
|
||
const appContainer = document.getElementById('app'); | ||
const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap')); | ||
const state = getInitialState(bootstrapData); | ||
|
||
const store = createStore( | ||
rootReducer, | ||
state, | ||
compose( | ||
applyMiddleware(thunkMiddleware), | ||
initEnhancer(), | ||
), | ||
); | ||
|
||
// Highlight the navbar menu | ||
const menus = document.querySelectorAll('.nav.navbar-nav li.dropdown'); | ||
const sqlLabMenu = Array.prototype.slice.apply(menus) | ||
.find(element => element.innerText.trim() === 'SQL Lab'); | ||
if (sqlLabMenu) { | ||
const classes = sqlLabMenu.getAttribute('class'); | ||
if (classes.indexOf('active') === -1) { | ||
sqlLabMenu.setAttribute('class', `${classes} active`); | ||
} | ||
} | ||
|
||
const Application = () => ( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider> | ||
); | ||
|
||
export default hot(module)(Application); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,8 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import { createStore, compose, applyMiddleware } from 'redux'; | ||
import { Provider } from 'react-redux'; | ||
import thunkMiddleware from 'redux-thunk'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
import getInitialState from './getInitialState'; | ||
import rootReducer from './reducers'; | ||
import { initEnhancer } from '../reduxUtils'; | ||
import { initJQueryAjax } from '../modules/utils'; | ||
import App from './components/App'; | ||
import { appSetup } from '../common'; | ||
|
||
import './main.less'; | ||
import '../../stylesheets/reactable-pagination.css'; | ||
import '../components/FilterableTable/FilterableTableStyles.css'; | ||
|
||
appSetup(); | ||
initJQueryAjax(); | ||
|
||
const appContainer = document.getElementById('app'); | ||
const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap')); | ||
const state = getInitialState(bootstrapData); | ||
|
||
const store = createStore( | ||
rootReducer, | ||
state, | ||
compose( | ||
applyMiddleware(thunkMiddleware), | ||
initEnhancer(), | ||
), | ||
); | ||
|
||
// jquery hack to highlight the navbar menu | ||
$('a:contains("SQL Lab")') | ||
.parent() | ||
.addClass('active'); | ||
|
||
render( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider>, | ||
appContainer, | ||
ReactDOM.render( | ||
<App />, | ||
document.getElementById('app'), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { hot } from 'react-hot-loader'; | ||
import { appSetup } from '../common'; | ||
import AddSliceContainer from './AddSliceContainer'; | ||
|
||
appSetup(); | ||
|
||
const addSliceContainer = document.getElementById('js-add-slice-container'); | ||
const bootstrapData = JSON.parse(addSliceContainer.getAttribute('data-bootstrap')); | ||
|
||
const App = () => ( | ||
<AddSliceContainer datasources={bootstrapData.datasources} /> | ||
); | ||
|
||
export default hot(module)(App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { appSetup } from '../common'; | ||
import AddSliceContainer from './AddSliceContainer'; | ||
|
||
appSetup(); | ||
|
||
const addSliceContainer = document.getElementById('js-add-slice-container'); | ||
const bootstrapData = JSON.parse(addSliceContainer.getAttribute('data-bootstrap')); | ||
import App from './App'; | ||
|
||
ReactDOM.render( | ||
<AddSliceContainer datasources={bootstrapData.datasources} />, | ||
addSliceContainer, | ||
<App />, | ||
document.getElementById('js-add-slice-container'), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import thunk from 'redux-thunk'; | ||
import { createStore, applyMiddleware, compose } from 'redux'; | ||
import { Provider } from 'react-redux'; | ||
import { hot } from 'react-hot-loader'; | ||
|
||
import { initEnhancer } from '../reduxUtils'; | ||
import { appSetup } from '../common'; | ||
import { initJQueryAjax } from '../modules/utils'; | ||
import DashboardContainer from './containers/Dashboard'; | ||
import getInitialState from './reducers/getInitialState'; | ||
import rootReducer from './reducers/index'; | ||
|
||
appSetup(); | ||
initJQueryAjax(); | ||
|
||
const appContainer = document.getElementById('app'); | ||
const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap')); | ||
const initState = getInitialState(bootstrapData); | ||
|
||
const store = createStore( | ||
rootReducer, | ||
initState, | ||
compose( | ||
applyMiddleware(thunk), | ||
initEnhancer(false), | ||
), | ||
); | ||
|
||
const App = () => ( | ||
<Provider store={store}> | ||
<DashboardContainer /> | ||
</Provider> | ||
); | ||
|
||
export default hot(module)(App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,5 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { createStore, applyMiddleware, compose } from 'redux'; | ||
import { Provider } from 'react-redux'; | ||
import thunk from 'redux-thunk'; | ||
import App from './App'; | ||
|
||
import { initEnhancer } from '../reduxUtils'; | ||
import { appSetup } from '../common'; | ||
import { initJQueryAjax } from '../modules/utils'; | ||
import DashboardContainer from './containers/Dashboard'; | ||
import getInitialState from './reducers/getInitialState'; | ||
import rootReducer from './reducers/index'; | ||
|
||
appSetup(); | ||
initJQueryAjax(); | ||
|
||
const appContainer = document.getElementById('app'); | ||
const bootstrapData = JSON.parse(appContainer.getAttribute('data-bootstrap')); | ||
const initState = getInitialState(bootstrapData); | ||
|
||
const store = createStore( | ||
rootReducer, | ||
initState, | ||
compose( | ||
applyMiddleware(thunk), | ||
initEnhancer(false), | ||
), | ||
); | ||
|
||
ReactDOM.render( | ||
<Provider store={store}> | ||
<DashboardContainer /> | ||
</Provider>, | ||
appContainer, | ||
); | ||
ReactDOM.render(<App />, document.getElementById('app')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* eslint no-undef: 2 */ | ||
import React from 'react'; | ||
import { hot } from 'react-hot-loader'; | ||
import { createStore, applyMiddleware, compose } from 'redux'; | ||
import { Provider } from 'react-redux'; | ||
import thunk from 'redux-thunk'; | ||
|
||
import shortid from 'shortid'; | ||
import { now } from '../modules/dates'; | ||
import { initEnhancer } from '../reduxUtils'; | ||
import { getChartKey } from './exploreUtils'; | ||
import ToastPresenter from '../messageToasts/containers/ToastPresenter'; | ||
import { getControlsState, getFormDataFromControls } from './store'; | ||
import { initJQueryAjax } from '../modules/utils'; | ||
import ExploreViewContainer from './components/ExploreViewContainer'; | ||
import rootReducer from './reducers/index'; | ||
import getToastsFromPyFlashMessages from '../messageToasts/utils/getToastsFromPyFlashMessages'; | ||
|
||
import { appSetup } from '../common'; | ||
import './main.css'; | ||
import '../../stylesheets/reactable-pagination.css'; | ||
|
||
appSetup(); | ||
initJQueryAjax(); | ||
|
||
const exploreViewContainer = document.getElementById('app'); | ||
const bootstrapData = JSON.parse(exploreViewContainer.getAttribute('data-bootstrap')); | ||
const controls = getControlsState(bootstrapData, bootstrapData.form_data); | ||
const rawFormData = { ...bootstrapData.form_data }; | ||
|
||
delete bootstrapData.form_data; | ||
delete bootstrapData.common.locale; | ||
delete bootstrapData.common.language_pack; | ||
|
||
// Initial state | ||
const bootstrappedState = { | ||
...bootstrapData, | ||
rawFormData, | ||
controls, | ||
filterColumnOpts: [], | ||
isDatasourceMetaLoading: false, | ||
isStarred: false, | ||
}; | ||
const slice = bootstrappedState.slice; | ||
const sliceFormData = slice | ||
? getFormDataFromControls(getControlsState(bootstrapData, slice.form_data)) | ||
: null; | ||
const chartKey = getChartKey(bootstrappedState); | ||
const initState = { | ||
charts: { | ||
[chartKey]: { | ||
id: chartKey, | ||
chartAlert: null, | ||
chartStatus: 'loading', | ||
chartUpdateEndTime: null, | ||
chartUpdateStartTime: now(), | ||
latestQueryFormData: getFormDataFromControls(controls), | ||
sliceFormData, | ||
queryRequest: null, | ||
queryResponse: null, | ||
triggerQuery: true, | ||
lastRendered: 0, | ||
}, | ||
}, | ||
saveModal: { | ||
dashboards: [], | ||
saveModalAlert: null, | ||
}, | ||
explore: bootstrappedState, | ||
impressionId: shortid.generate(), | ||
messageToasts: getToastsFromPyFlashMessages((bootstrapData.common || {}).flash_messages || []), | ||
}; | ||
|
||
const store = createStore( | ||
rootReducer, | ||
initState, | ||
compose( | ||
applyMiddleware(thunk), | ||
initEnhancer(false), | ||
), | ||
); | ||
|
||
const App = () => ( | ||
<Provider store={store}> | ||
<div> | ||
<ExploreViewContainer /> | ||
<ToastPresenter /> | ||
</div> | ||
</Provider> | ||
); | ||
|
||
export default hot(module)(App); |
Oops, something went wrong.