Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Enhancement] Loading and error feedback for shared maps loaded from URL #1002 (#1003)
Raúl Yeguasfa253a462b38
diff --git a/examples/demo-app/src/app.js b/examples/demo-app/src/app.jsindex 142fa8e18..b4bcf23eb 100644--- a/examples/demo-app/src/app.js+++ b/examples/demo-app/src/app.js@@ -34,7 +34,8 @@ import {loadRemoteMap,loadSampleConfigurations,onExportFileSuccess,- onLoadCloudMapSuccess+ onLoadCloudMapSuccess,+ onLoadCloudMapError} from './actions';import {loadCloudMap} from 'kepler.gl/actions';@@ -375,6 +376,7 @@ class App extends Component {cloudProviders={CLOUD_PROVIDERS}onExportToCloudSuccess={onExportFileSuccess}onLoadCloudMapSuccess={onLoadCloudMapSuccess}+ onLoadCloudMapError={onLoadCloudMapError}/>)}</AutoSizer>diff --git a/src/actions/provider-actions.js b/src/actions/provider-actions.jsindex e4c536e70..442aabe4a 100644--- a/src/actions/provider-actions.js+++ b/src/actions/provider-actions.js@@ -61,6 +61,8 @@ export const loadCloudMapSuccess = createAction(payload => payload);+export const loadCloudMapError = createAction(ActionTypes.LOAD_CLOUD_MAP_ERROR, payload => payload);+export const getSavedMaps = createAction(ActionTypes.GET_SAVED_MAPS, provider => provider);export const getSavedMapsSuccess = createAction(diff --git a/src/components/modals/load-data-modal.js b/src/components/modals/load-data-modal.jsindex 0a43a8cbf..d6f768366 100644--- a/src/components/modals/load-data-modal.js+++ b/src/components/modals/load-data-modal.js@@ -46,7 +46,7 @@ LoadDataModalFactory.deps = [ModalTabsFactory, FileUploadFactory, LoadStorageMapfunction LoadDataModalFactory(ModalTabs, FileUpload, LoadStorageMap) {const LoadDataModal = props => {- const {fileLoading, loadingMethods} = props;+ const {fileLoading, loadingMethods, isCloudMapLoading} = props;const [currentMethod, toggleMethod] = useState(getDefaultMethod(loadingMethods));return (@@ -56,7 +56,7 @@ function LoadDataModalFactory(ModalTabs, FileUpload, LoadStorageMap) {loadingMethods={loadingMethods}toggleMethod={toggleMethod}/>- {fileLoading ? (+ {fileLoading || isCloudMapLoading ? (<LoadingDialog size={64} />) : (currentMethod && <currentMethod.elementType key={currentMethod.id} {...props} />diff --git a/src/reducers/provider-state-updaters.js b/src/reducers/provider-state-updaters.jsindex 3576f5706..174bd18d9 100644--- a/src/reducers/provider-state-updaters.js+++ b/src/reducers/provider-state-updaters.js@@ -35,6 +35,7 @@ import {loadCloudMapSuccess,getSavedMapsSuccess,getSavedMapsError,+ loadCloudMapError,resetProviderStatus} from 'actions/provider-actions';import {removeNotification, toggleModal, addNotification} from 'actions/ui-state-actions';@@ -49,6 +50,7 @@ import KeplerGlSchema from 'schemas';export const INITIAL_PROVIDER_STATE = {isProviderLoading: false,+ isCloudMapLoading: false,providerError: null,currentProvider: null,successInfo: {},@@ -201,7 +203,8 @@ export const loadCloudMapUpdater = (state, action) => {const newState = {...state,- isProviderLoading: true+ isProviderLoading: true,+ isCloudMapLoading: true};// payload called by provider.downloadMap@@ -209,7 +212,7 @@ export const loadCloudMapUpdater = (state, action) => {// successresponse => loadCloudMapSuccess({response, loadParams, provider, onSuccess, onError}),// error- error => exportFileError({error, provider, onError})+ error => loadCloudMapError({error, provider, onError}));return withTask(newState, uploadFileTask);@@ -288,6 +291,7 @@ export const loadCloudMapSuccessUpdater = (state, action) => {...state,mapSaved: provider.name,currentProvider: provider.name,+ isCloudMapLoading: false,isProviderLoading: false};@@ -301,6 +305,24 @@ export const loadCloudMapSuccessUpdater = (state, action) => {return tasks.length ? withTask(newState, tasks) : newState;};++export const loadCloudMapErrorUpdater = (state, action) => {+ const message = getError(action.payload.error) || `Error loading saved map`;++ Console.warn(message);++ const newState = {+ ...state,+ isProviderLoading: false,+ isCloudMapLoading: false,+ providerError: null+ };++ return withTask(+ newState,+ createGlobalNotificationTasks({type: 'error', message, delayClose: false})+ );+};/**** @param {*} state@@ -310,6 +332,7 @@ export const resetProviderStatusUpdater = (state, action) => ({...state,isProviderLoading: false,providerError: null,+ isCloudMapLoading: false,successInfo: {}});diff --git a/src/reducers/provider-state.js b/src/reducers/provider-state.jsindex 2d2629ae5..47712c020 100644--- a/src/reducers/provider-state.js+++ b/src/reducers/provider-state.js@@ -35,6 +35,7 @@ const actionHandler = {[ActionTypes.POST_SAVE_LOAD_SUCCESS]: providerStateUpdaters.postSaveLoadSuccessUpdater,[ActionTypes.LOAD_CLOUD_MAP]: providerStateUpdaters.loadCloudMapUpdater,[ActionTypes.LOAD_CLOUD_MAP_SUCCESS]: providerStateUpdaters.loadCloudMapSuccessUpdater,+ [ActionTypes.LOAD_CLOUD_MAP_ERROR]: providerStateUpdaters.loadCloudMapErrorUpdater,[ActionTypes.GET_SAVED_MAPS]: providerStateUpdaters.getSavedMapsUpdater,[ActionTypes.GET_SAVED_MAPS_SUCCESS]: providerStateUpdaters.getSavedMapsSuccessUpdater,[ActionTypes.GET_SAVED_MAPS_ERROR]: providerStateUpdaters.getSavedMapsErrorUpdaterdiff --git a/test/node/reducers/provider-state-test.js b/test/node/reducers/provider-state-test.jsindex f03e9bc51..2daebcb35 100644--- a/test/node/reducers/provider-state-test.js+++ b/test/node/reducers/provider-state-test.js@@ -92,10 +92,12 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD', t => {const [task1, ...more] = drainTasksForTesting();t.ok(more.length === 0, 'should create 1 task');+ t.comment(JSON.stringify(nextState));t.deepEqual(nextState,{isProviderLoading: true,+ isCloudMapLoading: false,providerError: null,currentProvider: 'taro',successInfo: {},@@ -127,6 +129,7 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD', t => {resultState1,{isProviderLoading: false,+ isCloudMapLoading: false,providerError: null,currentProvider: 'taro',initialState: {},@@ -144,6 +147,7 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD', t => {resultState2,{isProviderLoading: false,+ isCloudMapLoading: false,providerError: 'hello',currentProvider: 'taro',initialState: {},@@ -229,6 +233,7 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD -> onSuccess : onError', t =nextState,{isProviderLoading: false,+ isCloudMapLoading: false,providerError: null,currentProvider: 'taro',mapSaved: 'taro',@@ -256,6 +261,7 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD -> onSuccess : onError', t =resultState3,{isProviderLoading: false,+ isCloudMapLoading: false,providerError: null,currentProvider: 'taro',mapSaved: 'taro',@@ -312,6 +318,7 @@ test('#providerStateReducer -> RESET_PROVIDER_STATUS', t => {nextState1,{isProviderLoading: false,+ isCloudMapLoading: false,providerError: null,currentProvider: 'taro',successInfo: {},@@ -330,6 +337,7 @@ test('#providerStateReducer -> SET_CLOUD_PROVIDER', t => {nextState,{isProviderLoading: false,+ isCloudMapLoading: false,providerError: null,currentProvider: 'blue',successInfo: {},