Skip to content

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

[Chore]: Technical: Translate actions to typescript part 2 (#1725)

Maksim Suslov2ba948583fe9
diff --git a/src/actions/map-style-actions.d.ts b/src/actions/map-style-actions.d.ts
deleted file mode 100644
index 025d8a2c1..000000000
--- a/src/actions/map-style-actions.d.ts
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright (c) 2020 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-// @ts-nocheck
-import ActionTypes from 'constants/action-types';
-import {Merge, RGBColor} from '../reducers/types';
-import {
- InputStyle,
- MapStyles,
- VisibleLayerGroups,
- MapStyles
-} from '../reducers/map-style-updaters';
-import {MapState} from '../reducers/map-state-updaters';
-
-export function addCustomMapStyle(): {type: ActionTypes.ADD_CUSTOM_MAP_STYLE};
-
-/** INPUT_MAP_STYLE */
-export type InputMapStyleUpdaterAction = {
- payload: {
- inputStyle: Partial<InputStyle>;
- mapState?: MapState
- }
-};
-
-export function inputMapStyle(
- inputStyle: InputMapStyleUpdaterAction['payload']['inputStyle'],
- mapState?: InputMapStyleUpdaterAction['payload']['mapState']
-): Merge<InputMapStyleUpdaterAction, {type: ActionTypes.INPUT_MAP_STYLE}>;
-
-/** MAP_CONFIG_CHANGE */
-export type MapConfigChangeUpdaterAction = {
- payload: {
- visibleLayerGroups?: VisibleLayerGroups;
- topLayerGroups?: VisibleLayerGroups;
- };
-};
-
-export function mapConfigChange(
- mapStyle: MapConfigChangeUpdaterAction['payload']
-): Merge<MapConfigChangeUpdaterAction, {type: ActionTypes.MAP_CONFIG_CHANGE}>;
-
-/** REQUEST_MAP_STYLES */
-export type RequestMapStylesUpdaterAction = {
- payload: {
- [key: string]: {
- id: string;
- label?: string;
- url: string;
- icon?: string;
- layerGroups?: string;
- };
- };
-};
-export function requestMapStyles(
- mapStyles: RequestMapStylesUpdaterAction['payload']
-): Merge<RequestMapStylesUpdaterAction, {type: ActionTypes.REQUEST_MAP_STYLES}>;
-
-/** LOAD_MAP_STYLES */
-export type LoadMapStylesUpdaterAction = {
- payload: MapStyles;
-};
-export function loadMapStyles(
- newStyles: LoadMapStylesUpdaterAction['payload']
-): Merge<LoadMapStylesUpdaterAction, {type: ActionTypes.LOAD_MAP_STYLES}>;
-
-/** LOAD_MAP_STYLE_ERR */
-export type LoadMapStyleErrUpdaterAction = {
- payload: Error;
-};
-export function loadMapStyleErr(
- error: LoadMapStyleErrUpdaterAction['payload']
-): Merge<LoadMapStyleErrUpdaterAction, {type: ActionTypes.LOAD_MAP_STYLE_ERR}>;
-
-/** MAP_STYLE_CHANGE */
-export type MapStyleChangeUpdaterAction = {
- payload: string;
-};
-export function mapStyleChange(
- styleType: MapStyleChangeUpdaterAction['payload']
-): Merge<MapStyleChangeUpdaterAction, {type: ActionTypes.MAP_STYLE_CHANGE}>;
-
-/** LOAD_CUSTOM_MAP_STYLE */
-export type LoadCustomMapStyleUpdaterAction = {
- payload: {
- icon?: string;
- style?: object;
- error?: Error;
- };
-};
-export function loadCustomMapStyle(
- customMapStyle: LoadCustomMapStyleUpdaterAction['payload']
-): Merge<LoadCustomMapStyleUpdaterAction, {type: ActionTypes.LOAD_CUSTOM_MAP_STYLE}>;
-
-/** SET_3D_BUILDING_COLOR */
-export type Set3dBuildingColorUpdaterAction = {
- payload: RGBColor;
-};
-export function set3dBuildingColor(
- color: Set3dBuildingColorUpdaterAction['payload']
-): Merge<Set3dBuildingColorUpdaterAction, {type: ActionTypes.SET_3D_BUILDING_COLOR}>;
diff --git a/src/actions/map-style-actions.ts b/src/actions/map-style-actions.ts
index aa87ef2d2..038181ae7 100644
--- a/src/actions/map-style-actions.ts
+++ b/src/actions/map-style-actions.ts
@@ -18,8 +18,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-import {createAction} from 'redux-actions';
+import {createAction} from '@reduxjs/toolkit';
import ActionTypes from 'constants/action-types';
+import {Merge, RGBColor} from '../reducers/types';
+import {InputStyle, MapStyles, VisibleLayerGroups} from '../reducers/map-style-updaters';
+import {MapState} from '../reducers/map-state-updaters';
/**
* Add map style from user input to reducer and set it to current style
@@ -27,11 +30,19 @@ import ActionTypes from 'constants/action-types';
* It should not be called from outside kepler.gl without a valid `inputStyle` in the `mapStyle` reducer.
* param {void}
* @memberof mapStyleActions
- * @type {typeof import('./map-style-actions').addCustomMapStyle}
* @public
*/
-export const addCustomMapStyle = createAction(ActionTypes.ADD_CUSTOM_MAP_STYLE);
+export const addCustomMapStyle: () => {
+ type: typeof ActionTypes.ADD_CUSTOM_MAP_STYLE;
+} = createAction(ActionTypes.ADD_CUSTOM_MAP_STYLE);
+/** INPUT_MAP_STYLE */
+export type InputMapStyleUpdaterAction = {
+ payload: {
+ inputStyle: Partial<InputStyle>;
+ mapState?: MapState;
+ };
+};
/**
* Input a custom map style object
* @memberof mapStyleActions
@@ -43,60 +54,142 @@ export const addCustomMapStyle = createAction(ActionTypes.ADD_CUSTOM_MAP_STYLE);
* @param inputStyle.accessToken - mapbox access token
* @param inputStyle.icon - icon image data url
* @param [mapState] - mapState is optional
- * @type {typeof import('./map-style-actions').inputMapStyle}
* @public
*/
-export const inputMapStyle = createAction(ActionTypes.INPUT_MAP_STYLE, (inputStyle, mapState) => ({
- inputStyle,
- mapState
-}));
+export const inputMapStyle: (
+ inputStyle: InputMapStyleUpdaterAction['payload']['inputStyle'],
+ mapState?: InputMapStyleUpdaterAction['payload']['mapState']
+) => Merge<InputMapStyleUpdaterAction, {type: typeof ActionTypes.INPUT_MAP_STYLE}> = createAction(
+ ActionTypes.INPUT_MAP_STYLE,
+ (
+ inputStyle: InputMapStyleUpdaterAction['payload']['inputStyle'],
+ mapState: InputMapStyleUpdaterAction['payload']['mapState']
+ ) => ({
+ payload: {
+ inputStyle,
+ mapState
+ }
+ })
+);
+/** MAP_CONFIG_CHANGE */
+export type MapConfigChangeUpdaterAction = {
+ payload: {
+ visibleLayerGroups?: VisibleLayerGroups;
+ topLayerGroups?: VisibleLayerGroups;
+ };
+};
/**
* Update `visibleLayerGroups`to change layer group visibility
* @memberof mapStyleActions
* @param mapStyle new config `{visibleLayerGroups: {label: false, road: true, background: true}}`
- * @type {typeof import('./map-style-actions').mapConfigChange}
* @public
*/
-export const mapConfigChange = createAction(ActionTypes.MAP_CONFIG_CHANGE, mapStyle => mapStyle);
+export const mapConfigChange: (
+ mapStyle: MapConfigChangeUpdaterAction['payload']
+) => Merge<
+ MapConfigChangeUpdaterAction,
+ {type: typeof ActionTypes.MAP_CONFIG_CHANGE}
+> = createAction(
+ ActionTypes.MAP_CONFIG_CHANGE,
+ (mapStyle: MapConfigChangeUpdaterAction['payload']) => ({payload: mapStyle})
+);
+/** REQUEST_MAP_STYLES */
+export type RequestMapStylesUpdaterAction = {
+ payload: {
+ [key: string]: {
+ id: string;
+ label?: string;
+ url: string;
+ icon?: string;
+ layerGroups?: string;
+ };
+ };
+};
/**
* Request map style style object based on style.url.
* @memberof mapStyleActions
- * @type {typeof import('./map-style-actions').requestMapStyles}
* @public
*/
-export const requestMapStyles = createAction(
+export const requestMapStyles: (
+ mapStyles: RequestMapStylesUpdaterAction['payload']
+) => Merge<
+ RequestMapStylesUpdaterAction,
+ {type: typeof ActionTypes.REQUEST_MAP_STYLES}
+> = createAction(
ActionTypes.REQUEST_MAP_STYLES,
- mapStyles => mapStyles
+ (mapStyles: RequestMapStylesUpdaterAction['payload']) => ({payload: mapStyles})
);
+
+/** LOAD_MAP_STYLES */
+export type LoadMapStylesUpdaterAction = {
+ payload: MapStyles;
+};
/**
* Callback when load map style success
* @memberof mapStyleActions
* @param newStyles a `{[id]: style}` mapping
- * @type {typeof import('./map-style-actions').loadMapStyles}
* @public
*/
-export const loadMapStyles = createAction(ActionTypes.LOAD_MAP_STYLES, newStyles => newStyles);
+export const loadMapStyles: (
+ newStyles: LoadMapStylesUpdaterAction['payload']
+) => Merge<
+ LoadMapStylesUpdaterAction,
+ {type: typeof ActionTypes.LOAD_MAP_STYLES}
+> = createAction(
+ ActionTypes.LOAD_MAP_STYLES,
+ (newStyles: LoadMapStylesUpdaterAction['payload']) => ({payload: newStyles})
+);
+/** LOAD_MAP_STYLE_ERR */
+export type LoadMapStyleErrUpdaterAction = {
+ payload: Error;
+};
/**
* Callback when load map style error
* @memberof mapStyleActions
* @param error
- * @type {typeof import('./map-style-actions').loadMapStyleErr}
* @public
*/
-export const loadMapStyleErr = createAction(ActionTypes.LOAD_MAP_STYLE_ERR, error => error);
+export const loadMapStyleErr: (
+ error: LoadMapStyleErrUpdaterAction['payload']
+) => Merge<
+ LoadMapStyleErrUpdaterAction,
+ {type: typeof ActionTypes.LOAD_MAP_STYLE_ERR}
+> = createAction(
+ ActionTypes.LOAD_MAP_STYLE_ERR,
+ (error: LoadMapStyleErrUpdaterAction['payload']) => ({payload: error})
+);
+/** MAP_STYLE_CHANGE */
+export type MapStyleChangeUpdaterAction = {
+ payload: string;
+};
/**
* Change to another map style. The selected style should already been loaded into `mapStyle.mapStyles`
* @memberof mapStyleActions
* @param styleType the style to change to
- * @type {typeof import('./map-style-actions').mapStyleChange}
* @public
*/
-export const mapStyleChange = createAction(ActionTypes.MAP_STYLE_CHANGE, styleType => styleType);
+export const mapStyleChange: (
+ styleType: MapStyleChangeUpdaterAction['payload']
+) => Merge<
+ MapStyleChangeUpdaterAction,
+ {type: typeof ActionTypes.MAP_STYLE_CHANGE}
+> = createAction(
+ ActionTypes.MAP_STYLE_CHANGE,
+ (styleType: MapStyleChangeUpdaterAction['payload']) => ({payload: styleType})
+);
+/** LOAD_CUSTOM_MAP_STYLE */
+export type LoadCustomMapStyleUpdaterAction = {
+ payload: {
+ icon?: string;
+ style?: object;
+ error?: Error;
+ };
+};
/**
* Callback when a custom map style object is received
* @memberof mapStyleActions
@@ -104,23 +197,38 @@ export const mapStyleChange = createAction(ActionTypes.MAP_STYLE_CHANGE, styleTy
* @param customMapStyle.icon
* @param customMapStyle.style
* @param customMapStyle.error
- * @type {typeof import('./map-style-actions').loadCustomMapStyle}
* @public
*/
-export const loadCustomMapStyle = createAction(
+export const loadCustomMapStyle: (
+ customMapStyle: LoadCustomMapStyleUpdaterAction['payload']
+) => Merge<
+ LoadCustomMapStyleUpdaterAction,
+ {type: typeof ActionTypes.LOAD_CUSTOM_MAP_STYLE}
+> = createAction(
ActionTypes.LOAD_CUSTOM_MAP_STYLE,
- customMapStyle => customMapStyle
+ (customMapStyle: LoadCustomMapStyleUpdaterAction['payload']) => ({payload: customMapStyle})
);
+/** SET_3D_BUILDING_COLOR */
+export type Set3dBuildingColorUpdaterAction = {
+ payload: RGBColor;
+};
// SET_3D_BUILDING_COLOR
/**
* Set 3d building layer group color
* @memberof mapStyleActions
* @param color - [r, g, b]
- * @type {typeof import('./map-style-actions').set3dBuildingColor}
* @public
*/
-export const set3dBuildingColor = createAction(ActionTypes.SET_3D_BUILDING_COLOR, color => color);
+export const set3dBuildingColor: (
+ color: Set3dBuildingColorUpdaterAction['payload']
+) => Merge<
+ Set3dBuildingColorUpdaterAction,
+ {type: typeof ActionTypes.SET_3D_BUILDING_COLOR}
+> = createAction(
+ ActionTypes.SET_3D_BUILDING_COLOR,
+ (color: Set3dBuildingColorUpdaterAction['payload']) => ({payload: color})
+);
/**
* Actions handled mostly by `mapStyle` reducer.
diff --git a/src/actions/provider-actions.d.ts b/src/actions/provider-actions.d.ts
deleted file mode 100644
index a0c576b63..000000000
--- a/src/actions/provider-actions.d.ts
+++ /dev/null
@@ -1,204 +0,0 @@
-// Copyright (c) 2020 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-// @ts-nocheck
-import {SavedMap} from 'schemas';
-import {MapListItem, Provider} from 'cloud-providers';
-
-type ProviderActionTypes = {
- EXPORT_FILE_TO_CLOUD: string;
- EXPORT_FILE_SUCCESS: string;
- EXPORT_FILE_ERROR: string;
- RESET_PROVIDER_STATUS: string;
- SET_CLOUD_PROVIDER: string;
- POST_SAVE_LOAD_SUCCESS: string;
- LOAD_CLOUD_MAP: string;
- LOAD_CLOUD_MAP_SUCCESS: string;
- LOAD_CLOUD_MAP_ERROR: string;
- GET_SAVED_MAPS: string;
- GET_SAVED_MAPS_SUCCESS: string;
- GET_SAVED_MAPS_ERROR: string;
-};
-
-/** EXPORT_FILE_TO_CLOUD */
-export type MapData = {
- map: SavedMap;
- thumbnail: Blob | null;
-};
-export type ExportFileOptions = {
- isPublic?: boolean;
- overwrite?: boolean;
-};
-export type OnErrorCallBack = (error: Error) => any;
-export type OnSuccessCallBack = (p: {
- response: any;
- provider: Provider;
- options: ExportFileOptions;
-}) => any;
-
-export type ExportFileToCloudPayload = {
- mapData: MapData;
- provider: Provider;
- options: ExportFileOptions;
- onSuccess?: OnSuccessCallBack;
- onError?: OnErrorCallBack;
- closeModal?: boolean;
-};
-
-export function exportFileToCloud(
- p: ExportFileToCloudPayload
-): {
- type: ProviderActionTypes.EXPORT_FILE_TO_CLOUD;
- payload: ExportFileToCloudPayload;
-};
-
-/** EXPORT_FILE_SUCCESS */
-export type ExportFileSuccessPayload = {
- response: any;
- provider: Provider;
- options?: ExportFileOptions;
- onSuccess?: OnSuccessCallBack;
- closeModal?: boolean;
-};
-export function exportFileSuccess(
- p: ExportFileSuccessPayload
-): {
- type: ProviderActionTypes.EXPORT_FILE_SUCCESS;
- payload: ExportFileSuccessPayload;
-};
-
-/** EXPORT_FILE_ERROR */
-export type ExportFileErrorPayload = {
- error: any;
- provider: Provider;
- options?: Options;
- onError?: OnErrorCallBack;
-};
-
-export function exportFileError(
- p: ExportFileErrorPayload
-): {
- type: ProviderActionTypes.EXPORT_FILE_ERROR;
- payload: ExportFileErrorPayload;
-};
-
-/** RESET_PROVIDER_STATUS */
-export function resetProviderStatus(): {
- type: ProviderActionTypes.RESET_PROVIDER_STATUS;
-};
-
-/** SET_CLOUD_PROVIDER */
-export type SetCloudProviderPayload = string;
-export function setCloudProvider(
- p: SetCloudProviderPayload
-): {
- type: ProviderActionTypes.SET_CLOUD_PROVIDER;
- payload: SetCloudProviderPayload;
-};
-
-/** POST_SAVE_LOAD_SUCCESS */
-export type PostSaveLoadSuccessPayload = string;
-export function postSaveLoadSuccess(
- p: PostSaveLoadSuccessPayload
-): {
- type: ProviderActionTypes.POST_SAVE_LOAD_SUCCESS;
- payload: PostSaveLoadSuccessPayload;
-};
-
-/** LOAD_CLOUD_MAP */
-type LoadCloudMapSuccessCallback = (p: {
- response: any;
- loadParams: any;
- provider: Provider;
-}) => any;
-export type LoadCloudMapPayload = {
- loadParams: any;
- provider: string;
- onSuccess?: any;
- onError?: OnErrorCallBack;
-};
-export function loadCloudMap(
- p: LoadCloudMapPayload
-): {
- type: ProviderActionTypes.LOAD_CLOUD_MAP;
- payload: LoadCloudMapPayload;
-};
-
-/** LOAD_CLOUD_MAP_SUCCESS */
-export type LoadCloudMapSuccessPayload = {
- response: any;
- loadParams: any;
- provider: Provider;
- onSuccess?: LoadCloudMapSuccessCallback;
- onError?: OnErrorCallBack;
-};
-export function loadCloudMapSuccess(
- p: LoadCloudMapSuccessPayload
-): {
- type: ProviderActionTypes.LOAD_CLOUD_MAP_SUCCESS;
- payload: LoadCloudMapSuccessPayload;
-};
-
-/** LOAD_CLOUD_MAP_ERROR */
-export type LoadCloudMapErrorPayload = {
- error: any;
- provider: Provider;
- onError?: OnErrorCallBack;
-};
-export function loadCloudMapError(
- p: LoadCloudMapErrorPayload
-): {
- type: ProviderActionTypes.LOAD_CLOUD_MAP_ERROR;
- payload: LoadCloudMapErrorPayload;
-};
-
-/** GET_SAVED_MAPS */
-export type GetSavedMapsPayload = string;
-export function getSavedMaps(
- p: GetSavedMapsPayload
-): {
- type: ProviderActionTypes.GET_SAVED_MAPS;
- payload: GetSavedMapsPayload;
-};
-
-/** GET_SAVED_MAPS_SUCCESS */
-export type GetSavedMapsSuccessPayload = {
- visualizations: MapListItem[];
- provider: string;
-};
-export function getSavedMapsSuccess(
- p: GetSavedMapsSuccessPayload
-): {
- type: ProviderActionTypes.GET_SAVED_MAPS_SUCCESS;
- payload: GetSavedMapsSuccessPayload;
-};
-
-/** GET_SAVED_MAPS_ERROR */
-export type GetSavedMapsErrorPayload = {
- error: any;
- provider: string;
-};
-export function getSavedMapsError(
- p: GetSavedMapsErrorPayload
-): {
- type: ProviderActionTypes.GET_SAVED_MAPS_ERROR;
- payload: GetSavedMapsErrorPayload;
-};
-
-export const ActionTypes: ProviderActionTypes;
diff --git a/src/actions/provider-actions.ts b/src/actions/provider-actions.ts
index c69db9d0a..fb07438a6 100644
--- a/src/actions/provider-actions.ts
+++ b/src/actions/provider-actions.ts
@@ -18,11 +18,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-import {createAction} from 'redux-actions';
+import {createAction} from '@reduxjs/toolkit';
import {ACTION_PREFIX} from 'constants/action-types';
+import {SavedMap} from 'schemas';
+import {MapListItem, Provider} from 'cloud-providers';
-/** @type {import('./provider-actions').ProviderActionTypes} */
-export const ActionTypes = {
+const assignType = <T>(obj: T): { [K in keyof T]: `${typeof ACTION_PREFIX}${string & K}`; } => obj as any
+export const ActionTypes = assignType({
EXPORT_FILE_TO_CLOUD: `${ACTION_PREFIX}EXPORT_FILE_TO_CLOUD`,
EXPORT_FILE_SUCCESS: `${ACTION_PREFIX}EXPORT_FILE_SUCCESS`,
EXPORT_FILE_ERROR: `${ACTION_PREFIX}EXPORT_FILE_ERROR`,
@@ -35,8 +37,32 @@ export const ActionTypes = {
GET_SAVED_MAPS: `${ACTION_PREFIX}GET_SAVED_MAPS`,
GET_SAVED_MAPS_SUCCESS: `${ACTION_PREFIX}GET_SAVED_MAPS_SUCCESS`,
GET_SAVED_MAPS_ERROR: `${ACTION_PREFIX}GET_SAVED_MAPS_ERROR`
+});
+
+/** EXPORT_FILE_TO_CLOUD */
+export type MapData = {
+ map: SavedMap;
+ thumbnail: Blob | null;
+};
+export type ExportFileOptions = {
+ isPublic?: boolean;
+ overwrite?: boolean;
};
+export type OnErrorCallBack = (error: Error) => any;
+export type OnSuccessCallBack = (p: {
+ response: any;
+ provider: Provider;
+ options: ExportFileOptions;
+}) => any;
+export type ExportFileToCloudPayload = {
+ mapData: MapData;
+ provider: Provider;
+ options: ExportFileOptions;
+ onSuccess?: OnSuccessCallBack;
+ onError?: OnErrorCallBack;
+ closeModal?: boolean;
+};
/**
* Call provider to upload file to cloud
* @param mapData
@@ -45,50 +71,148 @@ export const ActionTypes = {
* @param onSuccess
* @param onError
* @param closeModal
- * @type {typeof import('./provider-actions').exportFileToCloud}
*/
-export const exportFileToCloud = createAction(ActionTypes.EXPORT_FILE_TO_CLOUD, payload => payload);
+export const exportFileToCloud: (
+ p: ExportFileToCloudPayload
+) => {
+ type: typeof ActionTypes.EXPORT_FILE_TO_CLOUD;
+ payload: ExportFileToCloudPayload;
+} = createAction(ActionTypes.EXPORT_FILE_TO_CLOUD, (payload: ExportFileToCloudPayload) => ({payload}));
-/**
- * @type {typeof import('./provider-actions').exportFileSuccess}
- */
-export const exportFileSuccess = createAction(ActionTypes.EXPORT_FILE_SUCCESS, payload => payload);
+/** EXPORT_FILE_SUCCESS */
+export type ExportFileSuccessPayload = {
+ response: any;
+ provider: Provider;
+ options?: ExportFileOptions;
+ onSuccess?: OnSuccessCallBack;
+ closeModal?: boolean;
+};
+
+export const exportFileSuccess: (
+ p: ExportFileSuccessPayload
+) => {
+ type: typeof ActionTypes.EXPORT_FILE_SUCCESS;
+ payload: ExportFileSuccessPayload;
+} = createAction(ActionTypes.EXPORT_FILE_SUCCESS, (payload: ExportFileSuccessPayload) => ({payload}));
-/** @type {typeof import('./provider-actions').exportFileError} */
-export const exportFileError = createAction(ActionTypes.EXPORT_FILE_ERROR, payload => payload);
+/** EXPORT_FILE_ERROR */
+export type ExportFileErrorPayload = {
+ error: any;
+ provider: Provider;
+ options?: ExportFileOptions;
+ onError?: OnErrorCallBack;
+};
+
+export const exportFileError: (
+ p: ExportFileErrorPayload
+) => {
+ type: typeof ActionTypes.EXPORT_FILE_ERROR;
+ payload: ExportFileErrorPayload;
+} = createAction(ActionTypes.EXPORT_FILE_ERROR, (payload: ExportFileErrorPayload) => ({payload}));
-/** @type {typeof import('./provider-actions').postSaveLoadSuccess} */
-export const postSaveLoadSuccess = createAction(
+/** POST_SAVE_LOAD_SUCCESS */
+export type PostSaveLoadSuccessPayload = string;
+export const postSaveLoadSuccess: (
+ p: PostSaveLoadSuccessPayload
+) => {
+ type: typeof ActionTypes.POST_SAVE_LOAD_SUCCESS;
+ payload: PostSaveLoadSuccessPayload;
+} = createAction(
ActionTypes.POST_SAVE_LOAD_SUCCESS,
- message => message
+ (message: PostSaveLoadSuccessPayload) => ({payload : message})
);
-/** @type {typeof import('./provider-actions').resetProviderStatus} */
-export const resetProviderStatus = createAction(ActionTypes.RESET_PROVIDER_STATUS);
+export const resetProviderStatus: () => {
+ type: typeof ActionTypes.RESET_PROVIDER_STATUS;
+} = createAction(ActionTypes.RESET_PROVIDER_STATUS);
-/** @type {typeof import('./provider-actions').setCloudProvider} */
-export const setCloudProvider = createAction(ActionTypes.SET_CLOUD_PROVIDER, provider => provider);
+/** SET_CLOUD_PROVIDER */
+export type SetCloudProviderPayload = string;
+export const setCloudProvider: (
+ p: SetCloudProviderPayload
+) => {
+ type: typeof ActionTypes.SET_CLOUD_PROVIDER;
+ payload: SetCloudProviderPayload;
+} = createAction(ActionTypes.SET_CLOUD_PROVIDER, (provider: SetCloudProviderPayload) => ({payload : provider}));
-/** @type {typeof import('./provider-actions').loadCloudMap} */
-export const loadCloudMap = createAction(ActionTypes.LOAD_CLOUD_MAP, payload => payload);
+/** LOAD_CLOUD_MAP */
+export type LoadCloudMapPayload = {
+ loadParams: any;
+ provider: string;
+ onSuccess?: any;
+ onError?: OnErrorCallBack;
+};
+export const loadCloudMap: (
+ p: LoadCloudMapPayload
+) => {
+ type: typeof ActionTypes.LOAD_CLOUD_MAP;
+ payload: LoadCloudMapPayload;
+} = createAction(ActionTypes.LOAD_CLOUD_MAP, payload => ({payload : payload}));
-/** @type {typeof import('./provider-actions').loadCloudMapSuccess} */
-export const loadCloudMapSuccess = createAction(
+/** LOAD_CLOUD_MAP_SUCCESS */
+type LoadCloudMapSuccessCallback = (p: {response: any; loadParams: any; provider: Provider}) => any;
+export type LoadCloudMapSuccessPayload = {
+ response: any;
+ loadParams: any;
+ provider: Provider;
+ onSuccess?: LoadCloudMapSuccessCallback;
+ onError?: OnErrorCallBack;
+};
+export const loadCloudMapSuccess: (
+ p: LoadCloudMapSuccessPayload
+) => {
+ type: typeof ActionTypes.LOAD_CLOUD_MAP_SUCCESS;
+ payload: LoadCloudMapSuccessPayload;
+} = createAction(
ActionTypes.LOAD_CLOUD_MAP_SUCCESS,
- payload => payload
+ (payload: LoadCloudMapSuccessPayload) => ({payload : payload})
);
-/** @type {typeof import('./provider-actions').loadCloudMapError} */
-export const loadCloudMapError = createAction(ActionTypes.LOAD_CLOUD_MAP_ERROR, payload => payload);
+/** LOAD_CLOUD_MAP_ERROR */
+export type LoadCloudMapErrorPayload = {
+ error: any;
+ provider: Provider;
+ onError?: OnErrorCallBack;
+};
+export const loadCloudMapError: (
+ p: LoadCloudMapErrorPayload
+) => {
+ type: typeof ActionTypes.LOAD_CLOUD_MAP_ERROR;
+ payload: LoadCloudMapErrorPayload;
+} = createAction(ActionTypes.LOAD_CLOUD_MAP_ERROR, (payload: LoadCloudMapErrorPayload) => ({payload : payload}));
-/** @type {typeof import('./provider-actions').getSavedMaps} */
-export const getSavedMaps = createAction(ActionTypes.GET_SAVED_MAPS, provider => provider);
+/** GET_SAVED_MAPS */
+export type GetSavedMapsPayload = string;
+export const getSavedMaps: (
+ p: GetSavedMapsPayload
+) => {
+ type: typeof ActionTypes.GET_SAVED_MAPS;
+ payload: GetSavedMapsPayload;
+} = createAction(ActionTypes.GET_SAVED_MAPS, (provider: GetSavedMapsPayload) => ({payload : provider}));
-/** @type {typeof import('./provider-actions').getSavedMapsSuccess} */
-export const getSavedMapsSuccess = createAction(
+/** GET_SAVED_MAPS_SUCCESS */
+export type GetSavedMapsSuccessPayload = {
+ visualizations: MapListItem[];
+ provider: string;
+};
+export const getSavedMapsSuccess: (
+ p: GetSavedMapsSuccessPayload
+) => {
+ type: typeof ActionTypes.GET_SAVED_MAPS_SUCCESS;
+ payload: GetSavedMapsSuccessPayload;
+} = createAction(
ActionTypes.GET_SAVED_MAPS_SUCCESS,
- payload => payload
+ (payload: GetSavedMapsSuccessPayload) => ({payload : payload})
);
-/** @type {typeof import('./provider-actions').getSavedMapsError} */
-export const getSavedMapsError = createAction(ActionTypes.GET_SAVED_MAPS_ERROR, payload => payload);
+/** GET_SAVED_MAPS_ERROR */
+export type GetSavedMapsErrorPayload = {
+ error: any;
+ provider: string;
+};
+export const getSavedMapsError: (
+ p: GetSavedMapsErrorPayload
+) => {
+ type: typeof ActionTypes.GET_SAVED_MAPS_ERROR;
+ payload: GetSavedMapsErrorPayload;
+} = createAction(ActionTypes.GET_SAVED_MAPS_ERROR, payload => ({payload : payload}));
diff --git a/src/actions/ui-state-actions.d.ts b/src/actions/ui-state-actions.d.ts
deleted file mode 100644
index c374bb19d..000000000
--- a/src/actions/ui-state-actions.d.ts
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright (c) 2020 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-// @ts-nocheck
-import ActionTypes from 'constants/action-types';
-import {Merge} from '../reducers/types';
-import {ExportImage} from '../reducers/ui-state-updaters';
-
-/** TOGGLE_SIDE_PANEL */
-export type ToggleSidePanelUpdaterAction = {
- payload: string;
-};
-export function toggleSidePanel(
- id: string
-): Merge<ToggleSidePanelUpdaterAction, {type: ActionTypes.TOGGLE_SIDE_PANEL}>;
-
-/** TOGGLE_MODAL */
-export type ToggleModalUpdaterAction = {
- payload: string | null;
-};
-export function toggleModal(
- id: string | null
-): Merge<ToggleModalUpdaterAction, {type: ActionTypes.TOGGLE_MODAL}>;
-
-/** SHOW_EXPORT_DROPDOWN */
-export type ShowExportDropdownUpdaterAction = {
- payload: string;
-};
-export function showExportDropdown(
- id: string
-): Merge<ShowExportDropdownUpdaterAction, {type: ActionTypes.SHOW_EXPORT_DROPDOWN}>;
-
-/** HIDE_EXPORT_DROPDOWN */
-export function hideExportDropdown(): {type: ActionTypes.HIDE_EXPORT_DROPDOWN};
-
-/** TOGGLE_MAP_CONTROL */
-export type ToggleMapControlUpdaterAction = {
- payload: {
- panelId: string;
- index: number;
- };
-};
-export function toggleMapControl(
- panelId: string,
- index: number
-): Merge<ToggleMapControlUpdaterAction, {type: ActionTypes.TOGGLE_MAP_CONTROL}>;
-
-
-/** SET_MAP_CONTROL_VISIBILITY */
-export type setMapControlVisibilityUpdaterAction = {
- payload: {
- panelId: string;
- show: boolean;
- };
-};
-export function setMapControlVisibility(
- panelId: string,
- show: boolean
-): Merge<setMapControlVisibilityUpdaterAction, {type: ActionTypes.SET_MAP_CONTROL_VISIBILITY}>;
-
-/** OPEN_DELETE_MODAL */
-export type OpenDeleteModalUpdaterAction = {
- payload: string;
-};
-export function openDeleteModal(
- datasetId: string
-): Merge<OpenDeleteModalUpdaterAction, {type: ActionTypes.OPEN_DELETE_MODAL}>;
-
-/** ADD_NOTIFICATION */
-export type AddNotificationUpdaterAction = {
- payload: object;
-};
-export function addNotification(
- notification: object
-): Merge<
- AddNotificationUpdaterAction,
- {
- type: ActionTypes.ADD_NOTIFICATION;
- }
->;
-
-/** REMOVE_NOTIFICATION */
-export type RemoveNotificationUpdaterAction = {
- payload: string;
-};
-export function removeNotification(
- id: string
-): Merge<RemoveNotificationUpdaterAction, {type: ActionTypes.REMOVE_NOTIFICATION}>;
-
-/** SET_EXPORT_IMAGE_SETTING */
-export type SetExportImageSettingUpdaterAction = {
- payload: Partial<ExportImage>;
-};
-export function setExportImageSetting(
- newSetting: SetExportImageSettingUpdaterAction['payload']
-): Merge<SetExportImageSettingUpdaterAction, {type: ActionTypes.SET_EXPORT_IMAGE_SETTING}>;
-
-/** START_EXPORTING_IMAGE */
-export function startExportingImage(options?: {
- ratio?: string;
- resolution?: string;
- legend?: string;
- center?: boolean;
-}): Merge<SetExportImageSettingUpdaterAction, {type: ActionTypes.START_EXPORT_IMAGE}>;
-
-/** SET_EXPORT_IMAGE_DATA_URI */
-export type SetExportImageDataUriUpdaterAction = {
- payload: string;
-};
-export function setExportImageDataUri(): Merge<
- SetExportImageDataUriUpdaterAction,
- {type: ActionTypes.SET_EXPORT_IMAGE_DATA_URI}
->;
-
-/** SET_EXPORT_IMAGE_ERROR */
-export type SetExportImageErrorUpdaterAction = {
- payload: Error;
-};
-export function setExportImageError(
- error: Error
-): Merge<SetExportImageErrorUpdaterAction, {type: ActionTypes.SET_EXPORT_IMAGE_ERROR}>;
-
-/** CLEANUP_EXPORT_IMAGE */
-export function cleanupExportImage(): {type: ActionTypes.CLEANUP_EXPORT_IMAGE};
-
-/** SET_EXPORT_SELECTED_DATASET */
-export type SetExportSelectedDatasetUpdaterAction = {
- payload: string;
-};
-export function setExportSelectedDataset(
- datasetId: string
-): Merge<SetExportSelectedDatasetUpdaterAction, {type: ActionTypes.SET_EXPORT_SELECTED_DATASET}>;
-
-/** SET_EXPORT_DATA_TYPE */
-export type SetExportDataTypeUpdaterAction = {
- payload: string;
-};
-export function setExportDataType(
- dataType: string
-): Merge<SetExportDataTypeUpdaterAction, {type: ActionTypes.SET_EXPORT_DATA_TYPE}>;
-
-/** SET_EXPORT_FILTERED */
-export type SetExportFilteredUpdaterAction = {
- payload: boolean;
-};
-export function setExportFiltered(
- exportFiltered: boolean
-): Merge<SetExportFilteredUpdaterAction, {type: ActionTypes.SET_EXPORT_FILTERED}>;
-
-/** SET_EXPORT_DATA */
-export function setExportData(): {type: ActionTypes.SET_EXPORT_DATA};
-
-/** SET_USER_MAPBOX_ACCESS_TOKEN */
-export type SetUserMapboxAccessTokenUpdaterAction = {
- payload: string;
-};
-export function setUserMapboxAccessToken(): Merge<
- SetUserMapboxAccessTokenUpdaterAction,
- {type: ActionTypes.SET_USER_MAPBOX_ACCESS_TOKEN}
->;
-
-/** SET_EXPORT_MAP_FORMAT */
-export type SetExportMapFormatUpdaterAction = {
- payload: string;
-};
-export function setExportMapFormat(
- mapFormat: string
-): Merge<SetExportMapFormatUpdaterAction, {type: ActionTypes.SET_EXPORT_MAP_FORMAT}>;
-
-/** SET_EXPORT_MAP_HTML_MODE */
-export type SetExportHTMLMapModeUpdaterAction = {
- payload: string;
-};
-export function setExportHTMLMapMode(
- mode: string
-): Merge<SetExportHTMLMapModeUpdaterAction, {type: ActionTypes.SET_EXPORT_MAP_HTML_MODE}>;
-
-/** SET_LOCALE */
-export type SetLocaleUpdaterAction = {
- payload: {locale: string};
-};
-export function setLocale(
- locale: string
-): Merge<SetLocaleUpdaterAction, {type: ActionTypes.SET_LOCALE}>;
-
-/** TOGGLE_LAYER_PANEL_LIST_VIEW */
-export type ToggleLayerPanelListViewAction = {
- payload: string;
-}
-export function toggleLayerPanelListView(
- listView: string
-): Merge<ToggleLayerPanelListViewAction, {type: ActionTypes.TOGGLE_LAYER_PANEL_LIST_VIEW}>;
diff --git a/src/actions/ui-state-actions.ts b/src/actions/ui-state-actions.ts
index b524a99e1..088346fb8 100644
--- a/src/actions/ui-state-actions.ts
+++ b/src/actions/ui-state-actions.ts
@@ -18,18 +18,32 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-import {createAction} from 'redux-actions';
+import {createAction} from '@reduxjs/toolkit';
import ActionTypes from 'constants/action-types';
+import {Merge} from '../reducers/types';
+import {ExportImage} from '../reducers/ui-state-updaters';
+/** TOGGLE_SIDE_PANEL */
+export type ToggleSidePanelUpdaterAction = {
+ payload: string;
+};
/**
* Toggle active side panel
* @memberof uiStateActions
* @param id id of side panel to be shown, one of `layer`, `filter`, `interaction`, `map`
- * @type {typeof import('./ui-state-actions').toggleSidePanel}
* @public
*/
-export const toggleSidePanel = createAction(ActionTypes.TOGGLE_SIDE_PANEL, id => id);
+export const toggleSidePanel: (
+ id: string
+) => Merge<
+ ToggleSidePanelUpdaterAction,
+ {type: typeof ActionTypes.TOGGLE_SIDE_PANEL}
+> = createAction(ActionTypes.TOGGLE_SIDE_PANEL, (id: string) => ({payload: id}));
+/** TOGGLE_MODAL */
+export type ToggleModalUpdaterAction = {
+ payload: string | null;
+};
/**
* Show and hide modal dialog
* @memberof uiStateActions
@@ -40,220 +54,424 @@ export const toggleSidePanel = createAction(ActionTypes.TOGGLE_SIDE_PANEL, id =>
* - [`EXPORT_IMAGE_ID`](../constants/default-settings.md#export_image_id)
* - [`EXPORT_DATA_ID`](../constants/default-settings.md#export_data_id)
* - [`ADD_MAP_STYLE_ID`](../constants/default-settings.md#add_map_style_id)
- * @type {typeof import('./ui-state-actions').toggleModal}
* @public
*/
-export const toggleModal = createAction(ActionTypes.TOGGLE_MODAL, id => id);
+export const toggleModal: (
+ id: ToggleModalUpdaterAction['payload']
+) => Merge<ToggleModalUpdaterAction, {type: typeof ActionTypes.TOGGLE_MODAL}> = createAction(
+ ActionTypes.TOGGLE_MODAL,
+ (id: ToggleModalUpdaterAction['payload']) => ({
+ payload: id
+ })
+);
+/** SHOW_EXPORT_DROPDOWN */
+export type ShowExportDropdownUpdaterAction = {
+ payload: string;
+};
/**
* Hide and show side panel header dropdown, activated by clicking the share link on top of the side panel
* @memberof uiStateActions
* @param id - id of the dropdown
- * @type {typeof import('./ui-state-actions').showExportDropdown}
* @public
*/
-export const showExportDropdown = createAction(ActionTypes.SHOW_EXPORT_DROPDOWN, id => id);
+export const showExportDropdown: (
+ id: ShowExportDropdownUpdaterAction['payload']
+) => Merge<
+ ShowExportDropdownUpdaterAction,
+ {type: typeof ActionTypes.SHOW_EXPORT_DROPDOWN}
+> = createAction(
+ ActionTypes.SHOW_EXPORT_DROPDOWN,
+ (id: ShowExportDropdownUpdaterAction['payload']) => ({payload: id})
+);
/**
* Hide side panel header dropdown, activated by clicking the share link on top of the side panel
* @memberof uiStateActions
- * @type {typeof import('./ui-state-actions').hideExportDropdown}
* @public
*/
-export const hideExportDropdown = createAction(ActionTypes.HIDE_EXPORT_DROPDOWN);
+export const hideExportDropdown: () => {
+ type: typeof ActionTypes.HIDE_EXPORT_DROPDOWN;
+} = createAction(ActionTypes.HIDE_EXPORT_DROPDOWN);
+/** TOGGLE_MAP_CONTROL */
+export type ToggleMapControlUpdaterAction = {
+ payload: {
+ panelId: string;
+ index: number;
+ };
+};
/**
* Toggle active map control panel
* @memberof uiStateActions
* @param panelId - map control panel id, one of the keys of: [`DEFAULT_MAP_CONTROLS`](#default_map_controls)
- * @type {typeof import('./ui-state-actions').toggleMapControl}
* @public
*/
-export const toggleMapControl = createAction(ActionTypes.TOGGLE_MAP_CONTROL, (panelId, index) => ({
- panelId,
- index
-}));
+export const toggleMapControl: (
+ panelId: ToggleMapControlUpdaterAction['payload']['panelId'],
+ index: ToggleMapControlUpdaterAction['payload']['index']
+) => Merge<
+ ToggleMapControlUpdaterAction,
+ {type: typeof ActionTypes.TOGGLE_MAP_CONTROL}
+> = createAction(
+ ActionTypes.TOGGLE_MAP_CONTROL,
+ (
+ panelId: ToggleMapControlUpdaterAction['payload']['panelId'],
+ index: ToggleMapControlUpdaterAction['payload']['index']
+ ) => ({
+ payload: {
+ panelId,
+ index
+ }
+ })
+);
+/** SET_MAP_CONTROL_VISIBILITY */
+export type setMapControlVisibilityUpdaterAction = {
+ payload: {
+ panelId: string;
+ show: boolean;
+ };
+};
/**
* Toggle active map control panel
* @memberof uiStateActions
* @param panelId - map control panel id, one of the keys of: [`DEFAULT_MAP_CONTROLS`](#default_map_controls)
- * @type {typeof import('./ui-state-actions').setMapControlVisibility}
* @public
*/
-export const setMapControlVisibility = createAction(
+export const setMapControlVisibility: (
+ panelId: setMapControlVisibilityUpdaterAction['payload']['panelId'],
+ show: setMapControlVisibilityUpdaterAction['payload']['show']
+) => Merge<
+ setMapControlVisibilityUpdaterAction,
+ {type: typeof ActionTypes.SET_MAP_CONTROL_VISIBILITY}
+> = createAction(
ActionTypes.SET_MAP_CONTROL_VISIBILITY,
- (panelId, show) => ({
- panelId,
- show
+ (
+ panelId: setMapControlVisibilityUpdaterAction['payload']['panelId'],
+ show: setMapControlVisibilityUpdaterAction['payload']['show']
+ ) => ({
+ payload: {
+ panelId,
+ show
+ }
})
);
+/** OPEN_DELETE_MODAL */
+export type OpenDeleteModalUpdaterAction = {
+ payload: string;
+};
/**
* Toggle active map control panel
* @memberof uiStateActions
* @param datasetId - `id` of the dataset to be deleted
- * @type {typeof import('./ui-state-actions').openDeleteModal}
* @public
*/
-export const openDeleteModal = createAction(ActionTypes.OPEN_DELETE_MODAL, datasetId => datasetId);
+export const openDeleteModal: (
+ datasetId: OpenDeleteModalUpdaterAction['payload']
+) => Merge<
+ OpenDeleteModalUpdaterAction,
+ {type: typeof ActionTypes.OPEN_DELETE_MODAL}
+> = createAction(
+ ActionTypes.OPEN_DELETE_MODAL,
+ (datasetId: OpenDeleteModalUpdaterAction['payload']) => ({payload: datasetId})
+);
+/** ADD_NOTIFICATION */
+export type AddNotificationUpdaterAction = {
+ payload: object;
+};
/**
* Add a notification to be displayed.
* Existing notification will be updated in case of matching id.
* @memberof uiStateActions
* @param notification - The `notification` object to be added or updated
- * @type {typeof import('./ui-state-actions').addNotification}
* @public
*/
-export const addNotification = createAction(
+export const addNotification: (
+ notification: AddNotificationUpdaterAction['payload']
+) => Merge<
+ AddNotificationUpdaterAction,
+ {
+ type: typeof ActionTypes.ADD_NOTIFICATION;
+ }
+> = createAction(
ActionTypes.ADD_NOTIFICATION,
- notification => notification
+ (notification: AddNotificationUpdaterAction['payload']) => ({payload: notification})
);
+/** REMOVE_NOTIFICATION */
+export type RemoveNotificationUpdaterAction = {
+ payload: string;
+};
/**
* Remove a notification
* @memberof uiStateActions
* @param id - `id` of the notification to be removed
- * @type {typeof import('./ui-state-actions').removeNotification}
* @public
*/
-export const removeNotification = createAction(ActionTypes.REMOVE_NOTIFICATION, id => id);
+export const removeNotification: (
+ id: RemoveNotificationUpdaterAction['payload']
+) => Merge<
+ RemoveNotificationUpdaterAction,
+ {type: typeof ActionTypes.REMOVE_NOTIFICATION}
+> = createAction(
+ ActionTypes.REMOVE_NOTIFICATION,
+ (id: RemoveNotificationUpdaterAction['payload']) => ({payload: id})
+);
+/** SET_EXPORT_IMAGE_SETTING */
+export type SetExportImageSettingUpdaterAction = {
+ payload: Partial<ExportImage>;
+};
/**
* Set `exportImage` settings: ratio, resolution, legend
* @memberof uiStateActions
* @param newSetting - {ratio: '1x'}
- * @type {typeof import('./ui-state-actions').setExportImageSetting}
* @public
*/
-export const setExportImageSetting = createAction(
+export const setExportImageSetting: (
+ newSetting: SetExportImageSettingUpdaterAction['payload']
+) => Merge<
+ SetExportImageSettingUpdaterAction,
+ {type: typeof ActionTypes.SET_EXPORT_IMAGE_SETTING}
+> = createAction(
ActionTypes.SET_EXPORT_IMAGE_SETTING,
- newSetting => newSetting
+ (newSetting: SetExportImageSettingUpdaterAction['payload']) => ({payload: newSetting})
);
/**
* Start exporting image flow
* @memberof uiStateActions
- * @type {typeof import('./ui-state-actions').startExportingImage}
* @public
*/
-export const startExportingImage = createAction(ActionTypes.START_EXPORTING_IMAGE);
+export const startExportingImage: (options?: {
+ ratio?: string;
+ resolution?: string;
+ legend?: string;
+ center?: boolean;
+}) => Merge<
+ SetExportImageSettingUpdaterAction,
+ {type: typeof ActionTypes.START_EXPORTING_IMAGE}
+> = createAction(ActionTypes.START_EXPORTING_IMAGE, (payload: any) => ({payload}));
+/** SET_EXPORT_IMAGE_DATA_URI */
+export type SetExportImageDataUriUpdaterAction = {
+ payload: string;
+};
/**
* Set `exportImage.setExportImageDataUri` to a dataUri
* @memberof uiStateActions
* @param dataUri - export image data uri
- * @type {typeof import('./ui-state-actions').setExportImageDataUri}
* @public
*/
-export const setExportImageDataUri = createAction(
+export const setExportImageDataUri: (
+ dataUri: SetExportImageDataUriUpdaterAction['payload']
+) => Merge<
+ SetExportImageDataUriUpdaterAction,
+ {type: typeof ActionTypes.SET_EXPORT_IMAGE_DATA_URI}
+> = createAction(
ActionTypes.SET_EXPORT_IMAGE_DATA_URI,
- dataUri => dataUri
+ (dataUri: SetExportImageDataUriUpdaterAction['payload']) => ({payload: dataUri})
);
+/** SET_EXPORT_IMAGE_ERROR */
+export type SetExportImageErrorUpdaterAction = {
+ payload: Error;
+};
/**
* Set Export image error
* @memberof uiStateActions
- * @type {typeof import('./ui-state-actions').setExportImageError}
* @public
*/
-export const setExportImageError = createAction(ActionTypes.SET_EXPORT_IMAGE_ERROR, error => error);
+export const setExportImageError: (
+ error: SetExportImageErrorUpdaterAction['payload']
+) => Merge<
+ SetExportImageErrorUpdaterAction,
+ {type: typeof ActionTypes.SET_EXPORT_IMAGE_ERROR}
+> = createAction(
+ ActionTypes.SET_EXPORT_IMAGE_ERROR,
+ (error: SetExportImageErrorUpdaterAction['payload']) => ({payload: error})
+);
/**
* Delete cached export image
* @memberof uiStateActions
- * @type {typeof import('./ui-state-actions').cleanupExportImage}
* @public
*/
-export const cleanupExportImage = createAction(ActionTypes.CLEANUP_EXPORT_IMAGE);
+export const cleanupExportImage: () => {
+ type: typeof ActionTypes.CLEANUP_EXPORT_IMAGE;
+} = createAction(ActionTypes.CLEANUP_EXPORT_IMAGE);
+/** SET_EXPORT_SELECTED_DATASET */
+export type SetExportSelectedDatasetUpdaterAction = {
+ payload: string;
+};
/**
* Set selected dataset for export
* @memberof uiStateActions
* @param datasetId - dataset id
- * @type {typeof import('./ui-state-actions').setExportSelectedDataset}
* @public
*/
-export const setExportSelectedDataset = createAction(
+export const setExportSelectedDataset: (
+ datasetId: SetExportSelectedDatasetUpdaterAction['payload']
+) => Merge<
+ SetExportSelectedDatasetUpdaterAction,
+ {type: typeof ActionTypes.SET_EXPORT_SELECTED_DATASET}
+> = createAction(
ActionTypes.SET_EXPORT_SELECTED_DATASET,
- datasetId => datasetId
+ (datasetId: SetExportSelectedDatasetUpdaterAction['payload']) => ({payload: datasetId})
);
+/** SET_EXPORT_DATA_TYPE */
+export type SetExportDataTypeUpdaterAction = {
+ payload: string;
+};
/**
* Set data format for exporting data
* @memberof uiStateActions
* @param dataType - one of `'text/csv'`
- * @type {typeof import('./ui-state-actions').setExportDataType}
* @public
*/
-export const setExportDataType = createAction(
+export const setExportDataType: (
+ dataType: SetExportDataTypeUpdaterAction['payload']
+) => Merge<
+ SetExportDataTypeUpdaterAction,
+ {type: typeof ActionTypes.SET_EXPORT_DATA_TYPE}
+> = createAction(
ActionTypes.SET_EXPORT_DATA_TYPE,
- dataType => dataType
+ (dataType: SetExportDataTypeUpdaterAction['payload']) => ({payload: dataType})
);
+/** SET_EXPORT_FILTERED */
+export type SetExportFilteredUpdaterAction = {
+ payload: boolean;
+};
/**
* Whether to export filtered data, `true` or `false`
* @memberof uiStateActions
* @param payload - set `true` to ony export filtered data
- * @type {typeof import('./ui-state-actions').setExportFiltered}
* @public
*/
-export const setExportFiltered = createAction(ActionTypes.SET_EXPORT_FILTERED, payload => payload);
+export const setExportFiltered: (
+ exportFiltered: SetExportFilteredUpdaterAction['payload']
+) => Merge<
+ SetExportFilteredUpdaterAction,
+ {type: typeof ActionTypes.SET_EXPORT_FILTERED}
+> = createAction(
+ ActionTypes.SET_EXPORT_FILTERED,
+ (payload: SetExportFilteredUpdaterAction['payload']) => ({payload})
+);
/**
* Whether to including data in map config, toggle between `true` or `false`
* @memberof uiStateActions
- * @type {typeof import('./ui-state-actions').setExportData}
* @public
*/
-export const setExportData = createAction(ActionTypes.SET_EXPORT_DATA);
+export const setExportData: () => {type: typeof ActionTypes.SET_EXPORT_DATA} = createAction(
+ ActionTypes.SET_EXPORT_DATA
+);
+/** SET_USER_MAPBOX_ACCESS_TOKEN */
+export type SetUserMapboxAccessTokenUpdaterAction = {
+ payload: string;
+};
/**
* Whether we export a mapbox access token used to create a single map html file
* @memberof uiStateActions
* @param payload - mapbox access token
- * @type {typeof import('./ui-state-actions').setUserMapboxAccessToken}
* @public
*/
-export const setUserMapboxAccessToken = createAction(
+export const setUserMapboxAccessToken: (
+ payload: SetUserMapboxAccessTokenUpdaterAction['payload']
+) => Merge<
+ SetUserMapboxAccessTokenUpdaterAction,
+ {type: typeof ActionTypes.SET_USER_MAPBOX_ACCESS_TOKEN}
+> = createAction(
ActionTypes.SET_USER_MAPBOX_ACCESS_TOKEN,
- payload => payload
+ (payload: SetUserMapboxAccessTokenUpdaterAction['payload']) => ({payload})
);
+/** SET_EXPORT_MAP_FORMAT */
+export type SetExportMapFormatUpdaterAction = {
+ payload: string;
+};
/**
* Set the export map format (html, json)
* @memberOf uiStateActions
* @param payload - map format
- * @type {typeof import('./ui-state-actions').setExportMapFormat}
* @public
*/
-export const setExportMapFormat = createAction(
+export const setExportMapFormat: (
+ mapFormat: SetExportMapFormatUpdaterAction['payload']
+) => Merge<
+ SetExportMapFormatUpdaterAction,
+ {type: typeof ActionTypes.SET_EXPORT_MAP_FORMAT}
+> = createAction(
ActionTypes.SET_EXPORT_MAP_FORMAT,
- payload => payload
+ (payload: SetExportMapFormatUpdaterAction['payload']) => ({payload})
);
+/** SET_EXPORT_MAP_HTML_MODE */
+export type SetExportHTMLMapModeUpdaterAction = {
+ payload: string;
+};
/**
* Set the HTML mode to use to export HTML mode
* @memberOf uiStateActions
* @param payload - map mode
- * @type {typeof import('./ui-state-actions').setExportHTMLMapMode}
*/
-export const setExportHTMLMapMode = createAction(
+export const setExportHTMLMapMode: (
+ mode: SetExportHTMLMapModeUpdaterAction['payload']
+) => Merge<
+ SetExportHTMLMapModeUpdaterAction,
+ {type: typeof ActionTypes.SET_EXPORT_MAP_HTML_MODE}
+> = createAction(
ActionTypes.SET_EXPORT_MAP_HTML_MODE,
- payload => payload
+ (payload: SetExportHTMLMapModeUpdaterAction['payload']) => ({payload})
);
+/** SET_LOCALE */
+export type SetLocaleUpdaterAction = {
+ payload: {locale: string};
+};
/**
* Set `locale` value
* @memberof uiStateActions
* @param locale - locale of the UI
- * @type {typeof import('./ui-state-actions').setLocale}
* @public
*/
-export const setLocale = createAction(ActionTypes.SET_LOCALE, locale => ({
- locale
-}));
+export const setLocale: (
+ locale: SetLocaleUpdaterAction['payload']['locale']
+) => Merge<SetLocaleUpdaterAction, {type: typeof ActionTypes.SET_LOCALE}> = createAction(
+ ActionTypes.SET_LOCALE,
+ (locale: SetLocaleUpdaterAction['payload']['locale']) => ({
+ payload: {
+ locale
+ }
+ })
+);
+
+/** TOGGLE_LAYER_PANEL_LIST_VIEW */
+export type ToggleLayerPanelListViewAction = {
+ payload: string;
+};
+/**
+ * Toggle layer panel list view
+ * @memberof uiStateActions
+ * @param listView layer panel listView value. Can be 'list' or 'sortByDataset'
+ * @public
+ */
+export const toggleLayerPanelListView: (
+ listView: ToggleLayerPanelListViewAction['payload']
+) => Merge<
+ ToggleLayerPanelListViewAction,
+ {type: typeof ActionTypes.TOGGLE_LAYER_PANEL_LIST_VIEW}
+> = createAction(
+ ActionTypes.TOGGLE_LAYER_PANEL_LIST_VIEW,
+ (listView: ToggleLayerPanelListViewAction['payload']) => ({payload: listView})
+);
/**
* This declaration is needed to group actions in docs
@@ -270,15 +488,3 @@ export const setLocale = createAction(ActionTypes.SET_LOCALE, locale => ({
// @ts-ignore
const uiStateActions = null;
/* eslint-enable no-unused-vars */
-
-/**
- * Toggle layer panel list view
- * @memberof uiStateActions
- * @param listView layer panel listView value. Can be 'list' or 'sortByDataset'
- * @type {typeof import('./ui-state-actions').toggleLayerPanelListView}
- * @public
- */
-export const toggleLayerPanelListView = createAction(
- ActionTypes.TOGGLE_LAYER_PANEL_LIST_VIEW,
- listView => listView
-);
diff --git a/src/reducers/map-style-updaters.ts b/src/reducers/map-style-updaters.ts
index 09fb34255..344c778a7 100644
--- a/src/reducers/map-style-updaters.ts
+++ b/src/reducers/map-style-updaters.ts
@@ -18,7 +18,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-// @ts-nocheck
import Task, {withTask} from 'react-palm/tasks';
import cloneDeep from 'lodash.clonedeep';