Skip to content

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

[Bug] Fixed download file for microsoft edge (#1074)

Giuseppe Macrì124f1abb736f
diff --git a/src/components/modals/loading-dialog.js b/src/components/modals/loading-dialog.js
index e90e19ad4..c0404e789 100644
--- a/src/components/modals/loading-dialog.js
+++ b/src/components/modals/loading-dialog.js
@@ -21,7 +21,7 @@
import React from 'react';
import styled from 'styled-components';
import LoadingSpinner from 'components/common/loading-spinner';
-import { FormattedMessage } from "react-intl";
+import {FormattedMessage} from 'react-intl';
const StyledSpinner = styled.div`
text-align: center;
@@ -59,7 +59,9 @@ const LoadingDialog = ({size = 64, message = 'modal.loadingDialog.loading'}) =>
<StyledSpinner>
<LoadingSpinner size={size} />
</StyledSpinner>
- <div className="loading-message"><FormattedMessage id={message} /></div>
+ <div className="loading-message">
+ <FormattedMessage id={message} />
+ </div>
</div>
</StyledLoadingDialog>
);
diff --git a/src/components/modals/save-map-modal.js b/src/components/modals/save-map-modal.js
index 331e5a345..53bc20e39 100644
--- a/src/components/modals/save-map-modal.js
+++ b/src/components/modals/save-map-modal.js
@@ -38,7 +38,7 @@ import {
StyledModalInputFootnote
} from 'components/common/styled-components';
import ImagePreview from 'components/common/image-preview';
-import { FormattedMessage } from "react-intl";
+import {FormattedMessage} from 'react-intl';
const StyledSaveMapModal = styled.div.attrs({
className: 'save-map-modal'
@@ -183,8 +183,12 @@ function SaveMapModalFactory() {
<StyledModalContent className="save-map-modal-content">
<StyledExportSection disabled={isProviderLoading}>
<div className="description">
- <div className="title"><FormattedMessage id={'modal.saveMap.title'} /></div>
- <div className="subtitle"><FormattedMessage id={'modal.saveMap.subtitle'} /></div>
+ <div className="title">
+ <FormattedMessage id={'modal.saveMap.title'} />
+ </div>
+ <div className="subtitle">
+ <FormattedMessage id={'modal.saveMap.subtitle'} />
+ </div>
</div>
<div className="selection">
{cloudProviders.map(cloudProvider => (
diff --git a/src/components/modals/share-map-modal.js b/src/components/modals/share-map-modal.js
index 7986552c7..09e8c8fe3 100644
--- a/src/components/modals/share-map-modal.js
+++ b/src/components/modals/share-map-modal.js
@@ -125,32 +125,31 @@ export default function ShareMapUrlModalFactory() {
currentProvider={currentProvider}
cloudProviders={cloudProviders}
onUpdateImageSetting={onUpdateImageSetting}
-
- >
- <StyledShareMapModal className="export-cloud-modal">
- <StyledInnerDiv>
- <StyledExportSection>
- <div className="description">
- <div className="title">
- <FormattedMessage id={'modal.shareMap.shareUriTitle'} />
- </div>
- <div className="subtitle">
- <FormattedMessage id={'modal.shareMap.shareUriSubtitle'} />
- </div>
- </div>
- <div className="selection">
- <div className="title warning">
- <FormattedMessage id={'modal.shareMap.shareDisclaimer'} />
- </div>
- </div>
- </StyledExportSection>
- <StyledExportSection disabled={isProviderLoading}>
- <div className="description">
- <div className="title">
- <FormattedMessage id={'modal.shareMap.cloudTitle'} />
- </div>
- <div className="subtitle">
- <FormattedMessage id={'modal.shareMap.cloudSubtitle'} />
+ >
+ <StyledShareMapModal className="export-cloud-modal">
+ <StyledInnerDiv>
+ <StyledExportSection>
+ <div className="description">
+ <div className="title">
+ <FormattedMessage id={'modal.shareMap.shareUriTitle'} />
+ </div>
+ <div className="subtitle">
+ <FormattedMessage id={'modal.shareMap.shareUriSubtitle'} />
+ </div>
+ </div>
+ <div className="selection">
+ <div className="title warning">
+ <FormattedMessage id={'modal.shareMap.shareDisclaimer'} />
+ </div>
+ </div>
+ </StyledExportSection>
+ <StyledExportSection disabled={isProviderLoading}>
+ <div className="description">
+ <div className="title">
+ <FormattedMessage id={'modal.shareMap.cloudTitle'} />
+ </div>
+ <div className="subtitle">
+ <FormattedMessage id={'modal.shareMap.cloudSubtitle'} />
</div>
</div>
<div className="selection">
@@ -190,7 +189,10 @@ export default function ShareMapUrlModalFactory() {
rel="noopener noreferrer"
style={{textDecoration: 'underline'}}
>
- <FormattedMessage id={'modal.shareMap.gotoPage'} values={{currentProvider}} />
+ <FormattedMessage
+ id={'modal.shareMap.gotoPage'}
+ values={{currentProvider}}
+ />
</a>
)}
</div>
diff --git a/src/components/side-panel/common/dataset-info.js b/src/components/side-panel/common/dataset-info.js
index 04938a438..b93ab3452 100644
--- a/src/components/side-panel/common/dataset-info.js
+++ b/src/components/side-panel/common/dataset-info.js
@@ -21,7 +21,7 @@
import React from 'react';
import styled from 'styled-components';
import {format} from 'd3-format';
-import { FormattedMessage } from "react-intl";
+import {FormattedMessage} from 'react-intl';
const numFormat = format(',');
@@ -34,7 +34,10 @@ const StyledDataRowCount = styled.div`
export default function DatasetInfoFactory() {
const DatasetInfo = ({dataset}) => (
<StyledDataRowCount className="source-data-rows">
- <FormattedMessage id={'datasetInfo.rowCount'} values={{rowCount: numFormat(dataset.allData.length)}}/>
+ <FormattedMessage
+ id={'datasetInfo.rowCount'}
+ values={{rowCount: numFormat(dataset.allData.length)}}
+ />
</StyledDataRowCount>
);
diff --git a/src/components/side-panel/interaction-panel/interaction-panel.js b/src/components/side-panel/interaction-panel/interaction-panel.js
index 9c00d2169..bf6a59b9f 100644
--- a/src/components/side-panel/interaction-panel/interaction-panel.js
+++ b/src/components/side-panel/interaction-panel/interaction-panel.js
@@ -32,7 +32,7 @@ import {
PanelHeaderContent,
PanelContent
} from 'components/common/styled-components';
-import { FormattedMessage } from "react-intl";
+import {FormattedMessage} from 'react-intl';
const StyledPanelContent = styled(PanelContent)`
border-top: 1px solid ${props => props.theme.panelBorderColor};
@@ -93,8 +93,9 @@ function InteractionPanelFactory(TooltipConfig, BrushConfig) {
<config.iconComponent height="12px" />
</div>
<div className="interaction-panel__header__title">
-
- <PanelHeaderTitle><FormattedMessage id={config.label} /></PanelHeaderTitle>
+ <PanelHeaderTitle>
+ <FormattedMessage id={config.label} />
+ </PanelHeaderTitle>
</div>
</PanelHeaderContent>
<div className="interaction-panel__header__actions">
diff --git a/src/components/side-panel/layer-panel/layer-column-config.js b/src/components/side-panel/layer-panel/layer-column-config.js
index 0638ebb8b..4e2a18ba6 100644
--- a/src/components/side-panel/layer-panel/layer-column-config.js
+++ b/src/components/side-panel/layer-panel/layer-column-config.js
@@ -80,7 +80,9 @@ export default class LayerColumnConfig extends Component {
<SidePanelSection>
<div className="layer-config__column">
<TopRow>
- <PanelLabel><FormattedMessage id={'columns.title'} /></PanelLabel>
+ <PanelLabel>
+ <FormattedMessage id={'columns.title'} />
+ </PanelLabel>
<PanelLabel>
<FormattedMessage id="layer.required" />
</PanelLabel>
diff --git a/src/layers/icon-layer/icon-info-modal.js b/src/layers/icon-layer/icon-info-modal.js
index c9196c04f..7a85e06f9 100644
--- a/src/layers/icon-layer/icon-info-modal.js
+++ b/src/layers/icon-layer/icon-info-modal.js
@@ -22,7 +22,7 @@ import React from 'react';
import styled from 'styled-components';
import {line} from 'd3-shape';
import {Table, CenterFlexbox} from 'components/common/styled-components';
-import { FormattedMessage } from "react-intl";
+import {FormattedMessage} from 'react-intl';
const lineFunction = line()
.x(d => d[0] * 10)
@@ -125,15 +125,21 @@ const IconInfoModalFactory = (svgIcons = []) => {
<div className="icon-info-modal">
<div className="icon-info-modal__description">
<FormattedMessage id={'modal.iconInfo.description1'} />{' '}
- <code><FormattedMessage id={'modal.iconInfo.code'} /></code>
- <FormattedMessage id={'modal.iconInfo.description2'}/>
+ <code>
+ <FormattedMessage id={'modal.iconInfo.code'} />
+ </code>
+ <FormattedMessage id={'modal.iconInfo.description2'} />
</div>
<div className="icon-info-modal__example">
- <StyledTitle><FormattedMessage id={'modal.iconInfo.example'}/></StyledTitle>
+ <StyledTitle>
+ <FormattedMessage id={'modal.iconInfo.example'} />
+ </StyledTitle>
<ExampleTable />
</div>
<div className="icon-info-modal__icons">
- <StyledTitle><FormattedMessage id={'modal.iconInfo.icons'}/></StyledTitle>
+ <StyledTitle>
+ <FormattedMessage id={'modal.iconInfo.icons'} />
+ </StyledTitle>
<IconTable className="icon-info-modal__icons__table">
{svgIcons.map(icon => (
<IconItem key={icon.id} icon={icon} />
diff --git a/src/layers/trip-layer/trip-info-modal.js b/src/layers/trip-layer/trip-info-modal.js
index caa0ff02b..0078c3d38 100644
--- a/src/layers/trip-layer/trip-info-modal.js
+++ b/src/layers/trip-layer/trip-info-modal.js
@@ -46,7 +46,9 @@ const TripInfoModalFactory = (svgIcons = []) => {
</p>
</div>
<div className="trip-info-modal__example">
- <StyledTitle><FormattedMessage id={'modal.tripInfo.example'} /></StyledTitle>
+ <StyledTitle>
+ <FormattedMessage id={'modal.tripInfo.example'} />
+ </StyledTitle>
<pre>
<StyledCode>
{`
diff --git a/src/reducers/ui-state-updaters.js b/src/reducers/ui-state-updaters.js
index 9ee6008c0..811639c2d 100644
--- a/src/reducers/ui-state-updaters.js
+++ b/src/reducers/ui-state-updaters.js
@@ -110,7 +110,6 @@ export const DEFAULT_MAP_CONTROLS = [
{}
);
-
/**
* Default image export config
* @memberof uiStateUpdaters
@@ -325,8 +324,6 @@ export const toggleMapControlUpdater = (state, {payload: {panelId, index = 0}})
}
});
-
-
/**
* Toggle active map control panel
* @memberof uiStateUpdaters
diff --git a/src/utils/export-image-utils.js b/src/utils/export-image-utils.js
deleted file mode 100644
index d19721370..000000000
--- a/src/utils/export-image-utils.js
+++ /dev/null
@@ -1,74 +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.
-
-import domtoimage from 'utils/dom-to-image';
-import {Blob, URL, atob, Uint8Array, ArrayBuffer, document} from 'global/window';
-import {EXPORT_IMG_RATIO_OPTIONS, EXPORT_IMG_RESOLUTION_OPTIONS} from 'constants/default-settings';
-
-export function calculateExportImageSize({width, height, ratio, resolution}) {
- const resolutionItem = EXPORT_IMG_RESOLUTION_OPTIONS.find(op => op.id === resolution);
- const {width: scaledWidth, height: scaledHeight} = resolutionItem.getSize(width, height);
- const {zoomOffset, scale} = resolutionItem;
-
- return {
- zoomOffset,
- scale,
- ...EXPORT_IMG_RATIO_OPTIONS.find(op => op.id === ratio).getSize(scaledWidth, scaledHeight)
- };
-}
-
-export function convertToPng(sourceElem, options) {
- return domtoimage.toPng(sourceElem, options);
-}
-
-export function dataURItoBlob(dataURI) {
- const binary = atob(dataURI.split(',')[1]);
-
- // separate out the mime component
- const mimeString = dataURI
- .split(',')[0]
- .split(':')[1]
- .split(';')[0];
-
- // write the bytes of the string to an ArrayBuffer
- const ab = new ArrayBuffer(binary.length);
-
- // create a view into the buffer
- const ia = new Uint8Array(ab);
-
- for (let i = 0; i < binary.length; i++) {
- ia[i] = binary.charCodeAt(i);
- }
-
- return new Blob([ab], {type: mimeString});
-}
-
-export function downloadFile(fileBlob, filename) {
- const url = URL.createObjectURL(fileBlob);
-
- const link = document.createElement('a');
- link.setAttribute('href', url);
- link.setAttribute('download', filename);
-
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- URL.revokeObjectURL(url);
-}
diff --git a/src/utils/export-utils.js b/src/utils/export-utils.js
index 7acbc8eff..1a5d2ac4f 100644
--- a/src/utils/export-utils.js
+++ b/src/utils/export-utils.js
@@ -54,6 +54,10 @@ const defaultResolution = EXPORT_IMG_RESOLUTION_OPTIONS.find(op => op.id === RES
const defaultRatio = EXPORT_IMG_RATIO_OPTIONS.find(op => op.id === EXPORT_IMG_RATIOS.FOUR_BY_THREE);
+export function isMSEdge(window) {
+ return Boolean(window.navigator && window.navigator.msSaveOrOpenBlob);
+}
+
export function getScaleFromImageSize(imageW, imageH, mapW, mapH) {
if ([imageW, imageH, mapW, mapH].some(d => d <= 0)) {
return 1;
@@ -115,17 +119,21 @@ export function dataURItoBlob(dataURI) {
return new Blob([ab], {type: mimeString});
}
-export function downloadFile(fileBlob, filename) {
- const url = URL.createObjectURL(fileBlob);
+export function downloadFile(fileBlob, fileName) {
+ if (isMSEdge(window)) {
+ window.navigator.msSaveOrOpenBlob(fileBlob, fileName);
+ } else {
+ const url = URL.createObjectURL(fileBlob);
- const link = document.createElement('a');
- link.setAttribute('href', url);
- link.setAttribute('download', filename);
+ const link = document.createElement('a');
+ link.setAttribute('href', url);
+ link.setAttribute('download', fileName);
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- URL.revokeObjectURL(url);
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ URL.revokeObjectURL(url);
+ }
}
export function exportImage(state) {
diff --git a/test/browser/components/side-panel/color-selector-test.js b/test/browser/components/side-panel/color-selector-test.js
index 402f1e83c..802ed474f 100644
--- a/test/browser/components/side-panel/color-selector-test.js
+++ b/test/browser/components/side-panel/color-selector-test.js
@@ -49,7 +49,7 @@ import {Button} from 'components/common/styled-components';
import {COLOR_RANGES} from 'constants/color-ranges';
import {StateWFilesFiltersLayerColor, StateWTrips} from 'test/helpers/mock-state';
-import { IntlWrapper, mountWithTheme } from "test/helpers/component-utils";
+import {IntlWrapper, mountWithTheme} from 'test/helpers/component-utils';
import {hexToRgb} from 'utils/color-utils';
test('Components -> ColorSelector.render', t => {
@@ -83,7 +83,11 @@ test('Components -> LayerColorSelector.render -> render layer color', t => {
const layerConfiguratorProps = getLayerConfiguratorProps(mockProps);
t.doesNotThrow(() => {
- wrapper = mountWithTheme(<IntlWrapper><LayerColorSelector {...layerConfiguratorProps} /></IntlWrapper> );
+ wrapper = mountWithTheme(
+ <IntlWrapper>
+ <LayerColorSelector {...layerConfiguratorProps} />
+ </IntlWrapper>
+ );
}, 'Should not fail with layers');
const CSInstance = wrapper.find(ColorSelector);
@@ -150,7 +154,11 @@ test('Components -> LayerColorSelector.render -> render single color click', t =
const layerConfiguratorProps = getLayerConfiguratorProps(mockProps);
t.doesNotThrow(() => {
- wrapper = mountWithTheme(<IntlWrapper><LayerColorSelector {...layerConfiguratorProps} /></IntlWrapper> );
+ wrapper = mountWithTheme(
+ <IntlWrapper>
+ <LayerColorSelector {...layerConfiguratorProps} />
+ </IntlWrapper>
+ );
}, 'Should not fail render color select');
const CSInstance = wrapper.find(ColorSelector);
@@ -196,14 +204,16 @@ test('Components -> ArcLayerColorSelector.render -> render single color', t => {
let wrapper;
t.doesNotThrow(() => {
- wrapper = mountWithTheme(<IntlWrapper>
- <ArcLayerColorSelector
- layer={arcLayer}
- setColorUI={layerConfiguratorProps.setColorUI}
- onChangeConfig={layerConfiguratorProps.onChange}
- onChangeVisConfig={visConfiguratorProps.onChange}
- />
- </IntlWrapper> );
+ wrapper = mountWithTheme(
+ <IntlWrapper>
+ <ArcLayerColorSelector
+ layer={arcLayer}
+ setColorUI={layerConfiguratorProps.setColorUI}
+ onChangeConfig={layerConfiguratorProps.onChange}
+ onChangeVisConfig={visConfiguratorProps.onChange}
+ />
+ </IntlWrapper>
+ );
}, 'Should not fail render arc color select');
const CSInstance = wrapper.find(ColorSelector);
@@ -279,14 +289,16 @@ test('Components -> ArcLayerColorSelector.render -> render single color click',
let wrapper;
t.doesNotThrow(() => {
- wrapper = mountWithTheme(<IntlWrapper>
- <ArcLayerColorSelector
- layer={arcLayer}
- setColorUI={layerConfiguratorProps.setColorUI}
- onChangeConfig={layerConfiguratorProps.onChange}
- onChangeVisConfig={visConfiguratorProps.onChange}
- />
- </IntlWrapper> );
+ wrapper = mountWithTheme(
+ <IntlWrapper>
+ <ArcLayerColorSelector
+ layer={arcLayer}
+ setColorUI={layerConfiguratorProps.setColorUI}
+ onChangeConfig={layerConfiguratorProps.onChange}
+ onChangeVisConfig={visConfiguratorProps.onChange}
+ />
+ </IntlWrapper>
+ );
}, 'Should not fail render arc color select');
const CSInstance = wrapper.find(ColorSelector);
t.equal(CSInstance.length, 1, 'should render 1 ColorSelector');
@@ -329,7 +341,11 @@ test('Components -> LayerColorRangeSelector.render -> ColorSelector', t => {
let wrapper;
t.doesNotThrow(() => {
- wrapper = mountWithTheme(<IntlWrapper><LayerColorRangeSelector {...visConfiguratorProps} /></IntlWrapper>);
+ wrapper = mountWithTheme(
+ <IntlWrapper>
+ <LayerColorRangeSelector {...visConfiguratorProps} />
+ </IntlWrapper>
+ );
}, 'Should not fail render color range select');
const CPInstance = wrapper.find(ColorPalette);
t.equal(CPInstance.length, 1, 'should render 1 ColorPalette');
@@ -388,7 +404,11 @@ test('Components -> LayerColorRangeSelector.render -> ColorSelector -> ColorRang
let wrapper;
t.doesNotThrow(() => {
- wrapper = mountWithTheme(<IntlWrapper><LayerColorRangeSelector {...visConfiguratorProps} /></IntlWrapper> );
+ wrapper = mountWithTheme(
+ <IntlWrapper>
+ <LayerColorRangeSelector {...visConfiguratorProps} />
+ </IntlWrapper>
+ );
}, 'Should not fail render color range select');
// open color dropdown
@@ -544,7 +564,11 @@ test('Components -> LayerColorRangeSelector.render -> ColorSelector -> ColorRang
const visConfiguratorProps = getVisConfiguratorProps(mockProps);
let wrapper;
t.doesNotThrow(() => {
- wrapper = mountWithTheme(<IntlWrapper><LayerColorRangeSelector {...visConfiguratorProps} /></IntlWrapper> );
+ wrapper = mountWithTheme(
+ <IntlWrapper>
+ <LayerColorRangeSelector {...visConfiguratorProps} />
+ </IntlWrapper>
+ );
}, 'Should not fail render color range select');
// open color dropdown
@@ -591,7 +615,11 @@ test('Components -> LayerColorRangeSelector.render -> ColorSelector -> ColorRang
const visConfiguratorProps = getVisConfiguratorProps(mockProps);
let wrapper;
t.doesNotThrow(() => {
- wrapper = mountWithTheme(<IntlWrapper><LayerColorRangeSelector {...visConfiguratorProps} /></IntlWrapper> );
+ wrapper = mountWithTheme(
+ <IntlWrapper>
+ <LayerColorRangeSelector {...visConfiguratorProps} />
+ </IntlWrapper>
+ );
}, 'Should not fail render color range select');
// current colorRange
// { name: 'Ice And Fire 8',
@@ -743,7 +771,11 @@ test('Components -> LayerColorRangeSelector.render -> ColorSelector -> ColorRang
const visConfiguratorProps = getVisConfiguratorProps(mockProps);
let wrapper;
t.doesNotThrow(() => {
- wrapper = mountWithTheme(<IntlWrapper><LayerColorRangeSelector {...visConfiguratorProps} /></IntlWrapper> );
+ wrapper = mountWithTheme(
+ <IntlWrapper>
+ <LayerColorRangeSelector {...visConfiguratorProps} />
+ </IntlWrapper>
+ );
}, 'Should not fail render color range select');
const cp = wrapper.find(CustomPalette);
diff --git a/test/browser/layer-tests/icon-layer-specs.js b/test/browser/layer-tests/icon-layer-specs.js
index 6eb8974fa..7c9d113e6 100644
--- a/test/browser/layer-tests/icon-layer-specs.js
+++ b/test/browser/layer-tests/icon-layer-specs.js
@@ -40,7 +40,7 @@ import {
} from 'test/helpers/layer-utils';
import {KeplerGlLayers} from 'layers';
import {INITIAL_MAP_STATE} from 'reducers/map-state-updaters';
-import { IntlWrapper } from "../../helpers/component-utils";
+import {IntlWrapper} from '../../helpers/component-utils';
const {IconLayer} = KeplerGlLayers;
const columns = {
@@ -533,7 +533,11 @@ test('#IconLayer -> fetch icon geometry -> renderIconModal', t => {
let wrapper;
t.doesNotThrow(() => {
- wrapper = mount(<IntlWrapper><iconLayer.layerInfoModal.template /></IntlWrapper>);
+ wrapper = mount(
+ <IntlWrapper>
+ <iconLayer.layerInfoModal.template />
+ </IntlWrapper>
+ );
}, 'mount layer info modal with icons should not fail');
t.equal(wrapper.find('.icon-table__item').length, 3, 'should render 1 icon');
diff --git a/test/helpers/component-utils.js b/test/helpers/component-utils.js
index 738a83def..a7cf8727b 100644
--- a/test/helpers/component-utils.js
+++ b/test/helpers/component-utils.js
@@ -22,8 +22,8 @@ import React from 'react';
import {mount} from 'enzyme';
import {theme} from 'styles/base';
import {ThemeProvider} from 'styled-components';
-import { IntlProvider } from "react-intl";
-import { messages } from "localization";
+import {IntlProvider} from 'react-intl';
+import {messages} from 'localization';
export function mountWithTheme(node) {
return mount(node, {
@@ -32,7 +32,7 @@ export function mountWithTheme(node) {
});
}
-export const IntlWrapper = ({children, locale='en'}) => (
+export const IntlWrapper = ({children, locale = 'en'}) => (
<IntlProvider locale={locale} messages={messages[locale]}>
{children}
</IntlProvider>
diff --git a/test/node/utils/export-utils-test.js b/test/node/utils/export-utils-test.js
index f800cc4af..1840eefc3 100644
--- a/test/node/utils/export-utils-test.js
+++ b/test/node/utils/export-utils-test.js
@@ -22,7 +22,7 @@ import test from 'tape';
import {registerEntry} from 'actions/identity-actions';
import keplerGlReducer from 'reducers';
-import {getMapJSON, exportToJsonString} from 'utils/export-utils';
+import {getMapJSON, exportToJsonString, getScaleFromImageSize, isMSEdge} from 'utils/export-utils';
test('exportUtils -> ExportJson', t => {
const state = keplerGlReducer(undefined, registerEntry({id: 'test'})).test;
@@ -36,3 +36,27 @@ test('exportUtils -> ExportJson', t => {
t.end();
});
+
+test('exportUtils -> getScaleFromImageSize', t => {
+ t.equal(
+ getScaleFromImageSize(800, 600, 1400, 990),
+ 0.5714285714285714,
+ 'Should compute the right scale'
+ );
+ t.end();
+});
+
+test('exportUtils -> isMSEdge', t => {
+ t.equal(isMSEdge({}), false, 'Should return false because no navigator is defined');
+ t.equal(
+ isMSEdge({navigator: {}}),
+ false,
+ 'Should return false because msSaveOrOpenBlob is not defined'
+ );
+ t.equal(
+ isMSEdge({navigator: {msSaveOrOpenBlob: () => {}}}),
+ true,
+ 'Should return true because both navigator and msSaveOrOpenBlob are defined'
+ );
+ t.end();
+});
diff --git a/test/node/utils/util-test.js b/test/node/utils/util-test.js
index 5b9928a49..367eaa83c 100644
--- a/test/node/utils/util-test.js
+++ b/test/node/utils/util-test.js
@@ -80,13 +80,13 @@ test('Utils -> camelToTitle', t => {
t.end();
});
-test('Utils -> camelize', t=> {
+test('Utils -> camelize', t => {
t.equal(camelize('hello world test string'), 'helloWorldTestString', 'should camelize string');
t.equal(camelize('Hello World test String'), 'helloWorldTestString', 'should camelize string');
t.end();
});
-test('Utils -> capitalizeFirstLetter', t=> {
+test('Utils -> capitalizeFirstLetter', t => {
t.equal(capitalizeFirstLetter('hello world'), 'Hello world', 'should capitalize string');
t.equal(capitalizeFirstLetter(1), 1, 'should ignore other types than string');
t.end();
diff --git a/yarn.lock b/yarn.lock
index 5dd994790..4df8ae338 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1286,6 +1286,39 @@
unique-filename "^1.1.1"
which "^1.3.1"
+"@formatjs/intl-displaynames@^1.2.0":
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/@formatjs/intl-displaynames/-/intl-displaynames-1.2.2.tgz#d0f0edebad96660196d282f609a1169a88a27d4a"
+ integrity sha512-qwYxEWJEIplshOMWyLGl2g0d9g/25oQm8GWWCRcagHhv4YIfSJM5+GCTYNJiQImm10pKfEhoV5ezDs0Pr/8CRA==
+ dependencies:
+ "@formatjs/intl-utils" "^2.2.0"
+
+"@formatjs/intl-listformat@^1.4.1":
+ version "1.4.3"
+ resolved "https://registry.yarnpkg.com/@formatjs/intl-listformat/-/intl-listformat-1.4.3.tgz#3cb75b9a9da60ca54c52dd5a239a24cd448f7a60"
+ integrity sha512-FZcc3FSYYimMEm03+1qJzmsm1Vn5qxxkrFe0kqNKujEq3MAK+uL31jpPBiD1EPl22uTD0MHZMuZF55jqd/7R/w==
+ dependencies:
+ "@formatjs/intl-utils" "^2.2.1"
+
+"@formatjs/intl-relativetimeformat@^4.5.9":
+ version "4.5.11"
+ resolved "https://registry.yarnpkg.com/@formatjs/intl-relativetimeformat/-/intl-relativetimeformat-4.5.11.tgz#8161aba04b3dd488a00e2642e007bf5359f8ad34"
+ integrity sha512-UdZtBISVHMB1n9dOldnNpEr90/qdHcOXe+EPBAy6pXsqKwL1Nh86PU5/2wJij1wl7lQDrCb2npcYnmScv4uGRg==
+ dependencies:
+ "@formatjs/intl-utils" "^2.2.1"
+
+"@formatjs/intl-unified-numberformat@^3.2.0":
+ version "3.3.1"
+ resolved "https://registry.yarnpkg.com/@formatjs/intl-unified-numberformat/-/intl-unified-numberformat-3.3.1.tgz#67b7642b3405e3bf7aaad26862c39a901ba8111f"
+ integrity sha512-ZmSxfs7Vt1qnF4AmOuN1XVFK3rXPTxEW4K6mjEJjJkWlgmqSbZeLg7Q46c4GfU6x5dbHVFCaIWsy+U2ko6WkfA==
+ dependencies:
+ "@formatjs/intl-utils" "^2.2.1"
+
+"@formatjs/intl-utils@^2.2.0", "@formatjs/intl-utils@^2.2.1":
+ version "2.2.1"
+ resolved "https://registry.yarnpkg.com/@formatjs/intl-utils/-/intl-utils-2.2.1.tgz#0eeefe92d317acfcd179c14826e719b3b130d82a"
+ integrity sha512-WF3oU6l2WqJjN4OWvnjF9AHyQjHpjcfpyuckM7euFeX6ZGRPpPj+ZCqzf41g81MSksf9aZI4fFCZXWTBusgcWA==
+
version "2.1.4"
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5"
@@ -2656,6 +2689,19 @@
"@types/minimatch" "*"
"@types/node" "*"
+"@types/hoist-non-react-statics@^3.3.1":
+ version "3.3.1"
+ resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f"
+ integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==
+ dependencies:
+ "@types/react" "*"
+ hoist-non-react-statics "^3.3.0"
+
+"@types/invariant@^2.2.31":
+ version "2.2.31"
+ resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.31.tgz#4444c03004f215289dbca3856538434317dd28b2"
+ integrity sha512-jMlgg9pIURvy9jgBHCjQp/CyBjYHUwj91etVcDdXkFl2CwTFiQlB+8tcsMeXpXf2PFE5X2pjk4Gm43hQSMHAdA==
+
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff"
@@ -2691,6 +2737,19 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.5.1.tgz#6fae50892d1841f4b38b298e2f78fb68c5960cb9"
integrity sha512-Jj2W7VWQ2uM83f8Ls5ON9adxN98MvyJsMSASYFuSvrov8RMRY64Ayay7KV35ph1TSGIJ2gG9ZVDdEq3c3zaydA==
+"@types/prop-types@*":
+ version "15.7.3"
+ resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
+ integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
+
+"@types/react@*":
+ version "16.9.34"
+ resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.34.tgz#f7d5e331c468f53affed17a8a4d488cd44ea9349"
+ integrity sha512-8AJlYMOfPe1KGLKyHpflCg5z46n0b5DbRfqDksxBLBTUpB75ypDBAO9eCUcjNwE6LCUslwTz00yyG/X9gaVtow==
+ dependencies:
+ "@types/prop-types" "*"
+ csstype "^2.2.0"
+
"@types/stack-utils@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
@@ -5064,6 +5123,11 @@ cssstyle@^2.0.0, cssstyle@^2.2.0:
dependencies:
cssom "~0.3.6"
+csstype@^2.2.0:
+ version "2.6.10"
+ resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.10.tgz#e63af50e66d7c266edb6b32909cfd0aabe03928b"
+ integrity sha512-D34BqZU4cIlMCY93rZHbrq9pjTAQJ3U8S8rfBqjwHxkGPThWFjzZDQpgMJY0QViLxth6ZKYiwFBo14RdN44U/w==
+
csstype@^2.6.7:
version "2.6.8"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.8.tgz#0fb6fc2417ffd2816a418c9336da74d7f07db431"
@@ -7843,7 +7907,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb"
integrity sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==
-hoist-non-react-statics@^3.3.0:
+hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
@@ -8297,6 +8361,26 @@ [email protected]:
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296"
integrity sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==
+intl-format-cache@^4.2.21:
+ version "4.2.23"
+ resolved "https://registry.yarnpkg.com/intl-format-cache/-/intl-format-cache-4.2.23.tgz#2c508f64b3bb5862abc71392a4b1696e2b8572d2"
+ integrity sha512-a1chSSjN323lnm3f4VWR/+6uyaXgTLII8PkiDeKkC3A+eauUswf/k09iBwDQGlkLg29mZ+zShWdm+YdH+sLY4w==
+
+intl-messageformat-parser@^3.6.4:
+ version "3.6.4"
+ resolved "https://registry.yarnpkg.com/intl-messageformat-parser/-/intl-messageformat-parser-3.6.4.tgz#5199d106d816c3dda26ee0694362a9cf823978fb"
+ integrity sha512-RgPGwue0mJtoX2Ax8EmMzJzttxjnva7gx0Q7mKJ4oALrTZvtmCeAw5Msz2PcjW4dtCh/h7vN/8GJCxZO1uv+OA==
+ dependencies:
+ "@formatjs/intl-unified-numberformat" "^3.2.0"
+
+intl-messageformat@^7.8.4:
+ version "7.8.4"
+ resolved "https://registry.yarnpkg.com/intl-messageformat/-/intl-messageformat-7.8.4.tgz#c29146a06b9cd26662978a4d95fff2b133e3642f"
+ integrity sha512-yS0cLESCKCYjseCOGXuV4pxJm/buTfyCJ1nzQjryHmSehlptbZbn9fnlk1I9peLopZGGbjj46yHHiTAEZ1qOTA==
+ dependencies:
+ intl-format-cache "^4.2.21"
+ intl-messageformat-parser "^3.6.4"
+
invariant@^2.2.2, invariant@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
@@ -12555,6 +12639,24 @@ react-hot-loader@^3.0.0-beta.6:
redbox-react "^1.3.6"
source-map "^0.6.1"
+react-intl@^3.12.0:
+ version "3.12.1"
+ resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-3.12.1.tgz#e9a783ea20302e9da25e4eda59e5593a43d2ec80"
+ integrity sha512-cgumW29mwROIqyp8NXStYsoIm27+8FqnxykiLSawWjOxGIBeLuN/+p2srei5SRIumcJefOkOIHP+NDck05RgHg==
+ dependencies:
+ "@formatjs/intl-displaynames" "^1.2.0"
+ "@formatjs/intl-listformat" "^1.4.1"
+ "@formatjs/intl-relativetimeformat" "^4.5.9"
+ "@formatjs/intl-unified-numberformat" "^3.2.0"
+ "@formatjs/intl-utils" "^2.2.0"
+ "@types/hoist-non-react-statics" "^3.3.1"
+ "@types/invariant" "^2.2.31"
+ hoist-non-react-statics "^3.3.2"
+ intl-format-cache "^4.2.21"
+ intl-messageformat "^7.8.4"
+ intl-messageformat-parser "^3.6.4"
+ shallow-equal "^1.2.1"
+
react-is@^16.12.0, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.6, react-is@^16.9.0:
version "16.12.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.12.0.tgz#2cc0fe0fba742d97fd527c42a13bec4eeb06241c"
@@ -13809,6 +13911,11 @@ shallow-clone@^3.0.0:
dependencies:
kind-of "^6.0.2"
+shallow-equal@^1.2.1:
+ version "1.2.1"
+ resolved "https://registry.yarnpkg.com/shallow-equal/-/shallow-equal-1.2.1.tgz#4c16abfa56043aa20d050324efa68940b0da79da"
+ integrity sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA==
+
sharkdown@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/sharkdown/-/sharkdown-0.1.1.tgz#64484bd0f08f347f8319e9ff947a670f6b48b1b2"