Skip to content

Commit 5f001ef

Browse files
author
Chris DeMartini
authored
Merge pull request #14 from keplergl/disable-save
disable calling config callback if in readOnly
2 parents 0c5941b + 1102a8c commit 5f001ef

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
"@tableau/tableau-ui": "^2.1.0",
3434
"core-js": "^2.6.0",
3535
"gh-pages": "^2.0.1",
36-
"kepler.gl": "1.1.11",
36+
"kepler.gl": "1.1.13",
3737
"lodash.throttle": "^4.1.1",
3838
"react": "^16.8.4",
3939
"react-beautiful-dnd": "^9.0.2",
4040
"react-bootstrap": "^0.32.1",
4141
"react-dom": "^16.8.4",
42-
"react-palm": "^1.1.2",
43-
"react-redux": "^4.4.5",
44-
"react-router": "^3.0.5",
42+
"react-palm": "^3.1.2",
43+
"react-redux": "^7.1.3",
44+
"react-router": "3.2.5",
4545
"react-router-redux": "^4.0.8",
4646
"react-scripts": "^2.1.3",
4747
"react-spinkit": "^3.0.0",

src/App.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ class App extends Component {
810810
</div>
811811
);
812812
}
813+
const readOnly = tableauSettingsState.readOnly === 'true'
813814

814815
return (
815816
<KeplerGlComponent
@@ -820,7 +821,7 @@ class App extends Component {
820821
selectedSheet={this.state.selectedSheet}
821822
tableauSettings={tableauSettingsState}
822823
theme={tableauSettingsState.theme}
823-
readOnly={tableauSettingsState.readOnly === 'true'}
824+
readOnly={readOnly}
824825
keplerConfig={tableauSettingsState.keplerConfig}
825826
mapboxAPIKey={
826827
tableauSettingsState.mapboxAPIKey
@@ -829,7 +830,7 @@ class App extends Component {
829830
}
830831
isLoading={isLoading}
831832
// persist state to tableau
832-
configCallBack={this.configCallBack}
833+
configCallBack={readOnly ? null : this.configCallBack}
833834
// interactivity
834835
clickCallBack={this.clickCallBack}
835836
hoverCallBack={this.hoverCallBack}

src/components/KeplerGL/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ class App extends Component {
101101
}
102102

103103
handleConfigChange() {
104+
if (typeof this.props.configCallBack !== 'function') {
105+
return;
106+
}
107+
104108
const currentState = this.getMapConfig();
105109
if (!currentState) {
106110
return;

src/components/KeplerGL/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,14 @@ class KeplerGlComponent extends React.Component {
5555
};
5656
const config = keplerConfig ? JSON.parse(keplerConfig) : undefined;
5757
const hasMapStateConfig = Boolean(config && config.config && config.config.mapState);
58-
58+
5959
this.props.dispatch(
6060
addDataToMap({
6161
datasets,
62-
options: {readOnly, centerMap: !hasMapStateConfig},
62+
options: {
63+
readOnly,
64+
centerMap: !hasMapStateConfig
65+
},
6366
config
6467
})
6568
);

src/reducers.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {combineReducers} from 'redux';
2222
import {handleActions} from 'redux-actions';
2323
import {routerReducer} from 'react-router-redux';
2424
import keplerGlReducer, {visStateUpdaters} from 'kepler.gl/reducers';
25-
import {FILTER_TYPES} from 'kepler.gl/constants';
2625
import {MAP_ID, DATA_ID} from './constants';
2726
import {MARKER_SELECT} from './actions';
2827
import {log} from './utils';
@@ -52,6 +51,8 @@ const composedReducer = (state, action) => {
5251
switch (action.type) {
5352
case MARKER_SELECT:
5453
return markerSelectUpdater(state, action);
54+
default:
55+
break;
5556
}
5657

5758
return reducers(state, action);
@@ -69,7 +70,7 @@ function markerSelectUpdater(state, action) {
6970
);
7071
const {field, values} = action.payload;
7172
const visState = visStateSelector(state);
72-
let currentFilterIdx = visState.filters.findIndex(f => f.name === field && f.dataId === DATA_ID && f.tableauMarkerFilter);
73+
let currentFilterIdx = visState.filters.findIndex(f => f.name.includes(field) && f.dataId.includes(DATA_ID) && f.tableauMarkerFilter);
7374
let nextState = visState;
7475
if (values.length) {
7576
if (currentFilterIdx < 0) {
@@ -80,7 +81,7 @@ function markerSelectUpdater(state, action) {
8081
}
8182
log('add filter based on marker')
8283
// add filter
83-
nextState = visStateUpdaters.addFilterUpdater(nextState, {dataId: DATA_ID});
84+
nextState = visStateUpdaters.addFilterUpdater(nextState, {dataId: [DATA_ID]});
8485

8586
// added filter should be the last one
8687
const idx = nextState.filters.length - 1;
@@ -136,10 +137,10 @@ function getNewFilter(state, idx, field) {
136137
const newFilter = {
137138
...state.filters[idx],
138139
...filterProp,
139-
name: field.name,
140+
name: [field.name],
140141
// can't edit dataId once name is selected
141142
freeze: true,
142-
fieldIdx,
143+
fieldIdx: [fieldIdx],
143144
// add tableau identifier to filter
144145
tableauMarkerFilter: true
145146
};

src/store.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020

2121
import {createStore, applyMiddleware, compose} from 'redux';
2222

23-
import window from 'global/window';
2423
import {taskMiddleware} from 'react-palm/tasks';
2524
import {routerMiddleware} from 'react-router-redux';
2625
import {hashHistory} from 'react-router';
2726
import reducers from './reducers';
28-
import KeplerGlSchema from 'kepler.gl/schemas';
2927

3028
export const middlewares = [
3129
taskMiddleware,

0 commit comments

Comments
 (0)