Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
padawannn committed Apr 15, 2024
1 parent 0a55b9b commit 4251da9
Show file tree
Hide file tree
Showing 23 changed files with 367 additions and 478 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"packages/*"
],
"devDependencies": {
"@deck.gl/aggregation-layers": "^9.0.0-beta.1",
"@deck.gl/carto": "^9.0.0-beta.1",
"@deck.gl/core": "^9.0.0-beta.1",
"@deck.gl/extensions": "^9.0.0-beta.1",
"@deck.gl/geo-layers": "^9.0.0-beta.1",
"@deck.gl/google-maps": "^9.0.0-beta.1",
"@deck.gl/layers": "^9.0.0-beta.1",
"@deck.gl/mesh-layers": "^9.0.0-beta.1",
"@deck.gl/aggregation-layers": "^9.0.1",
"@deck.gl/carto": "^9.0.1",
"@deck.gl/core": "^9.0.1",
"@deck.gl/extensions": "^9.0.1",
"@deck.gl/geo-layers": "^9.0.1",
"@deck.gl/google-maps": "^9.0.1",
"@deck.gl/layers": "^9.0.1",
"@deck.gl/mesh-layers": "^9.0.1",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@formatjs/intl-localematcher": "^0.4.0",
Expand Down
26 changes: 0 additions & 26 deletions packages/react-api/__tests__/hooks/useCartoLayerProps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,11 @@ describe('useCartoLayerProps', () => {
'binary',
'onViewportLoad',
'fetch',
'loaders',
'onDataLoad',
'id',
'visible',
'opacity',
'uniqueIdProperty',
'data',
'type',
'geoColumn',
'aggregationExp',
'provider',
'connection',
'credentials',
'clientId',
'queryParameters',
'filterRange',
'updateTriggers',
'getFilterValue',
Expand Down Expand Up @@ -90,22 +80,6 @@ describe('useCartoLayerProps', () => {
});
});

test('should return correct props when source geo column is set', () => {
const source = {
credentials: {
apiVersion: API_VERSIONS.V2
},
geoColumn: 'column_name',
aggregationExp: 'agg_exp'
};

const { result } = renderHook(() => useCartoLayerProps({ source }));

expect(Object.keys(result.current)).toEqual([...COMMON_PROPS]);
expect(result.current.geoColumn).toBe(source.geoColumn);
expect(result.current.aggregationExp).toBe(source.aggregationExp);
});

describe('when maps_api_version is V3', () => {
test('should return correct props when source type is tileset', () => {
const source = {
Expand Down
28 changes: 0 additions & 28 deletions packages/react-api/src/hooks/FeaturesDroppedLoader.js

This file was deleted.

14 changes: 0 additions & 14 deletions packages/react-api/src/hooks/useCartoLayerProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import useGeojsonFeatures from './useGeojsonFeatures';
import useTileFeatures from './useTileFeatures';
import { getDataFilterExtensionProps } from './dataFilterExtensionUtil';
import { getMaskExtensionProps } from './maskExtensionUtil';
import FeaturesDroppedLoader from './FeaturesDroppedLoader';
import { CLIENT_ID } from '../api/common';

const LOADERS = [FeaturesDroppedLoader];

export default function useCartoLayerProps({
source,
Expand Down Expand Up @@ -57,7 +53,6 @@ export default function useCartoLayerProps({
...(viewportFeatures && {
onViewportLoad,
fetch,
loaders: LOADERS,
onDataLoad
})
};
Expand All @@ -78,15 +73,6 @@ export default function useCartoLayerProps({
visible: layerConfig?.visible !== undefined ? layerConfig.visible : true,
opacity: layerConfig?.opacity ?? 1,
uniqueIdProperty,
data: source?.data,
type: source?.type,
geoColumn: source?.geoColumn,
aggregationExp: source?.aggregationExp,
provider: source?.provider,
connection: source?.connection,
credentials: source?.credentials,
clientId: CLIENT_ID,
queryParameters: source?.queryParameters,
...dataFilterExtensionProps,
...maskExtensionProps,
extensions
Expand Down
8 changes: 1 addition & 7 deletions packages/react-api/src/hooks/useTileFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import {
TILE_FORMATS
} from '@carto/react-core';
import { Methods, executeTask } from '@carto/react-workers';
import { setIsDroppingFeatures } from '@carto/react-redux';
import { Layer } from '@deck.gl/core';
import { throwError } from './utils';
import useFeaturesCommons from './useFeaturesCommons';
import { useDispatch } from 'react-redux';

export default function useTileFeatures({
source,
Expand All @@ -19,7 +17,6 @@ export default function useTileFeatures({
uniqueIdProperty,
debounceTimeout = 250
}) {
const dispatch = useDispatch();
const [
debounceIdRef,
isTilesetLoaded,
Expand Down Expand Up @@ -81,14 +78,11 @@ export default function useTileFeatures({
return acc;
}, []);

const isDroppingFeatures = tiles?.some((tile) => tile.content?.isDroppingFeatures);
dispatch(setIsDroppingFeatures({ id: sourceId, isDroppingFeatures }));

executeTask(sourceId, Methods.LOAD_TILES, { tiles: cleanedTiles })
.then(() => setTilesetLoaded(true))
.catch(throwError);
},
[sourceId, setTilesetLoaded, dispatch]
[sourceId, setTilesetLoaded]
);

// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
1 change: 0 additions & 1 deletion packages/react-api/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export { getStats as _getStats } from './api/stats';
export { getTileJson as _getTileJson } from './api/tilejson';
export { executeModel as _executeModel } from './api/model';

export { default as FeaturesDroppedLoader } from './hooks/FeaturesDroppedLoader';
export { default as useCartoLayerProps } from './hooks/useCartoLayerProps';

export { Credentials, UseCartoLayerFilterProps, SourceProps, MAP_TYPES, API_VERSIONS } from './types';
1 change: 0 additions & 1 deletion packages/react-api/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export { getStats as _getStats } from './api/stats';
export { getTileJson as _getTileJson } from './api/tilejson';
export { executeModel as _executeModel } from './api/model';

export { default as FeaturesDroppedLoader } from './hooks/FeaturesDroppedLoader';
export { default as useCartoLayerProps } from './hooks/useCartoLayerProps';

export { getDataFilterExtensionProps } from './hooks/dataFilterExtensionUtil';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-api/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export type UseCartoLayerFilterProps = {
};
maskEnabled: boolean;
maskId: string;
} & SourceProps;
};

export type ExecuteSQLResponse<Response = FeatureCollection | {}[]> = Promise<Response>;

18 changes: 0 additions & 18 deletions packages/react-redux/src/slices/cartoSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ export const createCartoSlice = (initialState) => {
action.payload.credentials = action.payload.credentials || state.credentials;
state.dataSources[action.payload.id] = action.payload;
},
setIsDroppingFeatures: (state, action) => {
const source = state.dataSources[action.payload.id];
source.isDroppingFeatures = action.payload.isDroppingFeatures;
state.dataSources[action.payload.id] = source;
},
removeSource: (state, action) => {
delete state.dataSources[action.payload];
removeWorker(action.payload);
Expand Down Expand Up @@ -240,17 +235,6 @@ export const addSource = ({
}
});

/**
* Action to set the `isDroppingFeature` flag.
* @param {object} data
* @param {string} data.id - unique id for the source.
* @param {boolean} data.isDroppingFeatures - flag that indicate if tiles are generated using a dropping feature strategy.
*/
export const setIsDroppingFeatures = ({ id, isDroppingFeatures }) => ({
type: 'carto/setIsDroppingFeatures',
payload: { id, isDroppingFeatures }
});

/**
* Action to remove a source from the store
* @param {string} sourceId - id of the source to remove
Expand Down Expand Up @@ -356,8 +340,6 @@ const _setViewPort = (payload) => ({ type: 'carto/setViewPort', payload });
* Redux selector to get a source by ID
*/
export const selectSourceById = (state, id) => state.carto.dataSources[id];
export const checkIfSourceIsDroppingFeature = (state, id) =>
state.carto.dataSources[id]?.isDroppingFeatures;

/**
* Redux selector to select the active viewport
Expand Down
1 change: 0 additions & 1 deletion packages/react-redux/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export type Source = SourceProps & {
id: string;
filters?: SourceFilters;
filtersLogicalOperator?: FiltersLogicalOperators;
isDroppingFeatures?: boolean;
};

type InitialCarto2State = {
Expand Down
2 changes: 0 additions & 2 deletions packages/react-widgets/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type CommonWidgetProps = {
onStateChange?: (stateEvent: WidgetState) => void
wrapperProps?: object,
noDataAlertProps?: object
droppingFeaturesAlertProps?: object
}

type MonoColumnWidgetProps = {
Expand Down Expand Up @@ -103,7 +102,6 @@ export type WidgetWithAlert = {
dataSource: string;
global?: boolean;
noDataAlertProps?: object;
droppingFeaturesAlertProps?: object;
children?: React.ReactNode;
}

Expand Down
11 changes: 2 additions & 9 deletions packages/react-widgets/src/widgets/BarWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const EMPTY_ARRAY = [];
* @param {Function} [props.onError] - Function to handle error messages from the widget.
* @param {object} [props.wrapperProps] - Extra props to pass to [WrapperWidgetUI](https://storybook-react.carto.com/?path=/docs/widgets-wrapperwidgetui--default).
* @param {object} [props.noDataAlertProps] - Extra props to pass to [NoDataAlert]().
* @param {object} [props.droppingFeaturesAlertProps] - Extra props to pass to [NoDataAlert]() when dropping feature.
*/
function BarWidget({
id,
Expand All @@ -62,16 +61,14 @@ function BarWidget({
global,
onError,
wrapperProps,
noDataAlertProps,
droppingFeaturesAlertProps
noDataAlertProps
}) {
const dispatch = useDispatch();

const {
data: _data = [],
isLoading,
warning,
remoteCalculation
warning
} = useWidgetFetch(getCategories, {
id,
dataSource,
Expand Down Expand Up @@ -143,12 +140,9 @@ function BarWidget({
return (
<WrapperWidgetUI title={title} isLoading={isLoading} {...wrapperProps}>
<WidgetWithAlert
dataSource={dataSource}
warning={warning}
global={global}
droppingFeaturesAlertProps={droppingFeaturesAlertProps}
noDataAlertProps={noDataAlertProps}
showDroppingFeaturesAlert={!remoteCalculation}
>
{(!!sortedData.length || isLoading) && (
<BarWidgetUI
Expand Down Expand Up @@ -195,7 +189,6 @@ BarWidget.propTypes = {
onError: PropTypes.func,
wrapperProps: PropTypes.object,
noDataAlertProps: PropTypes.object,
droppingFeaturesAlertProps: PropTypes.object,
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
};

Expand Down
13 changes: 3 additions & 10 deletions packages/react-widgets/src/widgets/CategoryWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const EMPTY_ARRAY = [];
* @param {Function} [props.onError] - Function to handle error messages from the widget.
* @param {object} [props.wrapperProps] - Extra props to pass to [WrapperWidgetUI](https://storybook-react.carto.com/?path=/docs/widgets-wrapperwidgetui--default).
* @param {object} [props.noDataAlertProps] - Extra props to pass to [NoDataAlert]().
* @param {object} [props.droppingFeaturesAlertProps] - Extra props to pass to [NoDataAlert]() when dropping feature.
*/
function CategoryWidget(props) {
Expand All @@ -56,8 +55,7 @@ function CategoryWidget(props) {
global,
onError,
wrapperProps,
noDataAlertProps,
droppingFeaturesAlertProps
noDataAlertProps
} = props;
const dispatch = useDispatch();

Expand All @@ -68,8 +66,7 @@ function CategoryWidget(props) {
const {
data = [],
isLoading,
warning,
remoteCalculation
warning
} = useWidgetFetch(getCategories, {
id,
dataSource,
Expand Down Expand Up @@ -112,12 +109,9 @@ function CategoryWidget(props) {
return (
<WrapperWidgetUI title={title} isLoading={isLoading} {...wrapperProps}>
<WidgetWithAlert
dataSource={dataSource}
warning={warning}
global={global}
droppingFeaturesAlertProps={droppingFeaturesAlertProps}
noDataAlertProps={noDataAlertProps}
showDroppingFeaturesAlert={!remoteCalculation}
>
{(!!data.length || isLoading) && (
<CategoryWidgetUI
Expand Down Expand Up @@ -156,8 +150,7 @@ CategoryWidget.propTypes = {
global: PropTypes.bool,
onError: PropTypes.func,
wrapperProps: PropTypes.object,
noDataAlertProps: PropTypes.object,
droppingFeaturesAlertProps: PropTypes.object
noDataAlertProps: PropTypes.object
};

CategoryWidget.defaultProps = {
Expand Down

0 comments on commit 4251da9

Please sign in to comment.