Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Bug] Reset selected provider status after loading and before sharing (#999)

Raúl Yeguas97e4d6330068
diff --git a/src/reducers/provider-state-updaters.js b/src/reducers/provider-state-updaters.js
index 60d1e147f..3576f5706 100644
--- a/src/reducers/provider-state-updaters.js
+++ b/src/reducers/provider-state-updaters.js
@@ -34,7 +34,8 @@ import {
postSaveLoadSuccess,
loadCloudMapSuccess,
getSavedMapsSuccess,
- getSavedMapsError
+ getSavedMapsError,
+ resetProviderStatus
} from 'actions/provider-actions';
import {removeNotification, toggleModal, addNotification} from 'actions/ui-state-actions';
import {addDataToMap} from 'actions/actions';
@@ -163,6 +164,7 @@ export const postSaveLoadSuccessUpdater = (state, action) => {
const tasks = [
ACTION_TASK().map(_ => toggleModal(null)),
+ ACTION_TASK().map(_ => resetProviderStatus()),
...createGlobalNotificationTasks({message})
];
@@ -318,6 +320,9 @@ export const resetProviderStatusUpdater = (state, action) => ({
*/
export const setCloudProviderUpdater = (state, action) => ({
...state,
+ isProviderLoading: false,
+ providerError: null,
+ successInfo: {},
currentProvider: action.payload
});
diff --git a/test/node/reducers/provider-state-test.js b/test/node/reducers/provider-state-test.js
index 0befeec88..f03e9bc51 100644
--- a/test/node/reducers/provider-state-test.js
+++ b/test/node/reducers/provider-state-test.js
@@ -242,12 +242,13 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD -> onSuccess : onError', t =
const resultState2 = reducer(resultState1, succeedTaskInTest(task3, undefined));
// saveToCloudSuccess
- const [task4, task5, task6, ...more3] = drainTasksForTesting();
- t.ok(more3.length === 0, 'should create 3 tasks');
+ const [task4, task5, task6, task7, ...more3] = drainTasksForTesting();
+ t.ok(more3.length === 0, 'should create 4 tasks');
- t.ok(task4.type === 'ACTION_TASK', 'should create 2 ACTION_TASKS');
- t.ok(task5.type === 'ACTION_TASK', 'should create 2 ACTION_TASKS');
- t.ok(task6.type === 'DELAY_TASK', 'should create 1 DELAY_TASK');
+ t.ok(task4.type === 'ACTION_TASK', 'should create 3 ACTION_TASKS');
+ t.ok(task5.type === 'ACTION_TASK', 'should create 3 ACTION_TASKS');
+ t.ok(task6.type === 'ACTION_TASK', 'should create 3 ACTION_TASKS');
+ t.ok(task7.type === 'DELAY_TASK', 'should create 1 DELAY_TASK');
// toggleModal(null),
const resultState3 = composedReducer(resultState2, succeedTaskInTest(task4, undefined));
@@ -264,15 +265,31 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD -> onSuccess : onError', t =
},
'Should call toggleModal(null'
);
+
const resultState4 = composedReducer(resultState3, succeedTaskInTest(task5, undefined));
+ t.deepEqual(
+ resultState4,
+ {
+ isProviderLoading: false,
+ providerError: null,
+ currentProvider: 'taro',
+ mapSaved: 'taro',
+ initialState: {},
+ successInfo: {},
+ modalId: null
+ },
+ 'Should call resetProviderStatus'
+ );
+
+ const resultState5 = composedReducer(resultState4, succeedTaskInTest(task6, undefined));
t.equal(
- resultState4.notification.type,
+ resultState5.notification.type,
'success',
'Should call addNotification with successNote'
);
- const resultState5 = composedReducer(resultState4, succeedTaskInTest(task6, undefined));
- t.equal(resultState5.remove, true, 'Should call removeNotification');
+ const resultState6 = composedReducer(resultState5, succeedTaskInTest(task7, undefined));
+ t.equal(resultState6.remove, true, 'Should call removeNotification');
t.end();
});