Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Feat] UI for save map to backend storage (#906)
Shan He52124820e064
diff --git a/docs/api-reference/cloud-providers/overview.md b/docs/api-reference/cloud-providers/overview.mdindex acad65dac..eb81ae7d7 100644--- a/docs/api-reference/cloud-providers/overview.md+++ b/docs/api-reference/cloud-providers/overview.md@@ -1,10 +1,10 @@# Cloud Providers-The kepler.gl application does not have a backend, however it offers integration point for optional commercial backends. Each backend can integrate with kepler by adding a "cloud provider" object to kepler's global list of cloud providers.+The kepler.gl application does not have a backend, however it offers integration point for optional commercial backends. Each backend can integrate with kepler by adding a "cloud provider" object to kepler's global list of cloud providers.These objects must implement certain minimal set of methods, and can optionally immplement others, depending on the capability of the backend.-The set of methods available for cloud providers to implement is subject to change as new features are added to the front-end.+The set of methods available for cloud providers to implement is subject to change as new features are added to the front-end.## Cloud Provider Object@@ -22,8 +22,10 @@ Cloud-providers providers implement the following properties| `icon` | || `login` | || `uploadFile` | |-| `getAccessToken` | To participate in keplers built-in oauth login routes |-| `getAccessTokenFromLocation` | To participate in keplers built-in oauth login routes |+| `getAccessToken` | To participate in kepler's built-in oauth login routes |+| `getAccessTokenFromLocation` | To participate in kepler's built-in oauth login routes |+| `hasPrivateStorage` | To participate in kepler's build-in map saving function |+| `hasSharingUrl` | To participate in kepler's build-in share map via URL function |## Adding a new Cloud Provider@@ -39,6 +41,14 @@ The UI name of the providerThis should be a React SVG icon for the provider+## hasPrivateStorage() : Boolean++Whether the provider has private backend to store maps. If any provider supports private storage, The cloud storage icon in side panel will be shown.++## hasSharingUrl() : Boolean++Whether the provider supports share map with an URL. If any provider supports this feature, The share map url icon option will be shown as an option in the share map dropdown.+## Methods### login()@@ -47,7 +57,7 @@ This should be a React SVG icon for the provider### getAccessToken-This lets the provider participate in kepler's built-in oauth flow.+This lets the provider participate in kepler's built-in oauth flow.Can be ignored for providers that implement or use libraries that implement custom login flows (e.g signin using Google gapi).diff --git a/examples/demo-app/src/actions.js b/examples/demo-app/src/actions.jsindex 8569ac395..af82a2bf5 100644--- a/examples/demo-app/src/actions.js+++ b/examples/demo-app/src/actions.js@@ -25,13 +25,10 @@ import {loadFiles, toggleModal} from 'kepler.gl/actions';import {LOADING_SAMPLE_ERROR_MESSAGE,LOADING_SAMPLE_LIST_ERROR_MESSAGE,- MAP_CONFIG_URL, MAP_URI+ MAP_CONFIG_URL} from './constants/default-settings';import {LOADING_METHODS_NAMES} from './constants/default-settings';-import {getCloudProvider} from './cloud-providers';-import {generateHashId} from './utils/strings';-import {parseUri} from './utils/url';-import KeplerGlSchema from 'kepler.gl/schemas';+import {parseUri, getMapPermalink} from './utils/url';// CONSTANTSexport const INIT = 'INIT';@@ -109,6 +106,18 @@ export function setLoadingMapStatus(isMapLoading) {};}+export function onExportFileSuccess({response = {}, provider}) {+ return dispatch => {+ // TODO: a more generic way to generate responseUrl+ if (response.url) {+ const responseUrl = provider.getMapPermalink+ ? provider.getMapPermalink(response.url, false)+ : getMapPermalink(response.url, false)++ dispatch(push(responseUrl));+ }+ }+}/*** this method detects whther the response status is < 200 or > 300 in case the error* is not caught by the actualy request framework@@ -333,73 +342,3 @@ export function loadSampleConfigurations(sampleMapId = null) {});}}--/**- * this action will be triggered when the file is being uploaded- * @param isLoading- * @param metadata- * @returns {{type: string, isLoading: *, metadata: *}}- */-export function setPushingFile(isLoading, metadata) {- return {- type: PUSHING_FILE,- isLoading,- metadata- };-}--/**- * This method will export the current kepler config file to the choosen cloud platform- * @param data- * @param providerName- * @returns {Function}- */-export function exportFileToCloud(providerName) {- if (!providerName) {- throw new Error('No cloud provider identified')- }- const cloudProvider = getCloudProvider(providerName);- return (dispatch, getState) => {- // extract data from kepler- const mapData = KeplerGlSchema.save(getState().demo.keplerGl.map);- const data = JSON.stringify(mapData);- const newBlob = new Blob([data], {type: 'application/json'});- const fileName = `/keplergl_${generateHashId(6)}.json`;- const file = new File([newBlob], fileName);- // We are gonna pass the correct auth token to init the cloud provider- dispatch(setPushingFile(true, {filename: file.name, status: 'uploading', metadata: null}));- cloudProvider.uploadFile({- data,- type: 'application/json',- blob: file,- name: fileName,- isPublic: true,- cloudProvider- })- // need to perform share as well- .then(- response => {- if (cloudProvider.shareFile) {- dispatch(push(`/${MAP_URI}${response.url}`));- }- dispatch(setPushingFile(false, {filename: file.name, status: 'success', metadata: response}));- },- error => {- dispatch(setPushingFile(false, {filename: file.name, status: 'error', error}));- }- );- };-}--export function setCloudLoginSuccess(providerName) {- return dispatch => {- dispatch({type: CLOUD_LOGIN_SUCCESS}).then(- () => {- dispatch(exportFileToCloud(providerName));- },- () => {- dispatch(setPushingFile(false, {filename: null, status: 'error', error: 'not able to propagate login successfully'}));- }- );- };-}diff --git a/examples/demo-app/src/app.js b/examples/demo-app/src/app.jsindex 41db031d2..d2fbd0909 100644--- a/examples/demo-app/src/app.js+++ b/examples/demo-app/src/app.js@@ -19,7 +19,6 @@// THE SOFTWARE.import React, {Component} from 'react';-import {findDOMNode} from 'react-dom';import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';import styled, {ThemeProvider} from 'styled-components';import window from 'global/window';@@ -28,21 +27,20 @@ import {theme} from 'kepler.gl/styles';import Banner from './components/banner';import Announcement from './components/announcement';import {replaceLoadDataModal} from './factories/load-data-modal';-import {replaceSaveMap} from './factories/save-map';import {replaceMapControl} from './factories/map-control';import {replacePanelHeader} from './factories/panel-header';-import ExportUrlModal from './components/sharing/export-url-modal';import {AUTH_TOKENS} from './constants/default-settings';import {- exportFileToCloud,loadRemoteMap,loadSampleConfigurations,- setCloudLoginSuccess+ onExportFileSuccess} from './actions';+import {getCloudProviders} from './cloud-providers';++const CloudProviders = getCloudProviders();const KeplerGl = require('kepler.gl/components').injectComponents([replaceLoadDataModal(),- replaceSaveMap(),replaceMapControl(),replacePanelHeader()]);@@ -298,11 +296,6 @@ class App extends Component {);}- _isCloudStorageEnabled = () => {- const {app} = this.props.demo;- return app.featureFlags.cloudStorage;- };-_toggleCloudModal = () => {// TODO: this lives only in the demo hence we use the state for now// REFCOTOR using redux@@ -311,14 +304,6 @@ class App extends Component {});};- _onExportToCloud = (providerName) => {- this.props.dispatch(exportFileToCloud(providerName));- };-- _onCloudLoginSuccess = (providerName) => {- this.props.dispatch(setCloudLoginSuccess(providerName));- };-_getMapboxRef = (mapbox, index) => {if (!mapbox) {// The ref has been unset.@@ -336,8 +321,6 @@ class App extends Component {render() {const {showBanner} = this.state;- const {sharing} = this.props.demo;- const rootNode = this.root;return (<ThemeProvider theme={theme}><GlobalStyle@@ -356,17 +339,6 @@ class App extends Component {><Announcement onDisable={this._disableBanner} /></Banner>- {this._isCloudStorageEnabled() && rootNode && (- <ExportUrlModal- sharing={sharing}- isOpen={Boolean(this.state.cloudModalOpen)}- onClose={this._toggleCloudModal}- onExport={this._onExportToCloud}- onCloudLoginSuccess={this._onCloudLoginSuccess}- // this is to apply the same modal style as kepler.gl core- parentSelector={() => findDOMNode(this.root)}- />- )}<divstyle={{transition: 'margin 1s, height 1s',@@ -388,7 +360,8 @@ class App extends Component {getState={keplerGlGetState}width={width}height={height - (showBanner ? BannerHeight : 0)}- onSaveMap={this._isCloudStorageEnabled() && this._toggleCloudModal}+ cloudProviders={CloudProviders}+ onExportToCloudSuccess={onExportFileSuccess}/>)}</AutoSizer>diff --git a/examples/demo-app/src/cloud-providers/dropbox-provider.js b/examples/demo-app/src/cloud-providers/dropbox-provider.jsindex c75a2254c..22cbc68f2 100644--- a/examples/demo-app/src/cloud-providers/dropbox-provider.js+++ b/examples/demo-app/src/cloud-providers/dropbox-provider.js@@ -25,14 +25,18 @@ import {parseQueryString} from '../utils/url';import DropboxIcon from '../components/icons/dropbox-icon';const NAME = 'dropbox';+const DISPLAY_NAME = 'Dropbox';const DOMAIN = 'www.dropbox.com';const KEPLER_DROPBOX_FOLDER_LINK = `//${DOMAIN}/home/Apps`;const CORS_FREE_DOMAIN = 'dl.dropboxusercontent.com';+const PRIVATE_STORAGE_ENABLED = false;+const SHARING_ENABLED = true;export default class DropboxProvider {constructor(clientId, appName, icon = DropboxIcon) {// All cloud-providers providers must implement the following propertiesthis.name = NAME;+ this.displayName = DISPLAY_NAME;this.clientId = clientId;this.appName = appName;this.icon = icon;@@ -53,6 +57,7 @@ export default class DropboxProvider {*/login(onCloudLoginSuccess) {const link = this._authLink();+const authWindow = window.open(link, '_blank', 'width=1024,height=716');const handleToken = e => {// TODO: add security step to validate which domain the message is coming from@@ -60,27 +65,57 @@ export default class DropboxProvider {window.removeEventListener('message', handleToken);this._dropbox.setAccessToken(e.data.token);if (window.localStorage) {- window.localStorage.setItem('dropbox', JSON.stringify({- // dropbox token doesn't expire unless revoked by the user- token: e.data.token,- timestamp: new Date()- }));+ window.localStorage.setItem(+ 'dropbox',+ JSON.stringify({+ // dropbox token doesn't expire unless revoked by the user+ token: e.data.token,+ timestamp: new Date()+ })+ );}- onCloudLoginSuccess(this.name);};+ onCloudLoginSuccess();window.addEventListener('message', handleToken);}+ getUserName() {+ // TODO: Implement+ return null;+ }++ logout(onCloudLogoutSuccess) {+ // TODO: Implement+ }++ isEnabled() {+ // TODO: Implement+ return this.clientId !== null;+ }++ isConnected() {+ // TODO: Implement+ }++ hasPrivateStorage() {+ return PRIVATE_STORAGE_ENABLED;+ }++ hasSharingUrl() {+ return SHARING_ENABLED;+ }+/***- * @param blob to upload- * @param name if blob doesn't contain a file name, this field is used- * @param isPublic define whether the file will be available pubblicaly once uploaded+ * @param mapData map data and config in one json object {map: {datasets: Array<Object>, config: Object, info: Object}+ * @param blob json file blob to upload+ * @param fileName if blob doesn't contain a file name, this field is used+ * @param isPublic define whether the file will be available publicly once uploaded* @returns {Promise<DropboxTypes.files.FileMetadata>}*/- async uploadFile({blob, name, isPublic = true}) {+ async uploadFile({mapData, blob, fileName, isPublic = true}) {const metadata = await this._dropbox.filesUpload({- path: name || blob.name,+ path: `/${fileName || blob.name}`,contents: blob});@@ -93,18 +128,20 @@ export default class DropboxProvider {* @returns {Promise<DropboxTypes.sharing.FileLinkMetadataReference | DropboxTypes.sharing.FolderLinkMetadataReference | DropboxTypes.sharing.SharedLinkMetadataReference>}*/shareFile(metadata) {- return this._dropbox.sharingCreateSharedLinkWithSettings({- path: metadata.path_display || metadata.path_lower- }).then(- // Update URL to avoid CORS issue- // Unfortunately this is not the ideal scenario but it will make sure people- // can share dropbox urls with users without the dropbox account (publish on twitter, facebook)- result => ({- ...result,- folder_link: this._folderLink,- url: this._overrideUrl(result.url)+ return this._dropbox+ .sharingCreateSharedLinkWithSettings({+ path: metadata.path_display || metadata.path_lower})- );+ .then(+ // Update URL to avoid CORS issue+ // Unfortunately this is not the ideal scenario but it will make sure people+ // can share dropbox urls with users without the dropbox account (publish on twitter, facebook)+ result => ({+ ...result,+ folder_link: this._folderLink,+ url: this._overrideUrl(result.url)+ })+ );}/**@@ -147,7 +184,7 @@ export default class DropboxProvider {return this._dropbox.getAuthenticationUrl(`${window.location.origin}/${path}`,btoa(JSON.stringify({handler: 'dropbox', origin: window.location.origin}))- )+ );}/**@@ -159,6 +196,8 @@ export default class DropboxProvider {* @returns {DropboxTypes.sharing.FileLinkMetadataReference}*/_overrideUrl(url) {- return url ? url.slice(0, url.indexOf('?')).replace(DOMAIN, CORS_FREE_DOMAIN) : null;+ return url+ ? url.slice(0, url.indexOf('?')).replace(DOMAIN, CORS_FREE_DOMAIN)+ : null;}}diff --git a/examples/demo-app/src/components/sharing/cloud-storage.js b/examples/demo-app/src/components/sharing/cloud-storage.jsdeleted file mode 100644index 79a012c16..000000000--- a/examples/demo-app/src/components/sharing/cloud-storage.js+++ /dev/null@@ -1,176 +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 React from 'react';-import styled from 'styled-components';-import get from 'lodash.get';-import {CopyToClipboard} from 'react-copy-to-clipboard';-import {StyledModalContent} from 'kepler.gl/components';-import CloudTile from './cloud-tile';-import StatusPanel from './status-panel';-import {getCloudProviders} from '../../cloud-providers';-import {KEPLER_DISCLAIMER} from '../../constants/default-settings';-import {getMapPermalink} from '../../utils/url';--const StyledExportDataSection = styled.div`- display: flex;- flex-direction: row;- margin: 35px 0;- width: 100%;-- .description {- .title {- font-weight: 500;- color: ${props => props.theme.textColorLT};- font-size: 12px;- }- .subtitle {- color: ${props => props.theme.textColor};- font-size: 11px;- }- }-- .selection {- display: flex;- flex-wrap: wrap;- flex: 1;- padding-left: 50px;- }-`;--export const StyledInputLabel = styled.label`- font-size: 12px;- color: ${props => props.theme.textColorLT};- letter-spacing: 0.2px;-`;--const StyledInput = styled.input`- width: 100%;- padding: ${props => props.theme.inputPadding};- color: ${props => props.error ? 'red' : props.theme.titleColorLT};- height: ${props => props.theme.inputBoxHeight};- border: 0;- outline: 0;- font-size: 14px;-- :active,- :focus,- &.focus,- &.active {- outline: 0;- }-`;--export const StyledBtn = styled.button`- background-color: ${props => props.theme.primaryBtnActBgd};- color: ${props => props.theme.primaryBtnActColor};- &:focus {- outline: none;- }-`;--export const StyleSharingUrl = styled.div`- width: 100%;- display: flex;- margin-bottom: 14px;- flex-direction: column;-`;--const SharingUrl = ({url, message}) => (- <StyleSharingUrl>- <StyledInputLabel>{message}</StyledInputLabel>- <div style={{display: 'flex'}}>- <StyledInput type="text" value={url}/>- <CopyToClipboard text={url}>- <StyledBtn>copy</StyledBtn>- </CopyToClipboard>- </div>-- </StyleSharingUrl>-);--const ExportCloudModal = ({- isLoading,- info,- onExport,- onCloudLoginSuccess-}) => {- const metaUrl = get(info, ['metadata', 'url']);- const error = get(info, ['error']);- const folderLink = get(info, ['metadata', 'folder_link']);- const sharingLink = metaUrl ? getMapPermalink(metaUrl) : null;- return (-- <StyledModalContent className="export-cloud-modal">- <div style={{width: '100%'}}>- <StyledExportDataSection>- <div className="description">- <div className="title">- Save and share current map via URL- </div>- <div className="subtitle" style={{color: 'red', fontWeight: 500}}>- {KEPLER_DISCLAIMER}- </div>- </div>- </StyledExportDataSection>- <StyledExportDataSection>- <div className="description">- <div className="title">- Upload to your cloud storage- </div>- </div>- <div className="selection">- {getCloudProviders().map(cloudProvider => (- <CloudTile- key={cloudProvider.name}- token={cloudProvider.getAccessToken()}- onExport={onExport}- onLogin={() => cloudProvider.login(onCloudLoginSuccess)}- Icon={cloudProvider.icon}- name={cloudProvider.name}- />- ))}- </div>- </StyledExportDataSection>- <StyledExportDataSection>- <div className="selection">- <div style={{margin: 'auto', width: '100%'}}>- {isLoading && (- <StatusPanel isLoading={isLoading} {...info} />- )}- {error && (- <div className="subtitle" style={{color: 'red', fontWeight: 500}}>- {error.error}- </div>- )}- {metaUrl && [- (<SharingUrl key={0} url={sharingLink} message={'Share your map with other users'}/>),- (<a href={folderLink} target="_blank" rel="noopener noreferrer" style={{textDecoration: 'underline'}}>Go to your Kepler.gl Dropbox folder</a>)- ]}- </div>- </div>- </StyledExportDataSection>- </div>- </StyledModalContent>-- )-};--export default ExportCloudModal;diff --git a/examples/demo-app/src/components/sharing/cloud-tile.js b/examples/demo-app/src/components/sharing/cloud-tile.jsdeleted file mode 100644index 7a0dbe082..000000000--- a/examples/demo-app/src/components/sharing/cloud-tile.js+++ /dev/null@@ -1,84 +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 React, {useCallback} from 'react';-import styled from 'styled-components';--const StyledTileWrapper = styled.div`- display: flex;- align-items: center;- justify-content: center;- border-radius: 2px;- border: 1px solid ${props => props.selected ? props.theme.primaryBtnBgd : props.theme.selectBorderColorLT};- color: ${props => props.selected ? props.theme.primaryBtnBgd : props.theme.selectBorderColorLT};- cursor: pointer;- font-weight: 500;- width: 120px;- height: 120px;- background-color: #ffffff;-- :hover {- color: ${props => props.available && props.theme.primaryBtnBgd};- border: 1px solid ${props => props.available && props.theme.primaryBtnBgd};- }-`;--const StyledLabel = styled.div`- font-size: 14px;- color: ${props => props.theme.textColorLT};- letter-spacing: 0.2px;- text-align: center;- ul {- padding-left: 12px;- }-`;--const StyledTile = styled.div`- width: 64px;- margin: 12px;-`;--const TileButton = styled.button`- background-color: transparent;- border-width: 0;- cursor: pointer;- padding: 0;- outline: 0;-`;--const CloudTile = ({token, onExport, onLogin, Icon, name}) => {- const onExportCallback = useCallback(() => onExport(name), [onExport, name]);-- return (- <StyledTileWrapper onClick={token ? onExportCallback : onLogin}>- <StyledTile>- <div>- <div style={{textAlign: 'center'}}>{name}</div>- <TileButton>- <Icon height="64px" />- <StyledLabel>{token ? 'Upload' : 'Login'}</StyledLabel>- </TileButton>- </div>- </StyledTile>- </StyledTileWrapper>- );-};--export default CloudTile;diff --git a/examples/demo-app/src/components/sharing/status-panel.js b/examples/demo-app/src/components/sharing/status-panel.jsdeleted file mode 100644index b13ffd9e6..000000000--- a/examples/demo-app/src/components/sharing/status-panel.js+++ /dev/null@@ -1,129 +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 React from 'react';-import styled from 'styled-components';-import MapIcon from '../icons/map-icon';--const containerSize = 128;-const spinnerBorderSize = 10;-const tileWrapperSize = containerSize - 2 * spinnerBorderSize;-const tileSize = containerSize * 0.6;--const spinnerBorderColor = 'rgba(128, 128, 128, 0.2)';--const StyledWrapper = styled.div`- font-size: 14px;- font-weight: 500;- color: #3A414C;- display: flex;- position: relative;- align-items: center;- flex-direction: column;-- .title {- margin-bottom: 12px;- }-- .subtitle {- font-size: 12px;- }-`;--const StyledTileWrapper = styled.div`- position: relative;- width: ${containerSize}px;- height: ${containerSize}px;- display: flex;- align-items: center;- justify-content: center;- text-align: center;- margin: 0 auto;-- .loader,- .loader:after {- border-radius: 50%;- width: ${tileWrapperSize}px;- height: ${tileWrapperSize}px;- }- .loader {- margin: 0 auto;- font-size: 10px;- position: absolute;- text-indent: -9999em;- border: ${spinnerBorderSize}px solid ${spinnerBorderColor};- border-left: ${spinnerBorderSize}px solid #D6D6D6;- -webkit-transform: translateZ(0);- -ms-transform: translateZ(0);- transform: translateZ(0);- -webkit-animation: load8 2.0s infinite linear;- animation: load8 2.0s infinite linear;- }- @-webkit-keyframes load8 {- 0% {- -webkit-transform: rotate(0deg);- transform: rotate(0deg);- }- 100% {- -webkit-transform: rotate(360deg);- transform: rotate(360deg);- }- }- @keyframes load8 {- 0% {- -webkit-transform: rotate(0deg);- transform: rotate(0deg);- }- 100% {- -webkit-transform: rotate(360deg);- transform: rotate(360deg);- }- }-`;--const StyledTile = styled.div`- overflow: hidden;- opacity: 0.9;- transition: opacity 0.4s ease;- line-height: 0;- text-align: center;- width: ${tileSize}px;- height: ${tileSize}px;-`;--const StatusPanel = ({filename, isLoading, status, metadata}) => (- <StyledWrapper>- <div className="title">- {`${isLoading ? 'Loading' : status} ${filename} onto your cloud account`}- </div>- <StyledTileWrapper>- <div className="loader" />- <StyledTile>- <MapIcon width="100%" height="100%" />- </StyledTile>- </StyledTileWrapper>- <div className="subtitle">- {metadata && metadata.url}- </div>-- </StyledWrapper>-);--export default StatusPanel;diff --git a/examples/demo-app/src/constants/default-settings.js b/examples/demo-app/src/constants/default-settings.jsindex 5fec6e4dc..24523b389 100644--- a/examples/demo-app/src/constants/default-settings.js+++ b/examples/demo-app/src/constants/default-settings.js@@ -94,8 +94,6 @@ export const LOADING_SAMPLE_LIST_ERROR_MESSAGE = 'Not able to load sample gallerexport const LOADING_SAMPLE_ERROR_MESSAGE = 'Not able to load sample';export const LOADING_URL_MESSAGE = 'You can use the following formats: CSV | JSON | Kepler.gl config json. Make sure the url contains the file extension.';export const CORS_LINK = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS';-export const KEPLER_DISCLAIMER = '* Kepler.gl will save your map data to your personal cloud storage, only people with the URL can access your map and data. ' +- 'You can edit/delete the data file in your cloud account anytime.';export const DEFAULT_LOADING_METHOD = LOADING_METHODS[0];@@ -109,4 +107,5 @@ export const AUTH_TOKENS = {MAPBOX_TOKEN: process.env.MapboxAccessToken, // eslint-disable-lineDROPBOX_CLIENT_ID: process.env.DropboxClientId, // eslint-disable-lineEXPORT_MAPBOX_TOKEN: process.env.MapboxExportToken, // eslint-disable-line+ CARTO_CLIENT_ID: process.env.CartoClientId // eslint-disable-line};diff --git a/examples/demo-app/src/factories/panel-header.js b/examples/demo-app/src/factories/panel-header.jsindex 8b193d250..c8c19ce90 100644--- a/examples/demo-app/src/factories/panel-header.js+++ b/examples/demo-app/src/factories/panel-header.js@@ -21,9 +21,9 @@import {PanelHeaderFactory, Icons} from 'kepler.gl/components';import {GITHUB_BUG_REPORT, GITHUB_USER_GUIDE} from 'kepler.gl/constants';-export function CustomPanelHeaderFactory(SaveExportDropdown) {- const PanelHeader = PanelHeaderFactory(SaveExportDropdown);-+export function CustomPanelHeaderFactory(...deps) {+ const PanelHeader = PanelHeaderFactory(...deps);+ const defaultActionItems = PanelHeader.defaultProps.actionItems;PanelHeader.defaultProps = {...PanelHeader.defaultProps,actionItems: [@@ -43,8 +43,11 @@ export function CustomPanelHeaderFactory(SaveExportDropdown) {tooltip: 'User Guide',onClick: () => {}},+ defaultActionItems.find(item => item.id === 'storage'),{- ...PanelHeader.defaultProps.actionItems.find(item => item.id === 'save'),+ ...defaultActionItems.find(+ item => item.id === 'save'+ ),label: null,tooltip: 'Share'}diff --git a/examples/demo-app/src/reducers/index.js b/examples/demo-app/src/reducers/index.jsindex 7e1d8d080..8ea9ae69f 100644--- a/examples/demo-app/src/reducers/index.js+++ b/examples/demo-app/src/reducers/index.js@@ -26,8 +26,6 @@ import {processGeojson, processCsvData} from 'kepler.gl/processors';import KeplerGlSchema from 'kepler.gl/schemas';import {EXPORT_MAP_FORMATS} from 'kepler.gl/constants';-import sharingReducer from './sharing';-import {INIT,SET_LOADING_METHOD,@@ -104,8 +102,7 @@ const demoReducer = combineReducers({}}}),- app: appReducer,- sharing: sharingReducer+ app: appReducer});// this can be moved into a action and call kepler.gl actiondiff --git a/examples/demo-app/src/utils/url.js b/examples/demo-app/src/utils/url.jsindex 9098057b2..9125d5a8d 100644--- a/examples/demo-app/src/utils/url.js+++ b/examples/demo-app/src/utils/url.js@@ -36,8 +36,10 @@ export function parseQueryString(query) {* @param mapLink the cloud-providers url used to store the map* @returns {string}*/-export function getMapPermalink(mapLink) {- return `${window.location.protocol}//${window.location.host}/${MAP_URI}${mapLink}`+export function getMapPermalink(mapLink, fullUrl = true) {+ return fullUrl+ ? `${window.location.protocol}//${window.location.host}/${MAP_URI}${mapLink}`+ : `/${MAP_URI}${mapLink}`;}// from http://blog.stevenlevithan.com/archives/parseuridiff --git a/examples/webpack.config.local.js b/examples/webpack.config.local.jsindex afba1de55..50e68c778 100644--- a/examples/webpack.config.local.js+++ b/examples/webpack.config.local.js@@ -122,7 +122,8 @@ function makeLocalDevConfig(env, EXAMPLE_DIR = LIB_DIR, externals = {}) {new webpack.EnvironmentPlugin(['MapboxAccessToken','DropboxClientId',- 'MapboxExportToken'+ 'MapboxExportToken',+ 'CartoClientId'])]};diff --git a/package.json b/package.jsonindex 3e720357f..32e849707 100644--- a/package.json+++ b/package.json@@ -111,6 +111,7 @@"pbf": "^3.1.0","prop-types": "^15.6.0","react-color": "^2.17.3",+ "react-copy-to-clipboard": "^5.0.2","react-json-pretty": "^1.7.9","react-lifecycles-compat": "^3.0.4","react-map-gl": "^5.0.3",diff --git a/src/actions/provider-actions.js b/src/actions/provider-actions.jsnew file mode 100644index 000000000..ce83f2cf0--- /dev/null+++ b/src/actions/provider-actions.js@@ -0,0 +1,66 @@+// 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 {createAction} from 'redux-actions';+import keyMirror from 'keymirror';+import {addPrefix} from 'constants/action-types';++export const ActionTypes = addPrefix(keyMirror({+ EXPORT_FILE_TO_CLOUD: null,+ EXPORT_FILE_SUCCESS: null,+ EXPORT_FILE_ERROR: null,+ RESET_PROVIDER_STATUS: null,+ SET_CLOUD_PROVIDER: null,+ SAVE_TO_CLOUD_SUCCESS: null+}));++export const exportFileToCloud = createAction(+ ActionTypes.EXPORT_FILE_TO_CLOUD,+ ({mapData, provider, isPublic, onSuccess, onError, closeModal}) => ({+ mapData,+ provider,+ isPublic,+ onSuccess,+ onError,+ closeModal+ })+);++export const exportFileSuccess = createAction(+ ActionTypes.EXPORT_FILE_SUCCESS,+ ({response, provider, onSuccess, closeModal}) => ({response, provider, onSuccess, closeModal})+);++export const exportFileError = createAction(+ ActionTypes.EXPORT_FILE_ERROR,+ ({error, provider, onError}) => ({error, provider, onError})+);++export const saveToCloudSuccess = createAction(+ ActionTypes.SAVE_TO_CLOUD_SUCCESS+)++export const resetProviderStatus = createAction(+ ActionTypes.RESET_PROVIDER_STATUS+);++export const setCloudProvider = createAction(+ ActionTypes.SET_CLOUD_PROVIDER,+ provider => provider+);diff --git a/src/actions/ui-state-actions.js b/src/actions/ui-state-actions.jsindex 3326d7693..9f75f662a 100644--- a/src/actions/ui-state-actions.js+++ b/src/actions/ui-state-actions.js@@ -115,34 +115,14 @@ export const removeNotification = createAction();/**- * Set `exportImage.ratio`+ * Set `exportImage` settings: ratio, resolution, legend* @memberof uiStateActions- * @param {string} ratio - one of `'SCREEN'`, `'FOUR_BY_THREE'` and `'SIXTEEN_BY_NINE'`+ * @param {Object} newSetting - {ratio: '1x'}* @public*/-export const setRatio = createAction(- ActionTypes.SET_RATIO,- ratio => ratio-);--/**- * Set `exportImage.resolution`- * @memberof uiStateActions- * @param {string} resolution - one of `'ONE_X'`, `'TWO_X'`- * @public- */-export const setResolution = createAction(- ActionTypes.SET_RESOLUTION,- resolution => resolution-);--/**- * Set `exportImage.legend` to true or false- * @memberof uiStateActions- * @public- */-export const toggleLegend = createAction(- ActionTypes.TOGGLE_LEGEND+export const setExportImageSetting = createAction(+ ActionTypes.SET_EXPORT_IMAGE_SETTING,+ newSetting => newSetting);/**diff --git a/src/actions/vis-state-actions.js b/src/actions/vis-state-actions.jsindex 47ec0bd20..f5bb1e110 100644--- a/src/actions/vis-state-actions.js+++ b/src/actions/vis-state-actions.js@@ -480,6 +480,21 @@ export function setFilterPlot(idx, newProp) {};}+/**+ * Set the property of a filter plot+ * @memberof visStateActions+ * @param {Number} idx+ * @param {Object} newProp key value mapping of new prop `{yAxis: 'histogram'}`+ * @returns {{type: ActionTypes.SET_FILTER_PLOT, idx: *, newProp: *}}+ * @public+ */+export function setMapInfo(info) {+ return {+ type: ActionTypes.SET_MAP_INFO,+ info+ };+}+/*** Trigger file loading dispatch `addDataToMap` if succeed, or `loadFilesErr` if failed* @memberof visStateActionsdiff --git a/src/components/common/icons/data-table.js b/src/components/common/icons/data-table.jsnew file mode 100644index 000000000..6d8c64e05--- /dev/null+++ b/src/components/common/icons/data-table.js@@ -0,0 +1,45 @@+// 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 React, {Component} from 'react';+import PropTypes from 'prop-types';+import Base from './base';++export default class DataTable extends Component {+ static displayName = 'DataTable';+ static propTypes = {+ /** Set the height of the icon, ex. '16px' */+ height: PropTypes.string+ };+ static defaultProps = {+ height: '16px',+ predefinedClassName: 'data-ex-icons-datatable'+ };++ render() {+ return (+ <Base {...this.props}>+ <g>+ <path d="M49.8627039,8 L14.1386877,8 C11.3005103,8 9,10.2588055 9,13.045531 L9,51.954469 C9,54.74165 11.3005103,57 14.1386877,57 L49.8627039,57 C52.7004174,57 54.9999999,54.74165 54.9999999,51.954469 L54.9999999,13.045531 C55.0004638,10.2588055 52.7008814,8 49.8627039,8 Z M23.6645354,52.7702626 C23.6645354,53.3860934 23.1134149,53.8844062 22.4328647,53.8844062 L13.8673027,53.8844062 C13.1862885,53.8844062 12.6351681,53.3856379 12.6351681,52.7702626 L12.6351681,45.0177179 C12.6351681,44.4009761 13.1862885,43.9022078 13.8673027,43.9022078 L22.4328647,43.9022078 C23.1134149,43.9022078 23.6645354,44.4009761 23.6645354,45.0177179 L23.6645354,52.7702626 Z M37.4773392,52.7702626 C37.4773392,53.3860934 36.9271465,53.8844062 36.2461324,53.8844062 L27.6810343,53.8844062 C26.9995562,53.8844062 26.4484358,53.3856379 26.4484358,52.7702626 L26.4484358,45.0177179 C26.4484358,44.4009761 26.9995562,43.9022078 27.6810343,43.9022078 L36.2456685,43.9022078 C36.9271465,43.9022078 37.4768752,44.4009761 37.4768752,45.0177179 L37.4768752,52.7702626 L37.4773392,52.7702626 Z M51.2910708,52.7702626 C51.2910708,53.3860934 50.7408781,53.8844062 50.059864,53.8844062 L41.494302,53.8844062 C40.8128239,53.8844062 40.2630952,53.3856379 40.2630952,52.7702626 L40.2630952,45.0177179 C40.2630952,44.4009761 40.8132878,43.9022078 41.494302,43.9022078 L50.0594001,43.9022078 C50.7408781,43.9022078 51.2906068,44.4009761 51.2906068,45.0177179 L51.2906068,52.7702626 L51.2910708,52.7702626 Z M23.6645354,39.9735533 C23.6645354,40.5893842 23.1134149,41.0886079 22.4328647,41.0886079 L13.8673027,41.0886079 C13.1862885,41.0886079 12.6351681,40.5889287 12.6351681,39.9735533 L12.6351681,32.2200976 C12.6351681,31.6042668 13.1862885,31.1054985 13.8673027,31.1054985 L22.4328647,31.1054985 C23.1134149,31.1054985 23.6645354,31.6047223 23.6645354,32.2200976 L23.6645354,39.9735533 Z M37.4773392,39.9735533 C37.4773392,40.5893842 36.9271465,41.0886079 36.2461324,41.0886079 L27.6810343,41.0886079 C26.9995562,41.0886079 26.4484358,40.5889287 26.4484358,39.9735533 L26.4484358,32.2200976 C26.4484358,31.6042668 26.9995562,31.1054985 27.6810343,31.1054985 L36.2456685,31.1054985 C36.9271465,31.1054985 37.4768752,31.6047223 37.4768752,32.2200976 L37.4768752,39.9735533 L37.4773392,39.9735533 Z M51.2910708,39.9735533 C51.2910708,40.5893842 50.7408781,41.0886079 50.059864,41.0886079 L41.494302,41.0886079 C40.8128239,41.0886079 40.2630952,40.5889287 40.2630952,39.9735533 L40.2630952,32.2200976 C40.2630952,31.6042668 40.8132878,31.1054985 41.494302,31.1054985 L50.0594001,31.1054985 C50.7408781,31.1054985 51.2906068,31.6047223 51.2906068,32.2200976 L51.2906068,39.9735533 L51.2910708,39.9735533 Z M23.6645354,26.9996561 C23.6645354,27.6159424 23.1134149,28.1142552 22.4328647,28.1142552 L13.8673027,28.1142552 C13.1862885,28.1142552 12.6351681,27.6159424 12.6351681,26.9996561 L12.6351681,19.2466558 C12.6351681,18.630825 13.1862885,18.1316012 13.8673027,18.1316012 L22.4328647,18.1316012 C23.1134149,18.1316012 23.6645354,18.630825 23.6645354,19.2466558 L23.6645354,26.9996561 Z M37.4773392,26.9996561 C37.4773392,27.6159424 36.9271465,28.1142552 36.2461324,28.1142552 L27.6810343,28.1142552 C26.9995562,28.1142552 26.4484358,27.6159424 26.4484358,26.9996561 L26.4484358,19.2466558 C26.4484358,18.630825 26.9995562,18.1316012 27.6810343,18.1316012 L36.2456685,18.1316012 C36.9271465,18.1316012 37.4768752,18.630825 37.4768752,19.2466558 L37.4768752,26.9996561 L37.4773392,26.9996561 Z M51.2910708,26.9996561 C51.2910708,27.6159424 50.7408781,28.1142552 50.059864,28.1142552 L41.494302,28.1142552 C40.8128239,28.1142552 40.2630952,27.6159424 40.2630952,26.9996561 L40.2630952,19.2466558 C40.2630952,18.630825 40.8132878,18.1316012 41.494302,18.1316012 L50.0594001,18.1316012 C50.7408781,18.1316012 51.2906068,18.630825 51.2906068,19.2466558 L51.2906068,26.9996561 L51.2910708,26.9996561 Z" />+ </g>+ </Base>+ );+ }+}diff --git a/src/components/common/icons/db.js b/src/components/common/icons/db.jsnew file mode 100644index 000000000..7fb22eeb9--- /dev/null+++ b/src/components/common/icons/db.js@@ -0,0 +1,45 @@+// 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 React, {Component} from 'react';+import PropTypes from 'prop-types';+import Base from './base';++export default class Db extends Component {+ static displayName = 'Db';+ static propTypes = {+ /** Set the height of the icon, ex. '16px' */+ height: PropTypes.string+ };+ static defaultProps = {+ height: '16px',+ predefinedClassName: 'data-ex-icons-db'+ };++ render() {+ return (+ <Base {...this.props}>+ <g>+ <path d="M32.000001,6 C26.2249941,6 20.9934005,7.06979182 17.0208337,8.93585449 C13.0482668,10.8019172 10,13.6479177 10,17.4078917 L10,45.5921083 C10,49.3520823 13.0482668,52.177146 17.0208337,54.0432087 C20.9934005,55.9092042 26.2249941,57 32.000001,57 C37.7750413,57 43.0066082,55.9092042 46.9791677,54.0432087 C50.9517265,52.177146 54,49.3520823 54,45.5921083 L54,17.4078917 C54,13.6479177 50.9517259,10.8019172 46.9791677,8.93585449 C43.0066075,7.06979182 37.7750406,6 32.0000003,6 L32.000001,6 Z M32.0000003,10 C37.2706271,10 42.0256405,11.0406591 45.2916666,12.5994318 C48.557694,14.1582045 50,16.0484773 50,17.5 C50,18.9515227 48.557694,20.8204545 45.2916666,22.3792273 C42.0256405,23.9380682 37.2706271,25 32.0000003,25 C26.7294069,25 21.9743668,23.9380682 18.7083334,22.3792273 C15.4422994,20.8204545 14,18.9515227 14,17.5 C14,16.0484773 15.4422994,14.1582045 18.7083334,12.5994318 C21.9743668,11.0406591 26.7294069,10 32.0000003,10 Z M14,24 C14.9089734,24.6525751 15.9275867,25.2372249 17.0208334,25.7463652 C20.9934001,27.5963149 26.2249936,28.6777307 32.0000003,28.6777307 C37.7750404,28.6777307 43.0066072,27.5963149 46.9791666,25.7463652 C48.0724133,25.2372249 49.0910266,24.6525751 50,24 L50,26.6818848 C50,28.0982036 48.557694,29.9218214 45.2916666,31.4427891 C42.0256405,32.9638898 37.2706271,34 32.0000003,34 C26.7294069,34 21.9743668,32.9638898 18.7083334,31.4427891 C15.4422994,29.9218214 14,28.0982036 14,26.6818848 L14,24 Z M14,33 C14.9091527,33.6585228 15.92008,34.251917 17.0208334,34.7635187 C20.9934001,36.6095602 26.2249936,37.6887967 32.0000003,37.6887967 C37.7750404,37.6887967 43.0066072,36.6095602 46.9791666,34.7635187 C48.07992,34.2518506 49.0908466,33.6585228 50,33 L50,35.6970954 C50,37.110473 48.557694,38.9302905 45.2916666,40.4480996 C42.0256405,41.9660415 37.2706271,43 32.0000003,43 C26.7294069,43 21.9743668,41.9660415 18.7083334,40.4480996 C15.4422994,38.9302905 14,37.110473 14,35.6970954 L14,33 Z M14,43 C14.9091527,43.6585228 15.92008,44.2518506 17.0208334,44.7635187 C20.9934001,46.6095602 26.2249936,47.6887967 32.0000003,47.6887967 C37.7750404,47.6887967 43.0066072,46.6095602 46.9791666,44.7635187 C48.07992,44.251917 49.0908466,43.6585228 50,43 L50,45.6970954 C50,47.110473 48.557694,48.9302905 45.2916666,50.4480996 C42.0256405,51.9659751 37.2706271,53 32.0000003,53 C26.7294069,53 21.9743668,51.9659751 18.7083334,50.4480996 C15.4422994,48.9302905 14,47.110473 14,45.6970954 L14,43 Z" />+ </g>+ </Base>+ );+ }+}diff --git a/src/components/common/icons/gear.js b/src/components/common/icons/gear.jsnew file mode 100644index 000000000..f883fb3cd--- /dev/null+++ b/src/components/common/icons/gear.js@@ -0,0 +1,45 @@+// 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 React, {Component} from 'react';+import PropTypes from 'prop-types';+import Base from './base';++export default class Gear extends Component {+ static propTypes = {+ /** Set the height of the icon, ex. '16px' */+ height: PropTypes.string+ };+ static defaultProps = {+ height: '16px',+ predefinedClassName: 'data-ex-icons-gear'+ };++ render() {+ return (+ <Base {...this.props}>+ <g>+ <path d="M39.1740741,58 L26.2185185,58 L25.9240741,52.012963 C24.9425926,51.7185185 24.0592593,51.3259259 23.1759259,50.9333333 L18.562963,54.7611111 L9.63148148,45.8296296 L13.6555556,41.2166667 C13.262963,40.3333333 12.8703704,39.45 12.5759259,38.5666667 L6.49074074,38.2722222 L6.49074074,25.3166667 L12.6740741,25.0222222 C12.9685185,24.0407407 13.3611111,23.1574074 13.7537037,22.3722222 L9.72962963,17.7592593 L18.6611111,8.82777778 L23.2740741,12.7537037 C24.0592593,12.3611111 24.9425926,11.8703704 26.0222222,11.5759259 L26.3166667,5.58888889 L39.1740741,5.58888889 L39.4685185,11.4777778 C40.45,11.7722222 41.3333333,12.1648148 42.412963,12.7537037 L46.7314815,8.92592593 L55.662963,17.8574074 L51.9333333,22.1759259 C52.4240741,23.2555556 52.8166667,24.237037 53.2092593,25.1203704 L58.9018519,25.4148148 L58.9018519,38.2722222 L53.2092593,38.5666667 C52.9148148,39.5481481 52.4240741,40.6277778 51.9333333,41.6092593 L55.5648148,45.9277778 L46.6333333,54.8592593 L42.3148148,51.0314815 C41.2351852,51.5222222 40.3518519,51.9148148 39.3703704,52.3074074 L39.1740741,58 Z M30.1444444,53.9759259 L35.3462963,53.9759259 L35.6407407,49.0685185 L37.112963,48.6759259 C38.5851852,48.2833333 40.0574074,47.6944444 41.8240741,46.712963 L43.1,46.0259259 L46.7314815,49.2648148 L50.362963,45.6333333 L47.2222222,42.0018519 L48.0074074,40.7259259 C48.7925926,39.3518519 49.4796296,37.6833333 49.8722222,36.112963 L50.2648148,34.6407407 L55.0740741,34.3462963 L55.0740741,29.1444444 L50.1666667,28.85 L49.7740741,27.3777778 C49.3814815,25.9055556 48.7925926,24.4333333 47.8111111,22.6666667 L47.1240741,21.4888889 L50.1666667,17.8574074 L46.5351852,14.2259259 L42.9037037,17.4648148 L41.7259259,16.7777778 C39.9592593,15.7962963 38.487037,15.2074074 37.0148148,14.8148148 L35.5425926,14.4222222 L35.2481481,9.51481481 L30.0462963,9.51481481 L29.7518519,14.6185185 L28.2796296,15.0111111 C26.9055556,15.4037037 25.6296296,15.8944444 23.9611111,16.8759259 L22.6851852,17.6611111 L18.7592593,14.2259259 L15.1277778,17.8574074 L18.562963,21.7833333 L17.7777778,23.0592593 C17.0907407,24.237037 16.5018519,25.7092593 16.0111111,27.4759259 L15.6185185,28.85 L10.4166667,29.1444444 L10.4166667,34.3462963 L15.6185185,34.6407407 L16.0111111,36.112963 C16.4037037,37.7814815 16.9925926,39.1555556 17.7777778,40.4314815 L18.562963,41.7074074 L15.1277778,45.6333333 L18.7592593,49.2648148 L22.6851852,46.0259259 L23.9611111,46.8111111 C25.3351852,47.5962963 26.6111111,48.1851852 28.2796296,48.5777778 L29.7518519,48.9703704 L30.1444444,53.9759259 Z" />+ <path d="M32.8068966,45.2275862 C25.2758621,45.2275862 19.1931034,39.2413793 19.1931034,31.9034483 C19.1931034,24.3724138 25.2758621,18.2896552 32.8068966,18.2896552 C40.337931,18.2896552 46.1310345,24.2758621 46.1310345,31.9034483 C46.2275862,39.2413793 40.1448276,45.2275862 32.8068966,45.2275862 Z M32.8068966,22.6344828 C27.6896552,22.6344828 23.537931,26.7862069 23.537931,31.9034483 C23.537931,36.9241379 27.6896552,40.9793103 32.8068966,40.9793103 C37.8275862,40.9793103 41.8827586,36.9241379 41.8827586,31.9034483 C41.8827586,26.6896552 37.9241379,22.6344828 32.8068966,22.6344828 Z" />+ </g>+ </Base>+ );+ }+}diff --git a/src/components/common/icons/index.js b/src/components/common/icons/index.jsindex 48c4c9d7e..89c6b931a 100644--- a/src/components/common/icons/index.js+++ b/src/components/common/icons/index.js@@ -30,6 +30,8 @@ export {default as Close} from './close';export {default as Crosshairs} from './crosshairs';export {default as Cube3d} from './cube-3d';export {default as CursorClick} from './cursor-click';+export {default as DataTable} from './data-table';+export {default as Db} from './db';export {default as Delete} from './delete';export {default as Docs} from './docs';export {default as DragNDrop} from './drag-n-drop';@@ -41,13 +43,17 @@ export {default as File} from './file';export {default as Files} from './files';export {default as FileType} from './file-type';export {default as FilterFunnel} from './filter-funnel';+export {default as Gear} from './gear';export {default as Histogram} from './histogram';export {default as Info} from './info';export {default as Layers} from './layers';export {default as LeftArrow} from './left-arrow';export {default as Legend} from './legend';export {default as LineChart} from './line-chart';+export {default as Logout} from './logout';+export {default as Login} from './login';export {default as Map} from './map';+export {default as MapIcon} from './map-icon';export {default as Minus} from './minus';export {default as Messages} from './messages';export {default as Pause} from './pause';@@ -58,6 +64,7 @@ export {default as Reduce} from './reduce';export {default as Reset} from './reset';export {default as Rocket} from './rocket';export {default as Save} from './save';+export {default as Save2} from './save2';export {default as Share} from './share';export {default as SquareSelect} from './square-select';export {default as Settings} from './settings';diff --git a/src/components/common/icons/login.js b/src/components/common/icons/login.jsnew file mode 100644index 000000000..7e51bd488--- /dev/null+++ b/src/components/common/icons/login.js@@ -0,0 +1,46 @@+// 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 React, {Component} from 'react';+import Base from './base';+import PropTypes from 'prop-types';++export default class Login extends Component {+ static propTypes = {+ height: PropTypes.string+ };++ static defaultProps = {+ height: '16px',+ predefinedClassName: 'data-ex-icons-login'+ };++ render() {+ return (+ <Base {...this.props}>+ <polygon+ id="Path"+ points="26.9730089 40.981391 30.7141656 44.7225477 44.0754395 31.3612739 30.7141656 18 26.9730089 21.7411567 33.9208713 28.6890191 8 28.6890191 8 34.0335286 33.9208713 34.0335286"+ ></polygon>+ <path d="M50.7560765,8 L13.3445095,8 C10.4050293,8 8,10.4050293 8,13.3445095 L8,24.0335286 L13.3445095,24.0335286 L13.3445095,13.3445095 L50.7560765,13.3445095 L50.7560765,50.7560765 L13.3445095,50.7560765 L13.3445095,40.0670573 L8,40.0670573 L8,50.7560765 C8,53.6955566 10.4050293,56.1005859 13.3445095,56.1005859 L50.7560765,56.1005859 C53.6955566,56.1005859 56.1005859,53.6955566 56.1005859,50.7560765 L56.1005859,13.3445095 C56.1005859,10.4050293 53.6955566,8 50.7560765,8 Z"></path>+ </Base>+ );+ }+}diff --git a/src/components/common/icons/logout.js b/src/components/common/icons/logout.jsnew file mode 100644index 000000000..4248bee09--- /dev/null+++ b/src/components/common/icons/logout.js@@ -0,0 +1,43 @@+// 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 React, {Component} from 'react';+import Base from './base';+import PropTypes from 'prop-types';++export default class Logout extends Component {+ static propTypes = {+ height: PropTypes.string+ };++ static defaultProps = {+ height: '16px',+ predefinedClassName: 'data-ex-icons-logout'+ };++ render() {+ return (+ <Base {...this.props}>+ <polygon points="27.1024306 41.981391 23.3612739 45.7225477 10 32.3612739 23.3612739 19 27.1024306 22.7411567 20.1545681 29.6890191 46.0754395 29.6890191 46.0754395 35.0335286 20.1545681 35.0335286"></polygon>+ <path d="M50.7560765,8 L13.3445095,8 C10.4050293,8 8,10.4050293 8,13.3445095 L8,24.0335286 L13.3445095,24.0335286 L13.3445095,13.3445095 L50.7560765,13.3445095 L50.7560765,50.7560765 L13.3445095,50.7560765 L13.3445095,40.0670573 L8,40.0670573 L8,50.7560765 C8,53.6955566 10.4050293,56.1005859 13.3445095,56.1005859 L50.7560765,56.1005859 C53.6955566,56.1005859 56.1005859,53.6955566 56.1005859,50.7560765 L56.1005859,13.3445095 C56.1005859,10.4050293 53.6955566,8 50.7560765,8 Z"></path>+ </Base>+ );+ }+};diff --git a/examples/demo-app/src/components/icons/map-icon.js b/src/components/common/icons/map-icon.jssimilarity index 95%rename from examples/demo-app/src/components/icons/map-icon.jsrename to src/components/common/icons/map-icon.jsindex 357ddc816..1a37b0ac4 100644--- a/examples/demo-app/src/components/icons/map-icon.js+++ b/src/components/common/icons/map-icon.js@@ -19,8 +19,8 @@// THE SOFTWARE.import React, {Component} from 'react';-import {Icons} from 'kepler.gl/components';import PropTypes from 'prop-types';+import Base from './base';class MapIcon extends Component {static propTypes = {@@ -31,13 +31,13 @@ class MapIcon extends Component {static defaultProps = {height: '16px',- predefinedClassName: 'data-ex-icons-add',+ predefinedClassName: 'data-ex-icons-map-icon',totalColor: 1};render() {return (- <Icons.IconWrapper {...this.props} viewBox={"0 0 602 602"}>+ <Base {...this.props} viewBox={"0 0 602 602"}><g><pathd="M573.864,323.679l25.6-201.737L409.988,50.046L197.993,151.289L0,67.678l27.935,220.105L2.223,506.009l208.665,39.135@@ -59,7 +59,7 @@ class MapIcon extends Component {c6.123,17.472,22.13,30.499,37.994,42.232c-2.902,4.64-4.664,10.084-4.664,15.953c0,16.681,13.507,30.192,30.198,30.192c16.657,0,30.192-13.512,30.192-30.192C536.213,418.979,522.689,405.449,506.021,405.449z"/></g>- </Icons.IconWrapper>+ </Base>);}}diff --git a/src/components/common/icons/save2.js b/src/components/common/icons/save2.jsnew file mode 100644index 000000000..40bb3ce93--- /dev/null+++ b/src/components/common/icons/save2.js@@ -0,0 +1,47 @@+// 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 React, {Component} from 'react';+import PropTypes from 'prop-types';+import Base from './base';++export default class Save2 extends Component {+ static propTypes = {+ /** Set the height of the icon, ex. '16px' */+ height: PropTypes.string+ };+ static defaultProps = {+ height: '16px',+ predefinedClassName: 'data-ex-icons-save2'+ };++ render() {+ return (+ <Base {...this.props}>+ <g>+ <path d="M37.9069767,38 L24.0930233,38 C22.9368372,38 22,38.8952 22,40 C22,41.1048 22.9368372,42 24.0930233,42 L37.9069767,42 C39.0631628,42 40,41.1048 40,40 C40,38.8952 39.0631628,38 37.9069767,38 Z" />+ <path d="M37.9069767,46 L24.0930233,46 C22.9368372,46 22,46.8952 22,48 C22,49.1048 22.9368372,50 24.0930233,50 L37.9069767,50 C39.0631628,50 40,49.1048 40,48 C40,46.8952 39.0631628,46 37.9069767,46 Z" />+ <path d="M47.9591688,8.6 C46.8447431,7.56810345 45.4006509,7 43.8938457,7 L39.6276717,7 L17.8756081,7 L13.0382379,7 C9.70852048,7 7,9.75517241 7,13.1422414 L7,50.8577586 C7,54.2448276 9.70852048,57 13.0382379,57 L17.8756081,57 L46.1243919,57 L50.9617621,57 C54.2914795,57 57,54.2448276 57,50.8577586 L57,19.6896552 C57,17.9637931 56.2804963,16.3086207 55.0270852,15.1474138 L47.9591688,8.6 Z M37.5089917,11.3103448 L37.5089917,17.275 C37.5089917,18.2655172 36.7157579,19.0724138 35.7420126,19.0724138 L21.7612671,19.0724138 C20.7875218,19.0724138 19.994288,18.2655172 19.994288,17.275 L19.994288,11.3103448 L37.5089917,11.3103448 Z M19.994288,52.6896552 L19.994288,34.9448276 C19.994288,33.9543103 20.7875218,33.1474138 21.7612671,33.1474138 L42.2387329,33.1474138 C43.2124782,33.1474138 44.005712,33.9543103 44.005712,34.9448276 L44.005712,52.6896552 L19.994288,52.6896552 Z M52.7634875,50.8577586 C52.7634875,51.8681034 51.9558467,52.6896552 50.9626095,52.6896552 L48.2439194,52.6896552 L48.2439194,34.9448276 C48.2439194,31.5775862 45.5506534,28.837069 42.2395803,28.837069 L21.7612671,28.837069 C18.4501941,28.837069 15.7569281,31.5775862 15.7569281,34.9448276 L15.7569281,52.6896552 L13.0382379,52.6896552 C12.0450008,52.6896552 11.23736,51.8681034 11.23736,50.8577586 L11.23736,13.1422414 C11.23736,12.1318966 12.0450008,11.3103448 13.0382379,11.3103448 L15.7569281,11.3103448 L15.7569281,17.275 C15.7569281,20.6422414 18.4501941,23.3827586 21.7612671,23.3827586 L35.7420126,23.3827586 C39.0530856,23.3827586 41.7463516,20.6422414 41.7463516,17.275 L41.7463516,11.3103448 L43.8938457,11.3103448 C44.3430058,11.3103448 44.7735216,11.4793103 45.1057306,11.787931 L52.175342,18.3353448 C52.5490771,18.6810345 52.7634875,19.1758621 52.7634875,19.6896552 L52.7634875,50.8577586 Z" />+ <path d="M32.8214286,17.6428571 C33.3022857,17.6428571 33.7685714,17.4440777 34.111,17.1073997 C34.4461429,16.7626531 34.6428571,16.2939445 34.6428571,15.8090988 C34.6428571,15.3242531 34.4461429,14.8555444 34.111,14.5181329 C33.4334286,13.8286397 32.2094286,13.8286397 31.5391429,14.5100643 C31.1967143,14.8555444 31,15.3242531 31,15.8090988 C31,16.2939445 31.1967143,16.7626531 31.5391429,17.1073997 C31.8742857,17.4440777 32.3405714,17.6428571 32.8214286,17.6428571 Z" />+ </g>+ </Base>+ );+ }+}diff --git a/src/components/common/image-preview.js b/src/components/common/image-preview.jsnew file mode 100644index 000000000..479a07d3a--- /dev/null+++ b/src/components/common/image-preview.js@@ -0,0 +1,107 @@+// 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 React from 'react';+import styled from 'styled-components';+import LoadingSpinner from 'components/common/loading-spinner';++const StyledImagePreview = styled.div.attrs({+ className: 'image-preview'+})`+ align-items: center;+ display: flex;+ flex-direction: column;+ flex: 1;+ justify-content: center;+ padding: 30px;++ .dimension,+ .instruction {+ padding: 8px 0px;+ }++ .preview-image {+ background: #e2e2e2;+ border-radius: 4px;+ box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.18);+ width: 100%;+ position: relative;+ }++ .preview-image-placeholder {+ position: absolute;+ top: 0;+ left: 0;+ width: 100%;+ height: 100%;+ }++ .preview-image-spinner {+ position: absolute;+ left: calc(50% - 25px);+ top: calc(50% - 25px);+ }++ .preview-image--error {+ font-size: 12px;+ padding: 12px;+ color: ${props => props.theme.errorColor};+ text-align: center;+ }+`;++const ImagePreview = ({exportImage = {}, width = 400, showDimension}) => {+ const {+ error,+ imageDataUri,+ exporting,+ imageSize: {imageW, imageH} = {}+ } = exportImage;++ const imageStyle = {+ width: `${width}px`,+ height: `${(imageH / (imageW || 1)) * width}px`+ };++ return (+ <StyledImagePreview>+ {showDimension ? (+ <div className="dimension">+ {imageW} pixel x {imageH} pixel+ </div>+ ) : null}+ <div className="preview-image" style={imageStyle}>+ {exporting ? (+ <div className="preview-image-spinner">+ <LoadingSpinner />+ </div>+ ) : error ? (+ <div className="preview-image--error">+ <span> {error.message || 'Generate map image failed!'}</span>+ </div>+ ) : (+ <img className="preview-image-placeholder" src={imageDataUri} />+ )}+ </div>+ </StyledImagePreview>+ );+};++export default ImagePreview;diff --git a/src/components/common/modal.js b/src/components/common/modal.jsindex a78c30dab..564be0b4e 100644--- a/src/components/common/modal.js+++ b/src/components/common/modal.js@@ -143,7 +143,7 @@ export const ModalFooter = ({class ModalDialog extends Component {static propTypes = {footer: PropTypes.bool,- close: PropTypes.func.isRequired,+ close: PropTypes.bool,onConfirm: PropTypes.func,onCancel: PropTypes.func,confirmButton: PropTypes.object,@@ -155,7 +155,7 @@ class ModalDialog extends Component {static defaultProps = {footer: false,- close: () => {},+ close: true,onConfirm: () => {},onCancel: () => {},cancelButton: defaultCancelButton,@@ -185,7 +185,7 @@ class ModalDialog extends Component {footer={props.footer}>{props.close && (- <CloseButton className="modal--close" onClick={props.close}>+ <CloseButton className="modal--close" onClick={props.onCancel}><Delete height="14px" /></CloseButton>)}@@ -196,7 +196,7 @@ class ModalDialog extends Component {<ModalContent className="modal--body">{props.children}</ModalContent>{props.footer && (<ModalFooter- cancel={props.close}+ cancel={props.onCancel}confirm={props.onConfirm}cancelButton={props.cancelButton}confirmButton={props.confirmButton}diff --git a/src/components/common/styled-components.js b/src/components/common/styled-components.jsindex 0cc272316..aca2e1f92 100644--- a/src/components/common/styled-components.js+++ b/src/components/common/styled-components.js@@ -60,6 +60,12 @@ export const CenterFlexbox = styled.div`align-items: center;`;+export const CenterVerticalFlexbox = styled.div`+ display: flex;+ flex-direction: column;+ align-items: center;+`;+export const SpaceBetweenFlexbox = styled.div`display: flex;justify-content: space-between;@@ -236,7 +242,8 @@ export const Button = styled.div.attrs({}svg {- margin-right: 8px;+ margin-right: ${props =>+ props.large ? '10px' : props.small ? '6px' : '8px'};}`;@@ -249,6 +256,16 @@ export const InputLight = styled.input`${props => props.theme.inputLT}`;+export const TextArea = styled.textarea`+ ${props =>+ props.secondary ? props.theme.secondaryInput : props.theme.input};+`;+export const TextAreaLight = styled.textarea`+ ${props => props.theme.inputLT}+ height: auto;+ white-space: pre-wrap;+`;+export const InlineInput = styled(Input)`${props => props.theme.inlineInput};`;@@ -369,6 +386,59 @@ export const StyledModalContent = styled.div``};`;+export const StyledModalVerticalPanel = styled.div.attrs({+ className: 'modal-vertical-panel'+})`+ display: flex;+ flex-direction: column;+ justify-content: space-around;+ font-size: 12px;++ .modal-section:first-child {+ margin-top: 24px;+ ${media.palm`+ margin-top: 0;+ `};+ }++ input {+ margin-right: 8px;+ }+`;++export const StyledModalSection = styled.div.attrs({+ className: 'modal-section'+})`+ margin-bottom: 32px;++ .modal-section-title {+ font-weight: 500;+ }+ .modal-section-subtitle {+ color: ${props => props.theme.subtextColorLT};+ }++ input {+ margin-top: 8px;+ }++ ${media.portable`+ margin-bottom: 24px;+ `};+ ${media.palm`+ margin-bottom: 16px;+ `};+`;++export const StyledModalInputFootnote = styled.div.attrs({+ className: 'modal-input__footnote'+})`+ display: flex;+ justify-content: flex-end;+ color: ${props =>+ props.error ? props.theme.errorColor : props.theme.subtextColorLT};+ font-size: 10px;+`;/*** Newer versions of mapbox.gl display an error message banner on top of the map by default* which will cause the map to display points in the wrong locations@@ -385,21 +455,28 @@ export const StyledExportSection = styled.div`flex-direction: row;margin: 35px 0;width: 100%;+ color: ${props => props.theme.textColorLT};+ font-size: 12px;+ opacity: ${props => (props.disabled ? 0.3 : 1)};+ pointer-events: ${props => (props.disabled ? 'none' : 'all')};.description {width: 185px;-.title {font-weight: 500;- color: ${props => props.theme.textColorLT};- font-size: 12px;}.subtitle {- color: ${props => props.theme.textColor};+ color: ${props => props.theme.subtextColorLT};font-size: 11px;}}-+ .warning {+ color: ${props => props.theme.errorColor};+ font-weight: 500;+ }+ .description.full {+ width: 100%;+ }.selection {display: flex;flex-wrap: wrap;diff --git a/src/components/common/toolbar-item.js b/src/components/common/toolbar-item.jsindex 7d6d48b36..5fe45d453 100644--- a/src/components/common/toolbar-item.js+++ b/src/components/common/toolbar-item.js@@ -21,20 +21,26 @@import React from 'react';import styled from 'styled-components';-const StyledDiv = styled.div`- color: ${props => props.active ?- 'white' : props.theme.textColor- };+const StyledDiv = styled.div.attrs({+ className: 'toolbar-item'+})`+ color: ${props => (props.active ? 'white' : props.theme.textColor)};`;-const ToolbarItem = React.memo(({active, className, icon, label, onClick}) => (- <StyledDiv active={active} className="toolbar-item" onClick={(e) => {- e.stopPropagation();- e.preventDefault();- onClick(e);- }}>- {icon}- <div className="toolbar-item__title">{label}</div>+const ToolbarItem = React.memo(props => (+ <StyledDiv+ active={props.active}+ onClick={e => {+ e.stopPropagation();+ e.preventDefault();+ if (typeof props.onClose === 'function') {+ props.onClose();+ }+ props.onClick(e);+ }}+ >+ <props.icon/>+ <div className="toolbar-item__title">{props.label}</div></StyledDiv>));diff --git a/src/components/common/toolbar.js b/src/components/common/toolbar.jsindex 7c06aa0ee..4a452ae8d 100644--- a/src/components/common/toolbar.js+++ b/src/components/common/toolbar.js@@ -28,13 +28,13 @@ const Toolbar = styled.div`font-size: 11px;padding: 16px 0;transition: ${props => props.theme.transitionSlow};- margin-top: ${props => props.show ? '6px' : '20px'};- opacity: ${props => props.show ? 1 : 0};+ margin-top: ${props => (props.show ? '6px' : '20px')};+ opacity: ${props => (props.show ? 1 : 0)};transform: translateX(calc(-50% + 20px));- pointer-events: ${props => props.show ? 'all' : 'none'};+ pointer-events: ${props => (props.show ? 'all' : 'none')};z-index: 1000;- .save-export-dropdown__inner {+ .panel-header-dropdown__inner {box-shadow: none;background-color: transparent;display: flex;@@ -46,7 +46,7 @@ const Toolbar = styled.div`padding: 0 22px;display: flex;flex-direction: column;-+.toolbar-item__title {white-space: nowrap;margin-top: 4px;diff --git a/src/components/index.js b/src/components/index.jsindex f8bfff1ff..ffdf1051a 100644--- a/src/components/index.js+++ b/src/components/index.js@@ -35,10 +35,7 @@ export {default as PlotContainerFactory} from './plot-container';export {default as PanelHeaderFactory,SaveExportDropdownFactory,- ExportImageFactory,- ExportDataFactory,- ExportMapFactory,- SaveMapFactory+ PanelHeaderDropdownFactory} from './side-panel/panel-header'export {CollapseButtonFactory, default as SidebarFactory} from './side-panel/side-bar';export {default as PanelToggleFactory} from './side-panel/panel-toggle';diff --git a/src/components/kepler-gl.js b/src/components/kepler-gl.jsindex 027fc9f2d..4a2fac488 100644--- a/src/components/kepler-gl.js+++ b/src/components/kepler-gl.js@@ -29,6 +29,7 @@ import * as VisStateActions from 'actions/vis-state-actions';import * as MapStateActions from 'actions/map-state-actions';import * as MapStyleActions from 'actions/map-style-actions';import * as UIStateActions from 'actions/ui-state-actions';+import * as ProviderActions from 'actions/provider-actions';import {EXPORT_IMAGE_ID,@@ -36,7 +37,8 @@ import {KEPLER_GL_NAME,KEPLER_GL_VERSION,THEME,- DEFAULT_MAPBOX_API_URL+ DEFAULT_MAPBOX_API_URL,+ SAVE_MAP_ID} from 'constants/default-settings';import {MISSING_MAPBOX_TOKEN} from 'constants/user-feedbacks';@@ -95,7 +97,7 @@ KeplerGlFactory.deps = [function KeplerGlFactory(BottomWidget,MapContainer,- ModalWrapper,+ ModalContainer,SidePanel,PlotContainer,NotificationPanel@@ -110,7 +112,8 @@ function KeplerGlFactory(appName: KEPLER_GL_NAME,version: KEPLER_GL_VERSION,sidePanelWidth: DIMENSIONS.sidePanel.width,- theme: {}+ theme: {},+ cloudProviders: []};componentDidMount() {@@ -134,7 +137,7 @@ function KeplerGlFactory(root = createRef();- /* selector */+ /* selectors */themeSelector = props => props.theme;availableThemeSelector = createSelector(this.themeSelector,@@ -149,6 +152,16 @@ function KeplerGlFactory(: theme);+ availableProviders = createSelector(+ props => props.cloudProviders,+ providers => Array.isArray(providers) && providers.length ?+ ({+ hasStorage: providers.some(p => p.hasPrivateStorage()),+ hasShare: providers.some(p => p.hasSharingUrl())+ }) : {}+ );++ /* private methods */_validateMapboxToken() {const {mapboxApiAccessToken} = this.props;if (!validateToken(mapboxApiAccessToken)) {@@ -213,9 +226,12 @@ function KeplerGlFactory(visStateActions,mapStateActions,mapStyleActions,- uiStateActions+ uiStateActions,+ providerActions} = this.props;+ const availableProviders = this.availableProviders(this.props);+const {filters,layers,@@ -249,11 +265,13 @@ function KeplerGlFactory(mapStyle,layerBlending,onSaveMap,+ // onSaveToStorage,uiState,mapStyleActions,visStateActions,uiStateActions,- width: this.props.sidePanelWidth+ width: this.props.sidePanelWidth,+ availableProviders};const mapFields = {@@ -304,7 +322,8 @@ function KeplerGlFactory(/>));- const isExporting = uiState.currentModal === EXPORT_IMAGE_ID;+ const isExporting =+ uiState.currentModal === EXPORT_IMAGE_ID || uiState.currentModal === SAVE_MAP_ID;const theme = this.availableThemeSelector(this.props);return (@@ -347,7 +366,7 @@ function KeplerGlFactory(}containerW={containerW}/>- <ModalWrapper+ <ModalContainermapStyle={mapStyle}visState={visState}mapState={mapState}@@ -357,9 +376,14 @@ function KeplerGlFactory(visStateActions={visStateActions}uiStateActions={uiStateActions}mapStyleActions={mapStyleActions}+ providerActions={providerActions}rootNode={this.root.current}containerW={containerW}containerH={mapState.height}+ providerState={this.props.providerState}+ cloudProviders={this.props.cloudProviders}+ onExportToCloudSuccess={this.props.onExportToCloudSuccess}+ onExportToCloudError={this.props.onExportToCloudError}/></GlobalStyle></ThemeProvider>@@ -378,7 +402,8 @@ function mapStateToProps(state = {}, props) {visState: state.visState,mapStyle: state.mapStyle,mapState: state.mapState,- uiState: state.uiState+ uiState: state.uiState,+ providerState: state.providerState};}@@ -390,11 +415,12 @@ function makeGetActionCreators() {return createSelector([getDispatch, getUserActions],(dispatch, userActions) => {- const [visStateActions, mapStateActions, mapStyleActions, uiStateActions] = [+ const [visStateActions, mapStateActions, mapStyleActions, uiStateActions, providerActions] = [VisStateActions,MapStateActions,MapStyleActions,- UIStateActions+ UIStateActions,+ ProviderActions].map(actions =>bindActionCreators(mergeActions(actions, userActions), dispatch));@@ -404,6 +430,7 @@ function makeGetActionCreators() {mapStateActions,mapStyleActions,uiStateActions,+ providerActions,dispatch};}diff --git a/src/components/map/map-control.js b/src/components/map/map-control.jsindex 19e482265..f52042506 100644--- a/src/components/map/map-control.js+++ b/src/components/map/map-control.js@@ -261,26 +261,30 @@ const MapDrawPanel = React.memo(({<ToolbarItemonClick={() => onSetEditorMode(EDITOR_MODES.EDIT)}label="select"- icon={(<CursorClick height="22px"/>)}+ iconHeight="22px"+ icon={CursorClick}active={editor.mode === EDITOR_MODES.EDIT}/><ToolbarItemonClick={() => onSetEditorMode(EDITOR_MODES.DRAW_POLYGON)}label="polygon"- icon={(<Polygon height="22px"/>)}+ iconHeight="22px"+ icon={Polygon}active={editor.mode === EDITOR_MODES.DRAW_POLYGON}/><ToolbarItemonClick={() => onSetEditorMode(EDITOR_MODES.DRAW_RECTANGLE)}label="rectangle"- icon={(<Rectangle height="22px"/>)}+ iconHeight="22px"+ icon={Rectangle}active={editor.mode === EDITOR_MODES.DRAW_RECTANGLE}/><ToolbarItemonClick={onToggleEditorVisibility}label={editor.visible ? 'hide' : 'show'}- icon={editor.visible ? (<EyeSeen height="22px"/>) : (<EyeUnseen height="22px"/>)}- active={true}+ iconHeight="22px"+ icon={editor.visible ? EyeSeen : EyeUnseen}+ active/></StyledToolbar>) : null}diff --git a/src/components/modal-container.js b/src/components/modal-container.jsindex d93702463..b9b731c39 100644--- a/src/components/modal-container.js+++ b/src/components/modal-container.js@@ -22,12 +22,12 @@ import React, {Component} from 'react';import PropTypes from 'prop-types';import {css} from 'styled-components';import {findDOMNode} from 'react-dom';-import {Blob} from 'global/window';import ModalDialogFactory from './modals/modal-dialog';-import {formatCsv} from 'processors/data-processor';import KeplerGlSchema from 'schemas';-import {downloadFile, dataURItoBlob} from 'utils/export-image-utils';+import {exportJson, exportHtml, exportData, exportImage, exportMap} from 'utils/export-utils';+import {isValidMapInfo} from 'utils/map-info-utils';+// modalsimport DeleteDatasetModalFactory from './modals/delete-data-modal';import DataTableModalFactory from './modals/data-table-modal';@@ -36,22 +36,23 @@ import ExportImageModalFactory from './modals/export-image-modal';import ExportDataModalFactory from './modals/export-data-modal';import ExportMapModalFactory from './modals/export-map-modal/export-map-modal';import AddMapStyleModalFactory from './modals/add-map-style-modal';+import SaveMapModalFactory from './modals/save-map-modal';+import ShareMapModalFactory from './modals/share-map-modal';// Breakpointsimport {media} from 'styles/media-breakpoints';// Template-import {exportMapToHTML} from 'templates/export-map-html';import {ADD_DATA_ID,DATA_TABLE_ID,- DEFAULT_EXPORT_IMAGE_NAME,DELETE_DATA_ID,EXPORT_DATA_ID,- EXPORT_DATA_TYPE,EXPORT_IMAGE_ID,EXPORT_MAP_ID,- ADD_MAP_STYLE_ID+ ADD_MAP_STYLE_ID,+ SAVE_MAP_ID,+ SHARE_MAP_ID} from 'constants/default-settings';import {EXPORT_MAP_FORMATS} from '../constants/default-settings';@@ -78,6 +79,10 @@ const LoadDataModalStyle = css`top: 60px;`;+const DefaultStyle = css`+ max-width: 960px;+`+ModalContainerFactory.deps = [DeleteDatasetModalFactory,DataTableModalFactory,@@ -86,7 +91,9 @@ ModalContainerFactory.deps = [ExportDataModalFactory,ExportMapModalFactory,AddMapStyleModalFactory,- ModalDialogFactory+ ModalDialogFactory,+ SaveMapModalFactory,+ ShareMapModalFactory];export default function ModalContainerFactory(@@ -97,7 +104,9 @@ export default function ModalContainerFactory(ExportDataModal,ExportMapModal,AddMapStyleModal,- ModalDialog+ ModalDialog,+ SaveMapModal,+ ShareMapModal) {class ModalWrapper extends Component {static propTypes = {@@ -112,7 +121,9 @@ export default function ModalContainerFactory(visState: PropTypes.object.isRequired,visStateActions: PropTypes.object.isRequired,uiStateActions: PropTypes.object.isRequired,- mapStyleActions: PropTypes.object.isRequired+ mapStyleActions: PropTypes.object.isRequired,+ onSaveToStorage: PropTypes.func,+ cloudProviders: PropTypes.arrayOf(PropTypes.object)};_closeModal = () => {@@ -134,101 +145,54 @@ export default function ModalContainerFactory(};_onExportImage = () => {- const {exporting, imageDataUri} = this.props.uiState.exportImage;- if (!exporting && imageDataUri) {- const file = dataURItoBlob(imageDataUri);- downloadFile(file, DEFAULT_EXPORT_IMAGE_NAME);+ if (!this.props.uiState.exportImage.exporting) {+ exportImage(this.props, this.props.uiState.exportImage);+ this.props.uiStateActions.cleanupExportImage();+ this._closeModal();}- this.props.uiStateActions.cleanupExportImage();- this._closeModal();};- _downloadFile(data, type, filename) {- const fileBlob = new Blob([data], {type});- downloadFile(fileBlob, filename);- }-_onExportData = () => {- const {visState, uiState} = this.props;- const {datasets} = visState;- const {selectedDataset, dataType, filtered} = uiState.exportData;- // get the selected data- const filename = 'kepler-gl';- const selectedDatasets = datasets[selectedDataset] ?- [datasets[selectedDataset]] : Object.values(datasets);-- if (!selectedDatasets.length) {- // error: selected dataset not found.- this._closeModal();- }-- selectedDatasets.forEach(selectedData => {- const {allData, fields, label, filteredIdxCPU = []} = selectedData;- const exportData = filtered ? filteredIdxCPU.map(i => allData[i]) : allData;- // start to export data according to selected data type- switch (dataType) {- case EXPORT_DATA_TYPE.CSV: {- const type = 'text/csv';- const csv = formatCsv(exportData, fields);- this._downloadFile(csv, type, `${filename}_${label}.csv`);- break;- }- // TODO: support more file types.- default:- break;- }- });-+ exportData(this.props, this.props.uiState.exportData);this._closeModal();};- _onExportJSONMap = () => {+ _onExportMap = () => {const {uiState} = this.props;- const {hasData} = uiState.exportMap[EXPORT_MAP_FORMATS.JSON];-- // we pass all props because we avoid to create new variables- const data = hasData ? KeplerGlSchema.save(this.props)- : KeplerGlSchema.getConfigToSave(this.props);-- this._downloadFile(- JSON.stringify(data, null, 2),- 'application/json',- 'keplergl.json'+ const {format} = uiState.exportMap;+ (format === EXPORT_MAP_FORMATS.HTML ? exportHtml : exportJson)(+ this.props,+ this.props.uiState.exportMap[format] || {});-this._closeModal();};- _onExportHTMLMap = () => {- const {uiState} = this.props;- const {userMapboxToken, exportMapboxAccessToken, mode} = uiState.exportMap[EXPORT_MAP_FORMATS.HTML];+ _exportFileToCloud = ({provider, isPublic, closeModal}) => {+ const toSave = exportMap(this.props);+ this.props.providerActions.exportFileToCloud({+ mapData: toSave,+ provider,+ isPublic,+ closeModal,+ onSuccess: this.props.onExportToCloudSuccess,+ onError: this.props.onExportToCloudError+ });+ }- const data = {- ...KeplerGlSchema.save(this.props),- mapboxApiAccessToken: (userMapboxToken || '') !== '' ? userMapboxToken : exportMapboxAccessToken,- mode- };+ _onSaveMap = () => {+ const {currentProvider} = this.props.providerState;+ const provider = this.props.cloudProviders.find(p => p.name === currentProvider);+ this._exportFileToCloud({provider, isPublic: false, closeModal: true});+ }- this._downloadFile(- exportMapToHTML(data),- 'text/html',- 'kepler.gl.html'- );+ _onShareMapUrl = (provider) => {+ this._exportFileToCloud({provider, isPublic: true, closeModal: false});+ }+ _onCloseSaveMap = () => {+ this.props.providerActions.resetProviderStatus();this._closeModal();- };-- _onExportMap = () => {- const {uiState} = this.props;- const {format} = uiState.exportMap;-- const downloader = {- [EXPORT_MAP_FORMATS.HTML]: this._onExportHTMLMap,- [EXPORT_MAP_FORMATS.JSON]: this._onExportJSONMap- }[format];-- downloader && downloader();- };+ }/* eslint-disable complexity */render() {@@ -240,7 +204,10 @@ export default function ModalContainerFactory(uiState,visState,rootNode,- visStateActions+ visStateActions,+ uiStateActions,+ cloudProviders,+ providerState} = this.props;const {currentModal, datasetKeyToRemove} = uiState;const {datasets, layers, editingDataset} = visState;@@ -285,7 +252,6 @@ export default function ModalContainerFactory(layers={layers}/>);-modalProps = {title: 'Delete Dataset',cssStyle: DeleteDatasetModalStyled,@@ -318,16 +284,13 @@ export default function ModalContainerFactory(case EXPORT_IMAGE_ID:template = (<ExportImageModal- {...uiState.exportImage}- width={containerW}- height={containerH}- onChangeRatio={this.props.uiStateActions.setRatio}- onChangeResolution={this.props.uiStateActions.setResolution}- onToggleLegend={this.props.uiStateActions.toggleLegend}+ exportImage={uiState.exportImage}+ mapW={containerW}+ mapH={containerH}+ onUpdateSetting={uiStateActions.setExportImageSetting}/>);modalProps = {- close: false,title: 'Export Image',footer: true,onCancel: this._closeModal,@@ -346,13 +309,12 @@ export default function ModalContainerFactory(datasets={datasets}applyCPUFilter={this.props.visStateActions.applyCPUFilter}onClose={this._closeModal}- onChangeExportDataType={this.props.uiStateActions.setExportDataType}- onChangeExportSelectedDataset={this.props.uiStateActions.setExportSelectedDataset}- onChangeExportFiltered={this.props.uiStateActions.setExportFiltered}+ onChangeExportDataType={uiStateActions.setExportDataType}+ onChangeExportSelectedDataset={uiStateActions.setExportSelectedDataset}+ onChangeExportFiltered={uiStateActions.setExportFiltered}/>);modalProps = {- close: false,title: 'Export Data',footer: true,onCancel: this._closeModal,@@ -365,19 +327,18 @@ export default function ModalContainerFactory(break;case EXPORT_MAP_ID:const keplerGlConfig = KeplerGlSchema.getConfigToSave(- { mapStyle, visState, mapState, uiState }+ {mapStyle, visState, mapState, uiState});template = (<ExportMapModalconfig={keplerGlConfig}options={uiState.exportMap}- onChangeExportMapFormat={this.props.uiStateActions.setExportMapFormat}- onEditUserMapboxAccessToken={this.props.uiStateActions.setUserMapboxAccessToken}- onChangeExportMapHTMLMode={this.props.uiStateActions.setExportHTMLMapMode}+ onChangeExportMapFormat={uiStateActions.setExportMapFormat}+ onEditUserMapboxAccessToken={uiStateActions.setUserMapboxAccessToken}+ onChangeExportMapHTMLMode={uiStateActions.setExportHTMLMapMode}/>);modalProps = {- close: false,title: 'Export Map',footer: true,onCancel: this._closeModal,@@ -400,7 +361,6 @@ export default function ModalContainerFactory(/>);modalProps = {- close: false,title: 'Add Custom Mapbox Style',footer: true,onCancel: this._closeModal,@@ -412,7 +372,47 @@ export default function ModalContainerFactory(}};break;+ case SAVE_MAP_ID:+ template = (+ <SaveMapModal+ {...providerState}+ exportImage={uiState.exportImage}+ mapInfo={visState.mapInfo}+ onSetMapInfo={visStateActions.setMapInfo}+ onUpdateSetting={uiStateActions.setExportImageSetting}+ cloudProviders={cloudProviders.filter(p => p.hasPrivateStorage())}+ onSetCloudProvider={this.props.providerActions.setCloudProvider}+ />+ );+ modalProps = {+ title: 'Save Map',+ footer: true,+ onCancel: this._closeModal,+ onConfirm: this._onSaveMap,+ confirmButton: {+ large: true,+ disabled: uiState.exportImage.exporting ||+ !isValidMapInfo(visState.mapInfo) ||+ !providerState.currentProvider,+ children: 'Save'+ }+ };+ break;+ case SHARE_MAP_ID:+ template = (+ <ShareMapModal+ {...providerState}+ cloudProviders={cloudProviders.filter(p => p.hasSharingUrl())}+ onExport={this._onShareMapUrl}+ onSetCloudProvider={this.props.providerActions.setCloudProvider}+ />+ );+ modalProps = {+ title: 'Share URL',+ onCancel: this._onCloseSaveMap+ };+ break;default:break;}@@ -420,10 +420,11 @@ export default function ModalContainerFactory(return this.props.rootNode ? (<ModalDialog- {...modalProps}parentSelector={() => findDOMNode(rootNode)}isOpen={Boolean(currentModal)}- close={this._closeModal}+ onCancel={this._closeModal}+ {...modalProps}+ cssStyle={DefaultStyle.concat(modalProps.cssStyle || '')}>{template}</ModalDialog>diff --git a/src/components/modals/add-map-style-modal.js b/src/components/modals/add-map-style-modal.jsindex c92b82a7f..767d950c5 100644--- a/src/components/modals/add-map-style-modal.js+++ b/src/components/modals/add-map-style-modal.js@@ -27,7 +27,9 @@ import MapboxGLMap from 'react-map-gl';import {StyledModalContent,InputLight,- StyledMapContainer+ StyledMapContainer,+ StyledModalVerticalPanel,+ StyledModalSection} from 'components/common/styled-components';import {media} from 'styles/media-breakpoints';@@ -41,46 +43,6 @@ const ErrorMsg = {'Failed to load map style, make sure it is published. For private style, paste in your access token.'};-const InstructionPanel = styled.div`- display: flex;- flex-direction: column;- justify-content: space-around;- font-size: 12px;-- .modal-section:first-child {- margin-top: 24px;- ${media.palm`- margin-top: 0;- `};- }-- input {- margin-right: 8px;- }-`;--const StyledModalSection = styled.div`- margin-bottom: 32px;-- .modal-section-title {- font-weight: 500;- }- .modal-section-subtitle {- color: ${props => props.theme.subtextColorLT};- }-- input {- margin-top: 8px;- }-- ${media.portable`- margin-bottom: 24px;- `};- ${media.palm`- margin-bottom: 16px;- `};-`;-const PreviewMap = styled.div`align-items: center;display: flex;@@ -215,8 +177,8 @@ function AddMapStyleModalFactory() {return (<div className="add-map-style-modal"><StyledModalContent>- <InstructionPanel>- <StyledModalSection className="modal-section">+ <StyledModalVerticalPanel>+ <StyledModalSection><div className="modal-section-title">1. Publish your style at mapbox or provide access token</div>@@ -260,7 +222,7 @@ function AddMapStyleModalFactory() {placeholder="e.g. pk.abcdefg.xxxxxx"/></StyledModalSection>- <StyledModalSection className="modal-section">+ <StyledModalSection><div className="modal-section-title">2. Paste style url</div><div className="modal-section-subtitle">What is a@@ -281,7 +243,7 @@ function AddMapStyleModalFactory() {placeholder="e.g. mapbox://styles/uberdataviz/abcdefghijklmnopq"/></StyledModalSection>- <StyledModalSection className="modal-section">+ <StyledModalSection><div className="modal-section-title">3. Name your style</div><InputLighttype="text"@@ -291,7 +253,7 @@ function AddMapStyleModalFactory() {}/></StyledModalSection>- </InstructionPanel>+ </StyledModalVerticalPanel><PreviewMap><divclassName={classnames('preview-title', {diff --git a/src/components/modals/cloud-tile.js b/src/components/modals/cloud-tile.jsnew file mode 100644index 000000000..a1c4de37e--- /dev/null+++ b/src/components/modals/cloud-tile.js@@ -0,0 +1,184 @@+// 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 React from 'react';+import styled from 'styled-components';+import {Logout, Login} from 'components/common/icons';+import {+ CenterVerticalFlexbox,+ Button+} from 'components/common/styled-components';++const StyledTileWrapper = styled.div.attrs({+ className: 'provider-tile__wrapper'+})`+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: flex-start;+ border-radius: 2px;+ border: 1px solid+ ${props =>+ props.selected+ ? props.theme.primaryBtnBgd+ : props.theme.selectBorderColorLT};+ color: ${props =>+ props.selected+ ? props.theme.primaryBtnBgd+ : props.theme.selectBorderColorLT};+ cursor: pointer;+ font-weight: 500;+ width: 120px;+ height: 168px;+ background-color: #ffffff;+ transition: ${props => props.theme.transition};+ position: relative;+ :hover {+ border: 1px solid ${props => props.theme.primaryBtnBgd};+ color: ${props => props.theme.primaryBtnBgd};+ }++ .button {+ margin-top: 20px;+ }+`;++const CheckMark = styled.span.attrs({+ className: 'checkbox-inner'+})`+ background-color: ${props => props.theme.primaryBtnBgd};+ position: absolute;+ bottom: 0;+ right: 0;+ display: block;+ width: 16px;+ height: 16px;+ border-top-left-radius: 2px;++ :after {+ position: absolute;+ display: table;+ border: 2px solid #fff;+ border-top: 0;+ border-left: 0;+ transform: rotate(45deg) scale(1) translate(-50%, -50%);+ opacity: 1;+ content: ' ';+ top: 50%;+ left: 25%;+ width: 5.7px;+ height: 9.1px;+ }+`;+const StyledBox = styled(CenterVerticalFlexbox)`+ margin-right: 12px;+`;++const StyledCloudName = styled.div`+ font-size: 12px;+ margin-top: 12px;+ margin-bottom: 4px;+`;++const StyledUserName = styled.div`+ font-size: 11px;+ margin-top: 8px;+ text-align: center;+ color: ${props => props.theme.primaryBtnActBgd};+ overflow: hidden;+ width: 100px;+ text-overflow: ellipsis;+`;++const LoginButton = ({onClick}) => (+ <Button link small onClick={onClick}>+ <Login />+ Login+ </Button>+);++const LogoutButton = ({onClick}) => (+ <Button link small onClick={onClick}>+ <Logout />+ Logout+ </Button>+);++// eslint-disable-next-line complexity+const CloudTile = ({+ // action when click on the tile+ onSelect,+ // default to login+ onConnect,+ // default to logout+ onLogout,+ // action name+ actionName,+ // cloud provider class+ cloudProvider,+ // function to take after login or logout+ onSetCloudProvider,+ // whether provider is selected as currentProvider+ isSelected,+ // whether user has logged in+ isConnected+}) => {+ const userName =+ typeof cloudProvider.getUserName === 'function'+ ? cloudProvider.getUserName()+ : null;+ const onClickConnect =+ typeof onConnect === 'function'+ ? onConnect+ : () => cloudProvider.login(() => onSetCloudProvider(cloudProvider.name));++ const onClickLogout =+ typeof onLogout === 'function'+ ? onLogout+ : () => cloudProvider.logout(() => isSelected ? onSetCloudProvider(null) : null);++ return (+ <StyledBox>+ <StyledTileWrapper+ onClick={isConnected ? onSelect : onClickConnect}+ selected={isSelected}+ >+ <StyledCloudName>+ {cloudProvider.displayName || cloudProvider.name}+ </StyledCloudName>+ {cloudProvider.icon ? <cloudProvider.icon height="64px" /> : null}+ {isConnected && actionName ? (+ <Button className="cloud-tile__action" small secondary>+ {actionName}+ </Button>+ ) : null}+ {userName && <StyledUserName>{userName}</StyledUserName>}+ {isSelected && <CheckMark />}+ </StyledTileWrapper>+ {isConnected ? (+ <LogoutButton className="logout-button" onClick={onClickLogout} />+ ) : (+ <LoginButton className="login-button" onClick={onClickConnect} />+ )}+ </StyledBox>+ );+};++export default CloudTile;diff --git a/src/components/modals/export-image-modal.js b/src/components/modals/export-image-modal.jsindex c9a1d95f1..00405fbf5 100644--- a/src/components/modals/export-image-modal.js+++ b/src/components/modals/export-image-modal.js@@ -21,11 +21,10 @@import React, {Component} from 'react';import PropTypes from 'prop-types';import styled from 'styled-components';+import ImagePreview from 'components/common/image-preview';-import {calculateExportImageSize} from 'utils/export-image-utils';import {EXPORT_IMG_RATIO_OPTIONS,- EXPORT_IMG_RATIOS,EXPORT_IMG_RESOLUTION_OPTIONS} from 'constants/default-settings';@@ -34,7 +33,6 @@ import {SelectionButton} from 'components/common/styled-components';import Switch from 'components/common/switch';-import LoadingSpinner from 'components/common/loading-spinner';const ImageOptionList = styled.div`display: flex;@@ -60,158 +58,88 @@ const ImageOptionList = styled.div`}`;-const PreviewImageSection = styled.div`- align-items: center;- display: flex;- flex-direction: column;- flex: 1;- justify-content: center;- padding: 30px;-- .dimension,- .instruction {- padding: 8px 0px;- }-- .preview-image {- background: #e2e2e2;- border-radius: 4px;- box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.18);- width: 100%;- padding-bottom: ${props =>- props.ratio === EXPORT_IMG_RATIOS.SCREEN- ? `${(100 * props.height) / props.width}%`- : props.ratio === EXPORT_IMG_RATIOS.SIXTEEN_BY_NINE- ? '56.25%'- : '75%'};- position: relative;- }-- .preview-image-placeholder {- position: absolute;- top: 0;- left: 0;- width: 100%;- height: 100%;- }-- .preview-image-spinner {- position: absolute;- left: calc(50% - 25px);- top: calc(50% - 25px);- }-- .preview-image--error {- font-size: 12px;- padding: 12px;- color: ${props => props.theme.errorColor};- text-align: center;- }-`;--class ExportImageModal extends Component {- static propTypes = {- height: PropTypes.number.isRequired,- ratio: PropTypes.string.isRequired,- resolution: PropTypes.string.isRequired,- width: PropTypes.number.isRequired,- exporting: PropTypes.bool.isRequired,- imageDataUri: PropTypes.string,- // callbacks- onChangeRatio: PropTypes.func.isRequired,- onChangeResolution: PropTypes.func.isRequired,- onToggleLegend: PropTypes.func.isRequired- };+const ExportImageModalFactory = () => {+ class ExportImageModal extends Component {+ static propTypes = {+ mapW: PropTypes.number.isRequired,+ mapH: PropTypes.number.isRequired,+ exportImage: PropTypes.object.isRequired,+ // callbacks+ onUpdateSetting: PropTypes.func.isRequired+ };++ componentDidMount() {+ this._updateMapDim();+ }- render() {- const {- height,- legend,- ratio,- error,- resolution,- width,- exporting,- imageDataUri,- // callbacks:- onChangeRatio,- onChangeResolution,- onToggleLegend- } = this.props;+ componentDidUpdate() {+ this._updateMapDim();+ }- const exportImageSize = calculateExportImageSize({- width,- height,- ratio,- resolution- });+ _updateMapDim() {+ const {exportImage, mapH, mapW} = this.props;+ if (mapH !== exportImage.mapH || mapW !== exportImage.mapW) {+ this.props.onUpdateSetting({mapH, mapW});+ }+ }- return (- <StyledModalContent className="export-image-modal">- <ImageOptionList>- <div className="image-option-section">- <div className="image-option-section-title">Ratio</div>- Choose the ratio for various usages.- <div className="button-list">- {EXPORT_IMG_RATIO_OPTIONS.map(op => (- <SelectionButton- key={op.id}- selected={ratio === op.id}- onClick={() => onChangeRatio({ratio: op.id})}- >- {op.label}- </SelectionButton>- ))}- </div>- </div>- <div className="image-option-section">- <div className="image-option-section-title">Resolution</div>- High resolution is better for prints.- <div className="button-list">- {EXPORT_IMG_RESOLUTION_OPTIONS.map(op => (- <SelectionButton- key={op.id}- selected={resolution === op.id}- onClick={() =>- op.available && onChangeResolution({resolution: op.id})- }- >- {op.label}- </SelectionButton>- ))}- </div>- </div>- <div className="image-option-section">- <div className="image-option-section-title">Map Legend</div>- <Switch- type="checkbox"- id="add-map-legend"- checked={legend}- label="Add legend on map"- onChange={onToggleLegend}- />- </div>- </ImageOptionList>- <PreviewImageSection ratio={ratio} width={width} height={height}>- <div className="dimension">{`${exportImageSize.width} x ${exportImageSize.height}`}</div>- <div className="preview-image">- {exporting ? (- <div className="preview-image-spinner">- <LoadingSpinner />+ render() {+ const {exportImage, onUpdateSetting} = this.props;+ const {legend, ratio, resolution} = exportImage;++ return (+ <StyledModalContent className="export-image-modal">+ <ImageOptionList>+ <div className="image-option-section">+ <div className="image-option-section-title">Ratio</div>+ Choose the ratio for various usages.+ <div className="button-list">+ {EXPORT_IMG_RATIO_OPTIONS.filter(op => !op.hidden).map(op => (+ <SelectionButton+ key={op.id}+ selected={ratio === op.id}+ onClick={() => onUpdateSetting({ratio: op.id})}+ >+ {op.label}+ </SelectionButton>+ ))}</div>- ) : error ? (- <div className="preview-image--error">- <span> {error.message || 'Generate map image failed!'}</span>+ </div>+ <div className="image-option-section">+ <div className="image-option-section-title">Resolution</div>+ High resolution is better for prints.+ <div className="button-list">+ {EXPORT_IMG_RESOLUTION_OPTIONS.map(op => (+ <SelectionButton+ key={op.id}+ selected={resolution === op.id}+ onClick={() =>+ op.available && onUpdateSetting({resolution: op.id})+ }+ >+ {op.label}+ </SelectionButton>+ ))}</div>- ) : (- <img className="preview-image-placeholder" src={imageDataUri} />- )}- </div>- </PreviewImageSection>- </StyledModalContent>- );+ </div>+ <div className="image-option-section">+ <div className="image-option-section-title">Map Legend</div>+ <Switch+ type="checkbox"+ id="add-map-legend"+ checked={legend}+ label="Add legend on map"+ onChange={() => onUpdateSetting({legend: !legend})}+ />+ </div>+ </ImageOptionList>+ <ImagePreview exportImage={exportImage} />+ </StyledModalContent>+ );+ }}-}-const ExportImageModalFactory = () => ExportImageModal;+ return ExportImageModal;+};+export default ExportImageModalFactory;diff --git a/src/components/modals/save-map-modal.js b/src/components/modals/save-map-modal.jsnew file mode 100644index 000000000..fd0b390a5--- /dev/null+++ b/src/components/modals/save-map-modal.js@@ -0,0 +1,222 @@+// 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 React, {Component} from 'react';+import PropTypes from 'prop-types';+import styled from 'styled-components';+import CloudTile from './cloud-tile';++import {+ MAP_THUMBNAIL_DIMENSION,+ MAP_INFO_CHARACTER,+ EXPORT_IMG_RATIOS+} from 'constants/default-settings';++import {+ StyledModalContent,+ InputLight,+ TextAreaLight,+ StyledExportSection,+ StyledModalSection,+ StyledModalInputFootnote+} from 'components/common/styled-components';+import ImagePreview from 'components/common/image-preview';++const StyledSaveMapModal = styled.div.attrs({+ className: 'save-map-modal'+})`+ .save-map-modal-content {+ min-height: 400px;+ flex-direction: column;+ }++ .description {+ width: 300px;+ }++ .image-preview-panel {+ width: 300px;++ .image-preview {+ padding: 0+ }+ }++ .map-info-panel {+ flex-direction: column;+ }++ .save-map-modal-description {+ .modal-section-subtitle {+ margin-left: 6px;+ }+ }+`;++function SaveMapModalFactory() {+ class SaveMapModal extends Component {+ static propTypes = {+ exportImage: PropTypes.object.isRequired,+ mapInfo: PropTypes.object.isRequired,+ onSetMapInfo: PropTypes.func.isRequired,+ onSetCloudProvider: PropTypes.func.isRequired,+ isLoading: PropTypes.bool.isRequired,+ thumbWidth: PropTypes.number,+ thumbHeight: PropTypes.number,+ characterLimits: PropTypes.object,+ cloudProviders: PropTypes.arrayOf(PropTypes.object),+ currentProvider: PropTypes.string+ };++ static defaultProps = {+ thumbWidth: MAP_THUMBNAIL_DIMENSION.width,+ thumbHeight: MAP_THUMBNAIL_DIMENSION.height,+ characterLimits: MAP_INFO_CHARACTER,+ cloudProviders: [],+ currentProvider: null,+ isLoading: false,+ mapInfo: {title: '', description: ''}+ };++ componentDidMount() {+ this.props.onUpdateSetting({+ mapW: this.props.thumbWidth,+ mapH: this.props.thumbHeight,+ ratio: EXPORT_IMG_RATIOS.CUSTOM+ });+ this._setDefaultProvider();+ }++ _setDefaultProvider() {+ if (!this.props.currentProvider && this.props.cloudProviders.length) {+ const connected = this.props.cloudProviders.find(+ p => typeof p.getAccessToken === 'function' && p.getAccessToken()+ );++ if (connected) {+ this.props.onSetCloudProvider(connected.name);+ }+ }+ }++ _onChangeInput = (key, e) => {+ const {+ target: {value}+ } = e;+ this.props.onSetMapInfo({[key]: value});+ };++ render() {+ const {+ mapInfo,+ exportImage,+ characterLimits = {},+ cloudProviders,+ isLoading,+ currentProvider,+ onSetCloudProvider+ } = this.props;++ return (+ <StyledSaveMapModal>+ <StyledModalContent className="save-map-modal-content">+ <StyledExportSection disabled={isLoading}>+ <div className="description">+ <div className="title">Cloud storage</div>+ <div className="subtitle">+ Login save map to your personal cloud storage+ </div>+ </div>+ <div className="selection">+ {cloudProviders.map(cloudProvider => (+ <CloudTile+ key={cloudProvider.name}+ onSelect={() => onSetCloudProvider(cloudProvider.name)}+ onSetCloudProvider={onSetCloudProvider}+ cloudProvider={cloudProvider}+ isSelected={cloudProvider.name === currentProvider}+ isConnected={Boolean(cloudProvider.getAccessToken())}+ />+ ))}+ </div>+ </StyledExportSection>+ <StyledExportSection>+ <div className="description image-preview-panel">+ <ImagePreview+ exportImage={exportImage}+ width={this.props.thumbWidth}+ showDimension={false}+ />+ </div>+ <div className="selection map-info-panel">+ <StyledModalSection className="save-map-modal-name">+ <div className="modal-section-title">Name*</div>+ <div>+ <InputLight+ id="map-title"+ type="text"+ value={mapInfo.title}+ onChange={e => this._onChangeInput('title', e)}+ placeholder="Type map title"+ />+ </div>+ </StyledModalSection>+ <StyledModalSection>+ <div+ className="save-map-modal-description"+ style={{display: 'flex'}}+ >+ <div className="modal-section-title">Description</div>+ <div className="modal-section-subtitle">(optional)</div>+ </div>+ <div>+ <TextAreaLight+ rows="3"+ id="map-description"+ style={{resize: 'none'}}+ value={mapInfo.description}+ onChange={e => this._onChangeInput('description', e)}+ placeholder="Type map description"+ />+ </div>+ <StyledModalInputFootnote+ className="save-map-modal-description__footnote"+ error={+ characterLimits.description &&+ mapInfo.description.length > characterLimits.description+ }+ >+ {mapInfo.description.length}/+ {characterLimits.description ||+ MAP_INFO_CHARACTER.description}{' '}+ characters+ </StyledModalInputFootnote>+ </StyledModalSection>+ </div>+ </StyledExportSection>+ </StyledModalContent>+ </StyledSaveMapModal>+ );+ }+ }+ return SaveMapModal;+}++export default SaveMapModalFactory;diff --git a/src/components/modals/share-map-modal.js b/src/components/modals/share-map-modal.jsnew file mode 100644index 000000000..96cb676ac--- /dev/null+++ b/src/components/modals/share-map-modal.js@@ -0,0 +1,220 @@+// 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 React, {useState, Component} from 'react';+import styled, {ThemeProvider} from 'styled-components';+import {CopyToClipboard} from 'react-copy-to-clipboard';+import {Button} from 'components/common/styled-components';+import {themeLT} from 'styles/base';++import {+ StyledModalContent,+ StyledExportSection,+ InputLight+} from 'components/common/styled-components';+import CloudTile from './cloud-tile';+import StatusPanel from './status-panel';+import {SHARE_DISCLAIMER} from 'constants/default-settings';++export const StyledInputLabel = styled.label`+ font-size: 12px;+ color: ${props => props.theme.textColorLT};+ letter-spacing: 0.2px;+`;++export const StyleSharingUrl = styled.div.attrs({+ className: 'sharing-url'+})`+ width: 100%;+ display: flex;+ margin-bottom: 14px;+ flex-direction: column;++ input {+ border-right: 0;+ }++ .button {+ border-top-left-radius: 0;+ border-bottom-left-radius: 0;+ }+`;++export const SharingUrl = ({url, message}) => {+ const [copied, setCopy] = useState(false);+ return (+ <StyleSharingUrl>+ <StyledInputLabel>{message}</StyledInputLabel>+ <div style={{display: 'flex'}}>+ <InputLight type="text" value={url} readOnly selected />+ <CopyToClipboard text={url} onCopy={() => setCopy(true)}>+ <Button width="80px">{copied ? 'Copied!' : 'Copy'}</Button>+ </CopyToClipboard>+ </div>+ </StyleSharingUrl>+ );+};+const nop = () => {};++export const MAP_URI = 'demo/map?mapUrl=';++/**+ * Returns a permalink with the given map url: kepler.gl/[]+ * @param mapLink the cloud-providers url used to store the map+ * @returns {string}+ */+export function getMapPermalink(mapLink, fullURL = true) {+ return fullURL+ ? `${window.location.protocol}//${window.location.host}/${MAP_URI}${mapLink}`+ : `/${MAP_URI}${mapLink}`;+}++const StyledShareMapModal = styled(StyledModalContent)`+ padding: 24px 72px 40px 72px;+ margin: 0 -72px -40px -72px;+`;++const StyledInnerDiv = styled.div`+ min-height: 500px;+`;++export default function ShareMapUrlModalFactory() {+ class ShareMapUrlModal extends Component {+ static defaultProps = {+ isLoading: false,+ onExport: nop,+ cloudProviders: [],+ currentProvider: null,+ error: null,+ successInfo: {},+ onSetCloudProvider: nop+ };++ componentDidMount() {+ this._setDefaultProvider();+ }++ _setDefaultProvider() {+ if (!this.props.currentProvider && this.props.cloudProviders.length) {+ const connected = this.props.cloudProviders.find(+ p => typeof p.getAccessToken === 'function' && p.getAccessToken()+ );++ if (connected) {+ this.props.onSetCloudProvider(connected.name);+ }+ }+ }++ render() {+ const {+ isLoading,+ onExport,+ cloudProviders,+ currentProvider,+ error,+ successInfo,+ onSetCloudProvider+ } = this.props;+ const {metaUrl, folderLink} = successInfo;+ const provider = currentProvider+ ? cloudProviders.find(p => p.name === currentProvider)+ : null;++ // TODO: A better way to obtain sharingLink+ const sharingLink = metaUrl+ ? provider && provider.getMapPermalink+ ? provider.getMapPermalink(metaUrl, true)+ : getMapPermalink(metaUrl, true)+ : null;++ return (+ <ThemeProvider theme={themeLT}>+ <StyledShareMapModal className="export-cloud-modal">+ <StyledInnerDiv>+ <StyledExportSection>+ <div className="description">+ <div className="title">Share Map Url</div>+ <div className="subtitle">+ Generate a map url to share with others+ </div>+ </div>+ <div className="selection">+ <div className="title warning">{SHARE_DISCLAIMER}</div>+ </div>+ </StyledExportSection>+ <StyledExportSection disabled={isLoading}>+ <div className="description">+ <div className="title">Cloud storage</div>+ <div className="subtitle">+ Login and upload map data to your personal cloud storage+ </div>+ </div>+ <div className="selection">+ {cloudProviders.map(cloudProvider => (+ <CloudTile+ key={cloudProvider.name}+ onSelect={() => onExport(cloudProvider)}+ onSetCloudProvider={onSetCloudProvider}+ cloudProvider={cloudProvider}+ actionName="Upload"+ isSelected={cloudProvider.name === currentProvider}+ isConnected={Boolean(cloudProvider.getAccessToken())}+ />+ ))}+ </div>+ </StyledExportSection>+ {isLoading || error ? (+ <StatusPanel+ isLoading={isLoading}+ error={error}+ providerIcon={provider && provider.icon}+ />+ ) : null}+ {sharingLink && (+ <StyledExportSection>+ <div className="description">+ <div className="title">Share Url</div>+ </div>+ <div className="selection">+ <SharingUrl key={0} url={sharingLink} />+ {folderLink && (+ <a+ key={1}+ href={folderLink}+ target="_blank"+ rel="noopener noreferrer"+ style={{textDecoration: 'underline'}}+ >+ Go to your Kepler.gl {currentProvider} page+ </a>+ )}+ </div>+ </StyledExportSection>+ )}+ </StyledInnerDiv>+ </StyledShareMapModal>+ </ThemeProvider>+ );+ }+ }++ return ShareMapUrlModal;+}diff --git a/src/components/modals/status-panel.js b/src/components/modals/status-panel.jsnew file mode 100644index 000000000..89c5a2ac5--- /dev/null+++ b/src/components/modals/status-panel.js@@ -0,0 +1,105 @@+// 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 React from 'react';+import styled from 'styled-components';+import {MapIcon} from 'components/common/icons';+import {StyledExportSection} from 'components/common/styled-components';+import NotificationItemFactory from 'components/notification-panel/notification-item';+import ErrorBoundary from 'components/common/error-boundary';++const NotificationItem = NotificationItemFactory();+const StyledUploader = styled.div`+ display: flex;+ align-items: center;+ justify-content: flex-start;+`;++const StyledMapIcon = styled.div`+ color: ${props => props.theme.textColorLT};+ margin-right: 16px;+ margin-top: 4px;+`;++const StyledSvg = styled.svg`+ margin-right: 16px;++ line {+ stroke: ${props => props.theme.selectBorderColorLT};+ stroke-width: 4;+ stroke-linecap: square;+ stroke-dasharray: 5 12;+ animation: dash-animation 25s infinite linear;+ }+ circle {+ fill: ${props => props.theme.selectBorderColorLT};+ }++ @keyframes dash-animation {+ to {+ stroke-dashoffset: -1000;+ }+ }+`;++const Line = () => (+ <StyledSvg height="5px" width="150px">+ <line x1="0" y1="4" x2="150" y2="4" />+ </StyledSvg>+);++const ErrorDisplay = ({error}) => (+ <ErrorBoundary>+ <NotificationItem+ notification={{+ type: 'error',+ message: error,+ id: 'cloud-export-error'+ }}+ isExpanded+ />+ </ErrorBoundary>+);++const UploadAnimation = props => (+ <StyledUploader>+ <StyledMapIcon>+ <MapIcon height="48px" />+ </StyledMapIcon>+ <Line />+ {props.icon && <props.icon height="64px" />}+ </StyledUploader>+);++const StatusPanel = ({error, isLoading, providerIcon}) => (+ <StyledExportSection>+ <div className="description">+ <div className="title">+ {isLoading ? 'Map Uploading' : error ? 'Error' : null}+ </div>+ </div>+ <div className="selection">+ {isLoading && <UploadAnimation icon={providerIcon} />}+ {error && <ErrorDisplay error={error} />}+ </div>+ </StyledExportSection>+);++export default StatusPanel;diff --git a/src/components/notification-panel/notification-item.js b/src/components/notification-panel/notification-item.jsindex 9370ffb38..2b0446233 100644--- a/src/components/notification-panel/notification-item.js+++ b/src/components/notification-panel/notification-item.js@@ -46,7 +46,9 @@ const DeleteIcon = styled(Delete)`cursor: pointer;`;-const NotificationMessage = styled.div`+const NotificationMessage = styled.div.attrs({+ className: 'notification-item--message'+})`flex-grow: 2;width: ${props => props.theme.notificationPanelItemWidth}px;margin: 0 1em;@@ -90,14 +92,18 @@ export default function NotificationItemFactory() {id: PropTypes.string.isRequired,type: PropTypes.string.isRequired,message: PropTypes.string.isRequired- }).isRequired+ }).isRequired,+ isExpanded: PropTypes.bool};- constructor(props) {- super(props);- this.state = {- isExpanded: false- };+ state = {+ isExpanded: false+ };++ componentDidMount() {+ if (this.props.isExpanded) {+ this.setState({isExpanded: true});+ }}render() {@@ -115,7 +121,6 @@ export default function NotificationItemFactory() {{icons[notification.type]}</NotificationIcon><NotificationMessage- className="notification-item--message"isExpanded={isExpanded}theme={this.props.theme}>@@ -124,12 +129,12 @@ export default function NotificationItemFactory() {renderers={{link: LinkRenderer}}/></NotificationMessage>- <div className="notification-item--action">+ {typeof removeNotification === 'function' ? <div className="notification-item--action"><DeleteIconheight="10px"onClick={() => removeNotification(notification.id)}/>- </div>+ </div> : null}</NotificationItemContent>);}diff --git a/src/components/plot-container.js b/src/components/plot-container.jsindex 239a5a86a..2722b8871 100644--- a/src/components/plot-container.js+++ b/src/components/plot-container.js@@ -27,8 +27,9 @@ import {StaticMap} from 'react-map-gl';import debounce from 'lodash.debounce';import {exportImageError} from 'utils/notifications-utils';import MapContainerFactory from './map-container';-import {calculateExportImageSize, convertToPng} from 'utils/export-image-utils';+import {convertToPng} from 'utils/export-utils';import {scaleMapStyleByResolution} from 'utils/map-style-utils/mapbox-gl-style-editor';+import {getScaleFromImageSize} from 'utils/export-utils';const propTypes = {width: PropTypes.number.isRequired,@@ -46,7 +47,7 @@ const StyledPlotContainer = styled.div`.mapboxgl-ctrl-bottom-right {display: none;}-+position: absolute;`;@@ -84,17 +85,32 @@ export default function PlotContainerFactory(MapContainer) {plottingAreaRef = createRef();mapStyleSelector = props => props.mapFields.mapStyle;- resolutionSelector = props => props.exportImageSetting.resolution;+ mapScaleSelector = props => {+ const {imageSize} = props.exportImageSetting;+ const {mapState} = props.mapFields;+ if (imageSize.scale) {+ return imageSize.scale;+ }+ const scale = getScaleFromImageSize(+ imageSize.imageW,+ imageSize.imageH,+ mapState.width,+ mapState.height+ );++ return scale > 0 ? scale : 1;+ }+scaledMapStyleSelector = createSelector(this.mapStyleSelector,- this.resolutionSelector,- (mapStyle, resolution) => ({+ this.mapScaleSelector,+ (mapStyle, scale) => ({...mapStyle,bottomMapStyle: scaleMapStyleByResolution(mapStyle.bottomMapStyle,- resolution+ scale),- topMapStyle: scaleMapStyleByResolution(mapStyle.topMapStyle, resolution)+ topMapStyle: scaleMapStyleByResolution(mapStyle.topMapStyle, scale)}));@@ -109,26 +125,23 @@ export default function PlotContainerFactory(MapContainer) {this.props.startExportingImage();const filter = node => node.className !== 'mapboxgl-control-container';- convertToPng(this.plottingAreaRef.current, {filter}).then(dataUri => {- this.props.setExportImageDataUri(dataUri);- })- .catch(err => {- this.props.setExportImageError(err);- this.props.addNotification(exportImageError({err}));- });+ convertToPng(this.plottingAreaRef.current, {filter})+ .then(this.props.setExportImageDataUri)+ .catch(err => {+ this.props.setExportImageError(err);+ this.props.addNotification(exportImageError({err}));+ });}};render() {- const {width, height, exportImageSetting, mapFields} = this.props;- const {ratio, resolution, legend} = exportImageSetting;- const exportImageSize = calculateExportImageSize({- width,- height,- ratio,- resolution- });-+ const {exportImageSetting, mapFields} = this.props;+ const {imageSize = {}, legend} = exportImageSetting;+ const size = {+ width: imageSize.imageW || 1,+ height: imageSize.imageH || 1+ };+ const scale = this.mapScaleSelector(this.props);const mapProps = {...mapFields,mapStyle: this.scaledMapStyleSelector(this.props),@@ -136,8 +149,8 @@ export default function PlotContainerFactory(MapContainer) {// override viewport based on export settingsmapState: {...mapFields.mapState,- ...exportImageSize,- zoom: mapFields.mapState.zoom + exportImageSize.zoomOffset+ ...size,+ zoom: mapFields.mapState.zoom + (Math.log2(scale) || 0)},mapControls: {// override map legend visibility@@ -157,8 +170,8 @@ export default function PlotContainerFactory(MapContainer) {<divref={this.plottingAreaRef}style={{- width: exportImageSize.width,- height: exportImageSize.height+ width: `${size.width}px` ,+ height: `${size.height}px`}}><MapContainerdiff --git a/src/components/side-panel.js b/src/components/side-panel.jsindex 10e8f72b4..4d434d18d 100644--- a/src/components/side-panel.js+++ b/src/components/side-panel.js@@ -37,6 +37,8 @@ import {EXPORT_IMAGE_ID,EXPORT_DATA_ID,EXPORT_MAP_ID,+ SAVE_MAP_ID,+ SHARE_MAP_ID,PANELS} from 'constants/default-settings';@@ -92,7 +94,8 @@ export default function SidePanelFactory(width: PropTypes.number.isRequired,datasets: PropTypes.object.isRequired,visStateActions: PropTypes.object.isRequired,- mapStyleActions: PropTypes.object.isRequired+ mapStyleActions: PropTypes.object.isRequired,+ availableProviders: PropTypes.object};/* component private functions */_onOpenOrClose = () => {@@ -120,11 +123,15 @@ export default function SidePanelFactory(this.props.uiStateActions.openDeleteModal(key);};- _onExportImage = () => this.props.uiStateActions.toggleModal(EXPORT_IMAGE_ID);+ _onClickExportImage = () => this.props.uiStateActions.toggleModal(EXPORT_IMAGE_ID);- _onExportData = () => this.props.uiStateActions.toggleModal(EXPORT_DATA_ID);+ _onClickExportData = () => this.props.uiStateActions.toggleModal(EXPORT_DATA_ID);- _onExportMap = () => this.props.uiStateActions.toggleModal(EXPORT_MAP_ID);+ _onClickExportMap = () => this.props.uiStateActions.toggleModal(EXPORT_MAP_ID);++ _onClickSaveToStorage = () => this.props.uiStateActions.toggleModal(SAVE_MAP_ID);++ _onClickShareMap = () => this.props.uiStateActions.toggleModal(SHARE_MAP_ID);render() {const {@@ -140,7 +147,8 @@ export default function SidePanelFactory(interactionConfig,visStateActions,mapStyleActions,- uiStateActions+ uiStateActions,+ availableProviders = {}} = this.props;const {activeSidePanel} = uiState;@@ -199,13 +207,15 @@ export default function SidePanelFactory(<PanelHeaderappName={appName}version={version}- onExportImage={this._onExportImage}- onExportData={this._onExportData}visibleDropdown={uiState.visibleDropdown}showExportDropdown={uiStateActions.showExportDropdown}hideExportDropdown={uiStateActions.hideExportDropdown}- onExportMap={this._onExportMap}+ onExportImage={this._onClickExportImage}+ onExportData={this._onClickExportData}+ onExportMap={this._onClickExportMap}onSaveMap={this.props.onSaveMap}+ onSaveToStorage={availableProviders.hasStorage ? this._onClickSaveToStorage : null}+ onShareMap={availableProviders.hasShare ? this._onClickShareMap : null}/><PanelTogglepanels={PANELS}diff --git a/examples/demo-app/src/components/sharing/export-url-modal.js b/src/components/side-panel/cloud-storage-dropdown.jssimilarity index 65%rename from examples/demo-app/src/components/sharing/export-url-modal.jsrename to src/components/side-panel/cloud-storage-dropdown.jsindex f27632baa..1ab3dabe6 100644--- a/examples/demo-app/src/components/sharing/export-url-modal.js+++ b/src/components/side-panel/cloud-storage-dropdown.js@@ -19,30 +19,34 @@// THE SOFTWARE.import React from 'react';-import {Modal} from 'kepler.gl/components';-import CloudStorage from './cloud-storage';+import {PanelHeaderDropdownFactory, Icons} from 'kepler.gl/components';-const ExportUrlModal = ({- sharing,- isOpen,- onClose,- onExport,- onCloudLoginSuccess,- parentSelector-}) => (- <Modal- isOpen={isOpen}- close={onClose}- title={'Save / Share your map'}- parentSelector={parentSelector}- >- <CloudStorage- isLoading={sharing.isLoading}- info={sharing.info}- onExport={onExport}- onCloudLoginSuccess={onCloudLoginSuccess}+const CloudStorageItems = [+ {+ label: 'Save',+ icon: Icons.Save2,+ key: 'data',+ onClick: props => props.onSaveMap+ },+ {+ label: 'Settings',+ icon: Icons.Gear,+ key: 'settings',+ onClick: props => props.onExportData+ }+];++const PanelHeaderDropdown = PanelHeaderDropdownFactory();++const CloudStorageDropdown = ({show, onClose}) => {+ return (+ <PanelHeaderDropdown+ items={CloudStorageItems}+ show={show}+ onClose={onClose}+ id="cloud-storage"/>- </Modal>-);+ );+};-export default ExportUrlModal;+export default CloudStorageDropdown;diff --git a/src/components/side-panel/layer-panel/layer-column-config.js b/src/components/side-panel/layer-panel/layer-column-config.jsindex c11895160..4d365b9c5 100644--- a/src/components/side-panel/layer-panel/layer-column-config.js+++ b/src/components/side-panel/layer-panel/layer-column-config.js@@ -86,7 +86,7 @@ export default class LayerColumnConfig extends Component {<div className="layer-config__column"><TopRow><PanelLabel>Columns</PanelLabel>- <PanelLabel>* Required</PanelLabel>+ <PanelLabel>Required*</PanelLabel></TopRow>{Object.keys(columns).map(key => (<ColumnSelectordiff --git a/src/components/side-panel/panel-header.js b/src/components/side-panel/panel-header.jsindex 7dc7c16a2..333df7ac2 100644--- a/src/components/side-panel/panel-header.js+++ b/src/components/side-panel/panel-header.js@@ -21,9 +21,19 @@import React, {Component} from 'react';import styled from 'styled-components';import PropTypes from 'prop-types';+import {createSelector} from 'reselect';import {Tooltip} from 'components/common/styled-components';import KeplerGlLogo from 'components/common/logo';-import {Save, Files, Share, Picture, Map} from 'components/common/icons';+import {+ Save,+ DataTable,+ Save2,+ Gear,+ Picture,+ Db,+ Map as MapIcon,+ Share+} from 'components/common/icons';import ClickOutsideCloseDropdown from 'components/side-panel/panel-dropdown';import Toolbar from 'components/common/toolbar';import ToolbarItem from 'components/common/toolbar-item';@@ -45,13 +55,13 @@ const StyledPanelHeaderTop = styled.div.attrs({`;const StyledPanelTopActions = styled.div.attrs({- className: 'side-panel__header__actions'+ className: 'side-panel__top__actions'})`display: flex;`;const StyledPanelAction = styled.div.attrs({- className: 'side-panel__header__actions'+ className: 'side-panel__panel-header__action'})`align-items: center;border-radius: 2px;@@ -89,156 +99,190 @@ const StyledToolbar = styled(Toolbar)``;export const PanelAction = ({item, onClick}) => (- <StyledPanelAction className="side-panel__panel-header__action"- data-tip data-for={`${item.id}-action`} onClick={onClick}>+ <StyledPanelAction+ className="side-panel__panel-header__action"+ data-tip+ data-for={`${item.id}-action`}+ onClick={onClick}+ >{item.label ? <p>{item.label}</p> : null}<a target={item.blank ? '_blank' : ''} href={item.href}><item.iconComponent height="20px" /></a>- {item.tooltip ? (<Tooltip- id={`${item.id}-action`}- place="bottom"- delayShow={500}- effect="solid"- >- <span>{item.tooltip}</span>- </Tooltip>) : null }+ {item.tooltip ? (+ <Tooltip+ id={`${item.id}-action`}+ place="bottom"+ delayShow={500}+ effect="solid"+ >+ <span>{item.tooltip}</span>+ </Tooltip>+ ) : null}</StyledPanelAction>);-export const ExportImageFactory = () => {- const ExportImage = props => (<ToolbarItem {...props}/>);- ExportImage.defaultProps = {- label: 'Export Image',- icon: <Picture />+export const PanelHeaderDropdownFactory = () => {+ const PanelHeaderDropdown = ({items, show, onClose, id}) => {+ return (+ <StyledToolbar show={show} className={`${id}-dropdown`}>+ <ClickOutsideCloseDropdown+ className="panel-header-dropdown__inner"+ show={show}+ onClose={onClose}+ >+ {items.map(itm => (+ <ToolbarItem+ key={itm.key}+ label={itm.label}+ icon={itm.icon}+ onClick={itm.onClick}+ onClose={onClose}+ />+ ))}+ </ClickOutsideCloseDropdown>+ </StyledToolbar>+ );};- return ExportImage;+ return PanelHeaderDropdown;};-export const ExportDataFactory = () => {- const ExportData = props => (<ToolbarItem {...props}/>);- ExportData.defaultProps = {- label: 'Export Data',- icon: <Files />- };+const getDropdownItemsSelector = () =>+ createSelector(+ props => props,+ props =>+ props.items+ .map(t => ({+ ...t,+ onClick: t.onClick && t.onClick(props) ? t.onClick(props) : null+ }))+ .filter(l => l.onClick)+ );- return ExportData;-};+export const SaveExportDropdownFactory = PanelHeaderDropdown => {+ const dropdownItemsSelector = getDropdownItemsSelector();-export const ExportMapFactory = () => {- const ExportMap = props => (<ToolbarItem {...props}/>);- ExportMap.defaultProps = {- label: 'Export Map',- icon: <Map />- };+ const SaveExportDropdown = props => (- return ExportMap;-};+ <PanelHeaderDropdown+ items={dropdownItemsSelector(props)}+ show={props.show}+ onClose={props.onClose}+ id="save-export"+ />+ );-export const SaveMapFactory = () => {- const SaveMap = props => (<ToolbarItem {...props}/>);- SaveMap.defaultProps = {- label: 'Save Map',- icon: <Share />+ SaveExportDropdown.defaultProps = {+ items: [+ {+ label: 'Export Image',+ icon: Picture,+ key: 'image',+ onClick: props => props.onExportImage+ },+ {+ label: 'Export Data',+ icon: DataTable,+ key: 'data',+ onClick: props => props.onExportData+ },+ {+ label: 'Export Map',+ icon: MapIcon,+ key: 'map',+ onClick: props => props.onExportMap+ },+ {+ label: 'Save Map',+ icon: Save2,+ key: 'save',+ onClick: props => props.onSaveMap+ },+ {+ label: 'Share Map URL',+ icon: Share,+ key: 'save',+ onClick: props => props.onShareMap+ }+ ]};- return SaveMap;+ return SaveExportDropdown;};+SaveExportDropdownFactory.deps = [PanelHeaderDropdownFactory];-SaveExportDropdownFactory.deps = [- ExportImageFactory,- ExportDataFactory,- ExportMapFactory,- SaveMapFactory-];--export function SaveExportDropdownFactory(- ExportImage,- ExportData,- ExportMap,- SaveMap) {+export const CloudStorageDropdownFactory = PanelHeaderDropdown => {+ const dropdownItemsSelector = getDropdownItemsSelector();- const SaveExportDropdown = ({- onExportImage,- onExportData,- onExportConfig,- onExportMap,- onSaveMap,- show,- onClose- }) => {- return (- <StyledToolbar show={show} onClose={onClose} className="save-export-dropdown">- <ClickOutsideCloseDropdown- className="save-export-dropdown__inner"- show={show}- onClose={onClose}>- <ExportImage- className="export-image"- onClick={() => {- onExportImage();- onClose();- }}- />- <ExportData- className="export-data"- onClick={() => {- onExportData();- onClose();- }}- />- <ExportMap- className="export-map"- onClick={() => {- onExportMap();- onClose();- }}- />- {onSaveMap ? (- <SaveMap- className="save-map"- onClick={() => {- onSaveMap();- onClose();- }}- />- ) : null}- </ClickOutsideCloseDropdown>- </StyledToolbar>-- );+ const CloudStorageDropdown = (props) => (+ <PanelHeaderDropdown+ items={dropdownItemsSelector(props)}+ show={props.show}+ onClose={props.onClose}+ id="cloud-storage"+ />+ );+ CloudStorageDropdown.defaultProps = {+ items: [+ {+ label: 'Save',+ icon: Save2,+ key: 'data',+ onClick: props => props.onSaveToStorage+ },+ {+ label: 'Settings',+ icon: Gear,+ key: 'settings',+ onClick: props => props.onExportData+ }+ ]};-- return SaveExportDropdown;-}+ return CloudStorageDropdown;+};+CloudStorageDropdownFactory.deps = [PanelHeaderDropdownFactory];PanelHeaderFactory.deps = [- SaveExportDropdownFactory+ SaveExportDropdownFactory,+ CloudStorageDropdownFactory];-function PanelHeaderFactory(- SaveExportDropdown-) {+function PanelHeaderFactory(SaveExportDropdown, CloudStorageDropdown) {return class PanelHeader extends Component {static propTypes = {appName: PropTypes.string,version: PropTypes.string,- uiState: PropTypes.object,- uiStateActions: PropTypes.object,+ visibleDropdown: PropTypes.string,logoComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),- actionItems: PropTypes.arrayOf(PropTypes.any)+ actionItems: PropTypes.arrayOf(PropTypes.any),+ onExportImage: PropTypes.func,+ onExportData: PropTypes.func,+ onExportConfig: PropTypes.func,+ onExportMap: PropTypes.func,+ onSaveToStorage: PropTypes.func,+ onSaveMap: PropTypes.func,+ onShareMap: PropTypes.func};static defaultProps = {logoComponent: KeplerGlLogo,- actionItems: [{- id: 'save',- iconComponent: Save,- onClick: () => {},- label: 'Share',- dropdownComponent: SaveExportDropdown- }]+ actionItems: [+ {+ id: 'storage',+ iconComponent: Db,+ tooltip: 'Cloud Storage',+ onClick: () => {},+ dropdownComponent: CloudStorageDropdown+ },+ {+ id: 'save',+ iconComponent: Save,+ onClick: () => {},+ label: 'Share',+ dropdownComponent: SaveExportDropdown+ }+ ]};render() {@@ -246,7 +290,9 @@ function PanelHeaderFactory(appName,version,actionItems,+ onSaveToStorage,onSaveMap,+ onShareMap,onExportImage,onExportData,onExportConfig,@@ -255,15 +301,24 @@ function PanelHeaderFactory(showExportDropdown,hideExportDropdown} = this.props;+ let items = actionItems || [];++ // don't render cloud storage icon if onSaveToStorage is not provided+ if (typeof onSaveToStorage !== 'function') {+ items = actionItems.filter(ai => ai.id !== 'storage')+ }return (<StyledPanelHeader className="side-panel__panel-header"><StyledPanelHeaderTop className="side-panel__panel-header__top">- <this.props.logoComponent appName={appName} version={version}/>+ <this.props.logoComponent appName={appName} version={version} /><StyledPanelTopActions>- {actionItems.map(item => (- <div className="side-panel__panel-header__right"- key={item.id} style={{position: 'relative'}}>+ {items.map(item => (+ <div+ className="side-panel__panel-header__right"+ key={item.id}+ style={{position: 'relative'}}+ ><PanelActionitem={item}onClick={() => {@@ -277,7 +332,9 @@ function PanelHeaderFactory(<item.dropdownComponentonClose={hideExportDropdown}show={visibleDropdown === item.id}+ onSaveToStorage={onSaveToStorage}onSaveMap={onSaveMap}+ onShareMap={onShareMap}onExportData={onExportData}onExportImage={onExportImage}onExportConfig={onExportConfig}@@ -291,7 +348,7 @@ function PanelHeaderFactory(</StyledPanelHeader>);}- }+ };}export default PanelHeaderFactory;diff --git a/src/constants/action-types.js b/src/constants/action-types.jsindex f52f4f057..dce056ce6 100644--- a/src/constants/action-types.js+++ b/src/constants/action-types.js@@ -96,6 +96,7 @@ const ActionTypes = keyMirror({LAYER_COLOR_UI_CHANGE: null,TOGGLE_FEATURE_LAYER: null,APPLY_CPU_FILTER: null,+ SET_MAP_INFO: null,// mapStateUPDATE_MAP: null,@@ -127,9 +128,7 @@ const ActionTypes = keyMirror({REMOVE_NOTIFICATION: null,// uiState > export image- SET_RATIO: null,- SET_RESOLUTION: null,- TOGGLE_LEGEND: null,+ SET_EXPORT_IMAGE_SETTING: null,START_EXPORTING_IMAGE: null,SET_EXPORT_IMAGE_DATA_URI: null,SET_EXPORT_IMAGE_ERROR: null,@@ -163,7 +162,7 @@ const ActionTypes = keyMirror({TOGGLE_EDITOR_VISIBILITY: null});-const addPrefix = actions =>+export const addPrefix = actions =>Object.keys(actions).reduce((accu, key) => ({...accu,diff --git a/src/constants/default-settings.js b/src/constants/default-settings.jsindex 19a70a898..2a30007ce 100644--- a/src/constants/default-settings.js+++ b/src/constants/default-settings.js@@ -86,6 +86,20 @@ export const ADD_MAP_STYLE_ID = 'addMapStyle';* @public*/export const EXPORT_MAP_ID = 'exportMap';+/**+ * Modal id: save map modal+ * @constant+ * @type {string}+ * @public+ */+export const SAVE_MAP_ID = 'saveMap';+/**+ * Modal id: share map url modal+ * @constant+ * @type {string}+ * @public+ */+export const SHARE_MAP_ID = 'shareMap';import {Layers,@@ -575,7 +589,8 @@ export const RESOLUTIONS = keyMirror({export const EXPORT_IMG_RATIOS = keyMirror({SCREEN: null,FOUR_BY_THREE: null,- SIXTEEN_BY_NINE: null+ SIXTEEN_BY_NINE: null,+ CUSTOM: null});export const EXPORT_IMG_RATIO_OPTIONS = [@@ -584,6 +599,12 @@ export const EXPORT_IMG_RATIO_OPTIONS = [label: 'Original Screen',getSize: (screenW, screenH) => ({width: screenW, height: screenH})},+ {+ id: EXPORT_IMG_RATIOS.CUSTOM,+ hidden: true,+ label: 'Custom',+ getSize: (mapW, mapH) => ({width: mapW, height: mapH})+ },{id: EXPORT_IMG_RATIOS.FOUR_BY_THREE,label: '4:3',@@ -608,7 +629,6 @@ export const EXPORT_IMG_RESOLUTION_OPTIONS = [label: '1x',available: true,scale: 1,- zoomOffset: Math.log2(1),getSize: (screenW, screenH) => ({width: screenW,height: screenH@@ -619,7 +639,6 @@ export const EXPORT_IMG_RESOLUTION_OPTIONS = [label: '2x',available: true,scale: 2,- zoomOffset: Math.log2(2),getSize: (screenW, screenH) => ({width: screenW * 2,height: screenH * 2@@ -627,8 +646,6 @@ export const EXPORT_IMG_RESOLUTION_OPTIONS = [}];-export const DEFAULT_EXPORT_IMAGE_NAME = 'kepler-gl.png';-export const EXPORT_DATA_TYPE = keyMirror({CSV: null// SHAPEFILE: null,@@ -711,7 +728,8 @@ export const DEFAULT_NOTIFICATION_TOPICS = keyMirror({export const TOKEN_MISUSE_WARNING = '* If you do not provide your own token, the map may fail to display at any time when we replace ours to avoid misuse. ';export const DISCLAIMER = 'You can change the Mapbox token later using the following instructions: ';export const MAP_CONFIG_DESCRIPTION = 'Map config will be included in the Json file. If you are using kepler.gl in your own app. You can copy this config and pass it to ';-+export const SHARE_DISCLAIMER = 'kepler.gl will save your map data to your personal cloud storage, only people with the URL can access your map and data. ' ++ 'You can edit/delete the data file in your cloud account anytime.';// Animationexport const BASE_SPEED = 600;export const DEFAULT_TIME_FORMAT = 'MM/DD/YY HH:mm:ssa';@@ -738,3 +756,12 @@ export const EDITOR_AVAILABLE_LAYERS = [* Max number of filter value buffers that deck.gl provides*/export const MAX_GPU_FILTERS = 4;+export const MAP_THUMBNAIL_DIMENSION = {+ width: 300,+ height: 200+};++export const MAP_INFO_CHARACTER = {+ title: 100,+ description: 100+};diff --git a/src/reducers/core.js b/src/reducers/core.jsindex 5d417ef0f..1e4c177d4 100644--- a/src/reducers/core.js+++ b/src/reducers/core.js@@ -24,6 +24,7 @@ import {visStateReducerFactory} from './vis-state';import {mapStateReducerFactory} from './map-state';import {mapStyleReducerFactory} from './map-style';import {uiStateReducerFactory} from './ui-state';+import {providerStateReducerFactory} from './provider-state';import composers from './composers';@@ -32,7 +33,8 @@ const combined = (initialState = {}) =>visState: visStateReducerFactory(initialState.visState),mapState: mapStateReducerFactory(initialState.mapState),mapStyle: mapStyleReducerFactory(initialState.mapStyle),- uiState: uiStateReducerFactory(initialState.uiState)+ uiState: uiStateReducerFactory(initialState.uiState),+ providerState: providerStateReducerFactory(initialState.providerState)});export const coreReducerFactory = (initialState = {}) => (state, action) => {@@ -79,3 +81,12 @@ export const visStateLens = reduxState => ({visState: reduxState.visState});* @public*/export const uiStateLens = reduxState => ({uiState: reduxState.uiState});++/**+ * Connect subreducer `providerState`, used with `injectComponents`. Learn more at+ * [Replace UI Component](../advanced-usages/replace-ui-component.md#pass-custom-component-props)+ *+ * @param {*} reduxState+ * @public+ */+export const providerStateLens = reduxState => ({providerState: reduxState.providerState});diff --git a/src/reducers/provider-state-updaters.js b/src/reducers/provider-state-updaters.jsnew file mode 100644index 000000000..8c2da5987--- /dev/null+++ b/src/reducers/provider-state-updaters.js@@ -0,0 +1,209 @@+// 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 {withTask} from 'react-palm/tasks';+import {default as Console} from 'global/console';+import window from 'global/window';++import {generateHashId, getError} from 'utils/utils';+import {EXPORT_FILE_TO_CLOUD_TASK, ACTION_TASK, DELAY_TASK} from 'tasks/tasks';+import {exportFileSuccess, exportFileError, saveToCloudSuccess} from 'actions/provider-actions';+import {+ removeNotification,+ toggleModal,+ addNotification+} from 'actions/ui-state-actions';+import {+ DEFAULT_NOTIFICATION_TYPES,+ DEFAULT_NOTIFICATION_TOPICS+} from 'constants/default-settings';++export const INITIAL_PROVIDER_STATE = {+ isLoading: false,+ error: null,+ currentProvider: null,+ successInfo: {}+};++function createFileJson(mapData = {}) {+ if (!window.Blob || !window.File) {+ return {file: null, fileName: null};+ }+ const {map = {}, info = {}} = mapData;+ const data = JSON.stringify(map);+ const newBlob = new window.Blob([data], {type: 'application/json'});++ // TODO: Allow user import file name+ const name =+ info.title && info.title.length+ ? info.title+ : `keplergl_${generateHashId(6)}`;+ const fileName = `${name}.json`;++ return {file: new window.File([newBlob], fileName), fileName};+}++function createActionTask(action, payload) {+ if (typeof action === 'function') {+ return ACTION_TASK().map(_ => action(payload));+ }++ return null;+}++/**+ * This method will export the current kepler config file to the chosen cloud proder+ * add returns a share URL+ *+ * @param {*} state+ * @param {*} action+ */+export const exportFileToCloudUpdater = (state, action) => {+ const {mapData, provider, isPublic, onSuccess, onError, closeModal} = action.payload;++ if (!provider) {+ Console.error(`provider is not defined`);+ return state;+ }++ if (typeof provider.uploadFile !== 'function') {+ Console.error(+ `uploadFile is not a function of Cloud provider: ${provider.name}`+ );+ return state;+ }++ // TODO: do we need to always create a fileBlob?+ // if this is provider specific, we should just send over the json+ // and let provider decide what format to use+ const {file, fileName} = createFileJson(mapData);++ const newState = {+ ...state,+ isLoading: true,+ currentProvider: provider.name+ };++ // payload called by provider.uploadFile+ const payload = {+ mapData,+ blob: file,+ fileName,+ isPublic+ };+ const uploadFileTask = EXPORT_FILE_TO_CLOUD_TASK({provider, payload}).bimap(+ // success+ response => exportFileSuccess({response, provider, onSuccess, closeModal}),+ // error+ error => exportFileError({error, provider, onError})+ );++ return withTask(newState, uploadFileTask);+};++/**+ *+ * @param {*} state+ * @param {*} action+ */+export const exportFileSuccessUpdater = (state, action) => {+ const {response, provider, onSuccess, closeModal} = action.payload;++ const newState = {+ ...state,+ isLoading: false,+ // TODO: do we always have to store this?+ successInfo: {+ metaUrl: response.url,+ folderLink: response.folder_link+ }+ };++ const tasks = [+ createActionTask(onSuccess, {response, provider}),+ closeModal && ACTION_TASK().map(_ => saveToCloudSuccess())+ ].filter(d => d);++ return tasks.length ? withTask(newState, tasks) : newState;+};++/**+ * Close modal on success and display notification+ * @param {*} state+ * @param {*} action+ */+export const saveToCloudSuccessUpdater = (state, action) => {+ const id = generateHashId();+ const successNote = {+ id,+ type: DEFAULT_NOTIFICATION_TYPES.success,+ topic: DEFAULT_NOTIFICATION_TOPICS.global,+ message: `Saved to ${state.currentProvider} successfully`+ };++ const tasks = [+ ACTION_TASK().map(_ => toggleModal(null)),+ ACTION_TASK().map(_ => addNotification(successNote)),+ DELAY_TASK(3000).map(_ => removeNotification(id))+ ];++ return withTask(state, tasks);+};++/**+ *+ * @param {*} state+ * @param {*} action+ */+export const exportFileErrorUpdater = (state, action) => {+ const {error, provider, onError} = action.payload;++ const newState = {+ ...state,+ isLoading: false,+ error: getError(error)+ };++ const task = createActionTask(onError, {error, provider});++ return task ? withTask(newState, task) : newState;+};++/**+ *+ * @param {*} state+ * @param {*} action+ */+export const resetProviderStatusUpdater = (state, action) => ({+ ...state,+ isLoading: false,+ error: null,+ successInfo: {}+});++/**+ * Set current cloudProvider+ * @param {*} state+ * @param {*} action+ */+export const setCloudProviderUpdater = (state, action) => ({+ ...state,+ currentProvider: action.payload+});diff --git a/examples/demo-app/src/reducers/sharing.js b/src/reducers/provider-state.jssimilarity index 52%rename from examples/demo-app/src/reducers/sharing.jsrename to src/reducers/provider-state.jsindex 9ef86f64b..1da66d0f9 100644--- a/examples/demo-app/src/reducers/sharing.js+++ b/src/reducers/provider-state.js@@ -19,39 +19,28 @@// THE SOFTWARE.import {handleActions} from 'redux-actions';-import {getCloudProviders} from '../cloud-providers';-import {CLOUD_LOGIN_SUCCESS, LOAD_REMOTE_RESOURCE_ERROR, PUSHING_FILE} from '../actions';+import * as providerStateUpdaters from './provider-state-updaters';+import {ActionTypes} from 'actions/provider-actions';-const readAuthTokens = () => getCloudProviders()- .reduce((tokens, cloudProvider) => ({- ...tokens,- [cloudProvider.name]: cloudProvider.getAccessToken()- }), {});+/**+ * Important: Do not rename `actionHandler` or the assignment pattern of property value.+ * It is used to generate documentation+ */+const actionHandler = {+ [ActionTypes.EXPORT_FILE_TO_CLOUD]: providerStateUpdaters.exportFileToCloudUpdater,+ [ActionTypes.EXPORT_FILE_SUCCESS]: providerStateUpdaters.exportFileSuccessUpdater,+ [ActionTypes.EXPORT_FILE_ERROR]: providerStateUpdaters.exportFileErrorUpdater,+ [ActionTypes.RESET_PROVIDER_STATUS]: providerStateUpdaters.resetProviderStatusUpdater,+ [ActionTypes.SET_CLOUD_PROVIDER]: providerStateUpdaters.setCloudProviderUpdater,+ [ActionTypes.SAVE_TO_CLOUD_SUCCESS]: providerStateUpdaters.saveToCloudSuccessUpdater+}-const sharingInitialState = {- isLoading: false,- status: null,- info: null,- tokens: readAuthTokens()-};+// construct provider-state reducer+export const providerStateReducerFactory = (initialState = {}) =>+ handleActions(actionHandler, {+ ...providerStateUpdaters.INITIAL_PROVIDER_STATE,+ ...initialState,+ initialState+ });-// file upload reducer-export const sharingReducer = handleActions({- [LOAD_REMOTE_RESOURCE_ERROR]: (state, action) => ({- ...state,- error: action.error,- currentOption: {dataUrl: action.url},- isMapLoading: false- }),- [PUSHING_FILE]: (state, action) => ({- ...state,- isLoading: action.isLoading,- info: action.metadata- }),- [CLOUD_LOGIN_SUCCESS]: state => ({- ...state,- tokens: readAuthTokens()- })-}, sharingInitialState);--export default sharingReducer;+export default providerStateReducerFactory();diff --git a/src/reducers/ui-state-updaters.js b/src/reducers/ui-state-updaters.jsindex 5202ad6d9..a231d555d 100644--- a/src/reducers/ui-state-updaters.js+++ b/src/reducers/ui-state-updaters.js@@ -29,6 +29,7 @@ import {RESOLUTIONS} from 'constants/default-settings';import {createNotification, errorNotification} from 'utils/notifications-utils';+import {calculateExportImageSize} from 'utils/export-utils';export const DEFAULT_ACTIVE_SIDE_PANEL = 'layer';export const DEFAULT_MODAL = ADD_DATA_ID;@@ -120,6 +121,14 @@ export const DEFAULT_EXPORT_IMAGE = {ratio: EXPORT_IMG_RATIOS.SCREEN,resolution: RESOLUTIONS.ONE_X,legend: false,+ mapH: 0,+ mapW: 0,+ imageSize: {+ zoomOffset: 0,+ scale: 1,+ imagW: 0,+ imageH: 0+ },// exporting stateimageDataUri: '',exporting: false,@@ -328,47 +337,19 @@ export const openDeleteModalUpdater = (* @returns {Object} nextState* @public*/-export const toggleLegendUpdater = state => ({- ...state,- exportImage: {- ...state.exportImage,- legend: !state.exportImage.legend- }-});--/**- * Set `exportImage.ratio`- * @memberof uiStateUpdaters- * @param {Object} state `uiState`- * @param {Object} action- * @param {string} action.payload one of `'SCREEN'`, `'FOUR_BY_THREE'` and `'SIXTEEN_BY_NINE'`- * @returns {Object} nextState- * @public- */-export const setRatioUpdater = (state, {payload}) => ({- ...state,- exportImage: {- ...state.exportImage,- ratio: payload.ratio- }-});+export const setExportImageSetting = (state, {payload: newSetting}) => {+ const updated = {...state.exportImage, ...newSetting};+ const imageSize =+ calculateExportImageSize(updated) || state.exportImage.imageSize;-/**- * Set `exportImage.resolution`- * @memberof uiStateUpdaters- * @param {Object} state `uiState`- * @param {Object} action- * @param {string} action.payload one of `'ONE_X'`, `'TWO_X'`- * @returns {Object} nextState- * @public- */-export const setResolutionUpdater = (state, {payload}) => ({- ...state,- exportImage: {- ...state.exportImage,- resolution: payload.resolution- }-});+ return {+ ...state,+ exportImage: {+ ...updated,+ imageSize+ }+ };+};/*** Set `exportImage.exporting` to `true`@@ -587,7 +568,7 @@ export const removeNotificationUpdater = (state, {payload: id}) => ({* @returns {Object} nextState* @public*/-export const loadFilesUpdater = (state) => ({+export const loadFilesUpdater = state => ({...state,loadFiles: {...state.loadFiles,diff --git a/src/reducers/ui-state.js b/src/reducers/ui-state.jsindex 892235507..2113671a4 100644--- a/src/reducers/ui-state.js+++ b/src/reducers/ui-state.js@@ -36,9 +36,7 @@ const actionHandler = {[ActionTypes.ADD_NOTIFICATION]: uiStateUpdaters.addNotificationUpdater,[ActionTypes.REMOVE_NOTIFICATION]: uiStateUpdaters.removeNotificationUpdater,- [ActionTypes.SET_RATIO]: uiStateUpdaters.setRatioUpdater,- [ActionTypes.SET_RESOLUTION]: uiStateUpdaters.setResolutionUpdater,- [ActionTypes.TOGGLE_LEGEND]: uiStateUpdaters.toggleLegendUpdater,+ [ActionTypes.SET_EXPORT_IMAGE_SETTING]: uiStateUpdaters.setExportImageSetting,[ActionTypes.START_EXPORTING_IMAGE]: uiStateUpdaters.startExportingImage,[ActionTypes.SET_EXPORT_IMAGE_DATA_URI]: uiStateUpdaters.setExportImageDataUri,[ActionTypes.SET_EXPORT_IMAGE_ERROR]: uiStateUpdaters.setExportImageError,diff --git a/src/reducers/vis-state-updaters.js b/src/reducers/vis-state-updaters.jsindex 73c15b367..70cf8f75e 100644--- a/src/reducers/vis-state-updaters.js+++ b/src/reducers/vis-state-updaters.js@@ -77,7 +77,7 @@ import {} from 'utils/split-map-utils';import {Layer, LayerClasses} from 'layers';-import {processFileToLoad} from '/utils/file-utils';+import {processFileToLoad} from 'utils/file-utils';import {DEFAULT_TEXT_LABEL} from 'layers/layer-factory';import {@@ -167,6 +167,11 @@ export const DEFAULT_EDITOR = {* @public*/export const INITIAL_VIS_STATE = {+ // map info+ mapInfo: {+ title: '',+ description: ''+ },// layerslayers: [],layerData: [],@@ -1419,6 +1424,22 @@ export const applyCPUFilterUpdater = (state, {dataId}) => {return dataIds.reduce((accu, id) => filterDatasetCPU(accu, id), state);};+/**+ * User input to update the info of the map+ * @memberof visStateUpdaters+ * @param {Object} state `visState`+ * @param {Object} action action+ * @param {Object} action.info {title: 'hello'}+ * @returns {Object} nextState+ * @public+ */+export const setMapInfoUpdater = (state, action) => ({+ ...state,+ mapInfo: {+ ...state.mapInfo,+ ...action.info+ }+});/*** Helper function to update All layer domain and layer data of state* @memberof visStateUpdatersdiff --git a/src/reducers/vis-state.js b/src/reducers/vis-state.jsindex 16f076a7d..a951a5c44 100644--- a/src/reducers/vis-state.js+++ b/src/reducers/vis-state.js@@ -75,6 +75,8 @@ const actionHandler = {[ActionTypes.SET_FILTER_PLOT]: visStateUpdaters.setFilterPlotUpdater,+ [ActionTypes.SET_MAP_INFO]: visStateUpdaters.setMapInfoUpdater,+[ActionTypes.SET_VISIBLE_LAYERS_FOR_MAP]: visStateUpdaters.setVisibleLayersForMapUpdater,[ActionTypes.SHOW_DATASET_TABLE]: visStateUpdaters.showDatasetTableUpdater,diff --git a/src/styles/base.js b/src/styles/base.jsindex 52e1b2f3a..d2a6eb6d0 100644--- a/src/styles/base.js+++ b/src/styles/base.js@@ -1100,5 +1100,8 @@ export const themeLT = {mapPanelHeaderBackgroundColor: '#f7f7F7',sliderBarBgd: '#D3D8E0',secondarySwitchBtnBgd: '#D3D8E0',- switchTrackBgd: '#D3D8E0'+ switchTrackBgd: '#D3D8E0',++ // button+ linkBtnActColor: textColorLT};diff --git a/src/tasks/tasks.js b/src/tasks/tasks.jsindex b426a7068..59d6f593b 100644--- a/src/tasks/tasks.js+++ b/src/tasks/tasks.js@@ -18,7 +18,7 @@// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN// THE SOFTWARE.-import {taskCreator} from 'react-palm/tasks';+import Task, {taskCreator} from 'react-palm/tasks';import {json as requestJson} from 'd3-request';import console from 'global/console';@@ -36,7 +36,8 @@ export const LOAD_FILE_TASK = taskCreator(// TODO: I think we should pass info to the handler and return// the same format back from the file handler- if (result.datasets) { // this is coming from parsing keplergl.json file+ if (result.datasets) {+ // this is coming from parsing keplergl.json filesuccess(result); // info is already part of datasets}success({datasets: {data: result, info}});@@ -44,10 +45,9 @@ export const LOAD_FILE_TASK = taskCreator(}).catch(err => {console.log(err);- error(err)- })-- },+ error(err);+ });+ },'LOAD_FILE_TASK');@@ -61,9 +61,33 @@ export const LOAD_MAP_STYLE_TASK = taskCreator(if (!result) {error(new Error('Map style response is empty'));}- success({id, style: result})+ success({id, style: result});}}),'LOAD_MAP_STYLE_TASK');++/**+ * task to upload file to cloud provider+ */+export const EXPORT_FILE_TO_CLOUD_TASK = Task.fromPromise(+ ({provider, payload}) => provider.uploadFile(payload),++ 'EXPORT_FILE_TO_CLOUD_TASK'+);++/**+ * task to dispatch a function as a task+ */+export const ACTION_TASK = Task.fromCallback(+ (_, cb) => cb(),++ 'ACTION_TASK'+);++export const DELAY_TASK = Task.fromCallback(+ (delay, cb) => window.setTimeout(() => cb(), delay),++ 'DELAY_TASK'+);diff --git a/src/utils/export-utils.js b/src/utils/export-utils.jsnew file mode 100644index 000000000..e1f2202a1--- /dev/null+++ b/src/utils/export-utils.js@@ -0,0 +1,225 @@+// 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_RESOLUTION_OPTIONS,+ EXPORT_IMG_RATIO_OPTIONS,+ RESOLUTIONS,+ EXPORT_IMG_RATIOS,+ EXPORT_DATA_TYPE+} from 'constants/default-settings';+import {exportMapToHTML} from 'templates/export-map-html';+import {formatCsv} from 'processors/data-processor';++import KeplerGlSchema from 'schemas';++/**+ * Default file names+ */+export const DEFAULT_IMAGE_NAME = 'kepler-gl.png';+export const DEFAULT_HTML_NAME = 'kepler.gl.html';+export const DEFAULT_JSON_NAME = 'keplergl.json';+export const DEFAULT_DATA_NAME = 'kepler-gl';++const defaultResolution = EXPORT_IMG_RESOLUTION_OPTIONS.find(+ op => op.id === RESOLUTIONS.ONE_X+);++const defaultRatio = EXPORT_IMG_RATIO_OPTIONS.find(op => op.id === EXPORT_IMG_RATIOS.FOUR_BY_THREE);++export function getScaleFromImageSize(imageW, imageH, mapW, mapH) {+ if ([imageW, imageH, mapW, mapH].some(d => d <= 0)) {+ return 1;+ }++ const base = imageW / imageH > 1 ? imageW : imageH;+ const mapBase = imageW / imageH > 1 ? mapW : mapH;+ const scale = base / mapBase;++ return scale;+}++export function calculateExportImageSize({mapW, mapH, ratio, resolution}) {+ if (mapW <= 0 || mapH <= 0) {+ return null;+ }++ const ratioItem = EXPORT_IMG_RATIO_OPTIONS.find(op => op.id === ratio) || defaultRatio;++ const resolutionItem =+ EXPORT_IMG_RESOLUTION_OPTIONS.find(op => op.id === resolution) || defaultResolution;++ const {width: scaledWidth, height: scaledHeight} = resolutionItem.getSize(+ mapW,+ mapH+ );++ const {width: imageW, height: imageH} = ratioItem.getSize(+ scaledWidth,+ scaledHeight+ );++ const {scale} = ratioItem.id === EXPORT_IMG_RATIOS.CUSTOM ?+ {} : resolutionItem;++ return {+ scale,+ imageW,+ imageH+ };+}++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);+}++export function exportImage(state, options) {+ const {imageDataUri} = state.uiState.exportImage+ if (imageDataUri) {+ const file = dataURItoBlob(imageDataUri);+ downloadFile(file, DEFAULT_IMAGE_NAME);+ }+}++export function exportJson(state, options) {+ const {hasData} = options;++ const data = hasData+ ? KeplerGlSchema.save(state)+ : KeplerGlSchema.getConfigToSave(state);++ const fileBlob = new Blob([data], {type: 'application/json'});+ downloadFile(fileBlob, DEFAULT_JSON_NAME);+}++export function exportHtml(state, options) {+ const {userMapboxToken, exportMapboxAccessToken, mode} = options;++ const data = {+ ...KeplerGlSchema.save(state),+ mapboxApiAccessToken:+ (userMapboxToken || '') !== ''+ ? userMapboxToken+ : exportMapboxAccessToken,+ mode+ };++ const fileBlob = new Blob([exportMapToHTML(data)], {type: 'text/html'});+ downloadFile(fileBlob, DEFAULT_HTML_NAME);+}++export function exportData(state, option) {+ const {visState} = state;+ const {datasets} = visState;+ const {selectedDataset, dataType, filtered} = option;+ // get the selected data+ const filename = DEFAULT_DATA_NAME;+ const selectedDatasets = datasets[selectedDataset]+ ? [datasets[selectedDataset]]+ : Object.values(datasets);+ if (!selectedDatasets.length) {+ // error: selected dataset not found.+ return;+ }++ selectedDatasets.forEach(selectedData => {+ const {allData, fields, label, filteredIdxCPU = []} = selectedData;+ const toExport = filtered ? filteredIdxCPU.map(i => allData[i]) : allData;+ // start to export data according to selected data type+ switch (dataType) {+ case EXPORT_DATA_TYPE.CSV: {+ const csv = formatCsv(toExport, fields);++ const fileBlob = new Blob([csv], {type: 'text/csv'});+ downloadFile(fileBlob, `${filename}_${label}.csv`);+ break;+ }+ // TODO: support more file types.+ default:+ break;+ }+ });+}++export function exportMap(state, option) {+ const mapToState = KeplerGlSchema.save(state);+ const {mapInfo} = state.visState;+ const {imageDataUri} = state.uiState.exportImage;+ const thumbnail = imageDataUri ? dataURItoBlob(imageDataUri) : null++ return {+ map: mapToState,+ info: mapInfo,+ thumbnail+ };+}++const exporters = {+ exportImage,+ exportJson,+ exportHtml,+ exportData+};++export default exporters;diff --git a/examples/demo-app/src/factories/save-map.js b/src/utils/map-info-utils.jssimilarity index 77%rename from examples/demo-app/src/factories/save-map.jsrename to src/utils/map-info-utils.jsindex f3d54b3f2..b1f636ac2 100644--- a/examples/demo-app/src/factories/save-map.js+++ b/src/utils/map-info-utils.js@@ -18,17 +18,13 @@// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN// THE SOFTWARE.-import {SaveMapFactory} from 'kepler.gl/components';+import {MAP_INFO_CHARACTER} from 'constants/default-settings';-export const CustomSaveMapFactory = () => {- const SaveMap = SaveMapFactory();- SaveMap.defaultProps = {- ...SaveMap.defaultProps,- label: 'Share Public URL'- };- return SaveMap;-};--export function replaceSaveMap() {- return [SaveMapFactory, CustomSaveMapFactory]+export function isValidMapInfo(mapInfo) {+ return (+ mapInfo.title.length &&+ mapInfo.title.length <= MAP_INFO_CHARACTER.title &&+ (!mapInfo.description.length ||+ mapInfo.description.length <= MAP_INFO_CHARACTER.description)+ );}diff --git a/src/utils/map-style-utils/mapbox-gl-style-editor.js b/src/utils/map-style-utils/mapbox-gl-style-editor.jsindex dc44148ae..ddb0157a6 100644--- a/src/utils/map-style-utils/mapbox-gl-style-editor.js+++ b/src/utils/map-style-utils/mapbox-gl-style-editor.js@@ -22,8 +22,6 @@ import memoize from 'lodash.memoize';import clondDeep from 'lodash.clonedeep';import {DEFAULT_LAYER_GROUPS,- RESOLUTIONS,- EXPORT_IMG_RESOLUTION_OPTIONS,DEFAULT_MAPBOX_API_URL} from 'constants/default-settings';@@ -151,23 +149,22 @@ export function getStyleImageIcon({`?access_token=${mapboxApiAccessToken}&logo=false&attribution=false`;}-export function scaleMapStyleByResolution(mapboxStyle, resolution) {- const labelLayerGroup = DEFAULT_LAYER_GROUPS.find(lg => lg.slug === 'label');- const {filter: labelLayerFilter} = labelLayerGroup;+export function scaleMapStyleByResolution(mapboxStyle, scale) {++ if (scale !== 1 && mapboxStyle) {+ const labelLayerGroup = DEFAULT_LAYER_GROUPS.find(lg => lg.slug === 'label');+ const {filter: labelLayerFilter} = labelLayerGroup;+ const zoomOffset = Math.log2(scale);- if (resolution !== RESOLUTIONS.ONE_X && mapboxStyle) {- const {scale, zoomOffset} = EXPORT_IMG_RESOLUTION_OPTIONS.find(- r => r.id === resolution- );const copyStyle = clondDeep(mapboxStyle);(copyStyle.layers || []).forEach(d => {// edit minzoom and maxzoomif (d.maxzoom) {- d.maxzoom += zoomOffset;+ d.maxzoom = Math.max(d.maxzoom + zoomOffset, 1);}if (d.minzoom) {- d.minzoom += zoomOffset;+ d.minzoom = Math.max(d.minzoom + zoomOffset, 1);}// edit text size@@ -177,9 +174,10 @@ export function scaleMapStyleByResolution(mapboxStyle, resolution) {d.layout['text-size'] &&Array.isArray(d.layout['text-size'].stops)) {+d.layout['text-size'].stops.forEach(stop => {// zoom- stop[0] += Math.log2(scale);+ stop[0] = Math.max(stop[0] + zoomOffset, 1);// sizestop[1] *= scale;});diff --git a/src/utils/utils.js b/src/utils/utils.jsindex cff0ecae1..fb5ec9e97 100644--- a/src/utils/utils.js+++ b/src/utils/utils.js@@ -121,13 +121,15 @@ const insertValue = (obj, key, value) => {* @param {*} value*/export function isObject(value) {- return value !== null && (typeof value === 'object' || typeof value === 'function')+ return (+ value !== null && (typeof value === 'object' || typeof value === 'function')+ );}const setPath = ([key, ...next], value, obj) => {// is Object allows js object, array and functionif (!isObject(obj)) {- return obj+ return obj;}if (next.length === 0) {@@ -150,3 +152,34 @@ const setPath = ([key, ...next], value, obj) => {*/export const set = (path, value, obj) =>obj === null ? obj : setPath(path, value, obj);++/**+ * Get error information of unknown type+ * Extracts as much human readable information as possible+ * Ensure result is an Error object suitable for throw or promise rejection+ *+ * @private+ * @param {*} err - Unknown error+ * @return {string} - human readable error msg+ */+export function getError(err) {+ if (!err) {+ return 'Something went wrong';+ }++ if (typeof err === 'string') {+ return err;+ } else if (err instanceof Error) {+ return err.message;+ } else if (typeof err === 'object') {+ return err.error+ ? getError(err.error)+ : err.err+ ? getError(err.err)+ : err.message+ ? getError(err.message)+ : JSON.stringify(err);+ }++ return null;+}diff --git a/test/browser/components/modals/index.js b/test/browser/components/modals/index.jsindex 65a6ae06a..c5d100829 100644--- a/test/browser/components/modals/index.js+++ b/test/browser/components/modals/index.js@@ -19,3 +19,5 @@// THE SOFTWARE.import './data-table-modal-test';+import './save-map-modal-test';+import './share-map-modal-test';diff --git a/test/browser/components/modals/save-map-modal-test.js b/test/browser/components/modals/save-map-modal-test.jsnew file mode 100644index 000000000..fbf0f63e1--- /dev/null+++ b/test/browser/components/modals/save-map-modal-test.js@@ -0,0 +1,175 @@+// 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 React from 'react';+import test from 'tape';+import {mountWithTheme} from 'test/helpers/component-utils';+import sinon from 'sinon';+import SaveMapModalFactory from 'components/modals/save-map-modal';++import CloudTile from 'components/modals/cloud-tile';+import ImagePreview from 'components/common/image-preview';+const SaveMapModal = SaveMapModalFactory();++test('Components -> SaveMapModal.mount', t => {+ const onUpdateSetting = sinon.spy();+ const onSetCloudProvider = sinon.spy();++ // mount+ t.doesNotThrow(() => {+ mountWithTheme(+ <SaveMapModal+ onUpdateSetting={onUpdateSetting}+ onSetCloudProvider={onSetCloudProvider}+ />+ );+ }, 'Show not fail without props');+ t.ok(onUpdateSetting.calledOnce, 'should call onUpdateSetting when mount');+ t.ok(+ onSetCloudProvider.notCalled,+ 'should not call onSetCloudProvider when mount'+ );++ t.end();+});++test('Components -> SaveMapModal.mount with providers', t => {+ const onSetCloudProvider = sinon.spy();++ const mockProvider = {+ getAccessToken: () => true,+ name: 'taro'+ };+ // mount+ t.doesNotThrow(() => {+ mountWithTheme(+ <SaveMapModal+ onUpdateSetting={() => {}}+ onSetCloudProvider={onSetCloudProvider}+ cloudProviders={[mockProvider]}+ />+ );+ }, 'Show not fail mount props');+ t.ok(+ onSetCloudProvider.calledWithExactly('taro'),+ 'should set default provider when mount'+ );++ const wrapper = mountWithTheme(+ <SaveMapModal+ onUpdateSetting={() => {}}+ onSetCloudProvider={onSetCloudProvider}+ cloudProviders={[mockProvider]}+ currentProvider="hello"+ />+ );+ t.ok(+ onSetCloudProvider.calledOnce,+ 'should not set default provider if it is already set'+ );++ t.ok(wrapper.find(CloudTile).length === 1, 'should render 1 cloud provider');+ t.ok(wrapper.find(ImagePreview).length === 1, 'should render 1 ImagePreview');++ t.end();+});++test('Components -> SaveMapModal on change input', t => {+ const onSetMapInfo = sinon.spy();+ const eventObj = {target: {value: 'taro'}};++ let wrapper;+ // mount+ t.doesNotThrow(() => {+ wrapper = mountWithTheme(+ <SaveMapModal onUpdateSetting={() => {}} onSetMapInfo={onSetMapInfo} />+ );+ }, 'Show not fail mount props');++ wrapper.find('input#map-title').simulate('change', eventObj);++ t.ok(onSetMapInfo.calledWithExactly({title: 'taro'}), 'should set map title');++ wrapper.find('textarea#map-description').simulate('change', eventObj);++ t.ok(+ onSetMapInfo.calledWithExactly({description: 'taro'}),+ 'should set map description'+ );++ t.end();+});++test('Components -> SaveMapModal on click provider', t => {+ const onSetCloudProvider = sinon.spy();+ const login = sinon.spy();+ const logout = sinon.spy();++ const mockProvider = {+ getAccessToken: () => true,+ name: 'taro',+ logout+ };++ const mockProvider2 = {+ getAccessToken: () => false,+ name: 'blue',+ login+ };++ let wrapper;+ // mount+ t.doesNotThrow(() => {+ wrapper = mountWithTheme(+ <SaveMapModal+ cloudProviders={[mockProvider, mockProvider2]}+ currentProvider='taro'+ onUpdateSetting={() => {}}+ onSetCloudProvider={onSetCloudProvider} />+ );+ }, 'Show not fail mount props');++ t.equal(wrapper.find('.provider-tile__wrapper').length, 2, 'should render 1 provider tile');++ // click taro to select+ wrapper.find('.provider-tile__wrapper').at(0).simulate('click');+ t.ok(onSetCloudProvider.calledWithExactly('taro'), 'should call onSetCloudProvider with taro');++ // click blue to login+ wrapper.find('.provider-tile__wrapper').at(1).simulate('click');+ t.ok(login.calledOnce, 'should call login');++ // call onSuccess after login to set current provider+ const onSuccess = login.args[0][0];+ onSuccess();+ t.ok(onSetCloudProvider.calledWithExactly('blue'), 'should call onSetCloudProvider with blue');++ // click taro to logout+ wrapper.find('.logout-button').simulate('click');+ t.ok(logout.calledOnce, 'should call logout');++ // call onSuccess after login to set current provider+ const onSuccessLogout = logout.args[0][0];+ onSuccessLogout();+ t.ok(onSetCloudProvider.calledWithExactly(null), 'should call onSetCloudProvider with null');++ t.end();+});+diff --git a/test/browser/components/modals/share-map-modal-test.js b/test/browser/components/modals/share-map-modal-test.jsnew file mode 100644index 000000000..c986647f8--- /dev/null+++ b/test/browser/components/modals/share-map-modal-test.js@@ -0,0 +1,174 @@+// 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 React from 'react';+import test from 'tape';+import {mountWithTheme} from 'test/helpers/component-utils';+import sinon from 'sinon';+import ShareMapUrlModalFactory, {+ SharingUrl+} from 'components/modals/share-map-modal';++import CloudTile from 'components/modals/cloud-tile';+import StatusPanel from 'components/modals/status-panel';+const ShareMapUrlModal = ShareMapUrlModalFactory();++test('Components -> ShareMapUrlModal.mount', t => {+ const onSetCloudProvider = sinon.spy();++ // mount+ t.doesNotThrow(() => {+ mountWithTheme(+ <ShareMapUrlModal onSetCloudProvider={onSetCloudProvider} />+ );+ }, 'Show not fail without props');+ t.ok(+ onSetCloudProvider.notCalled,+ 'should not call onSetCloudProvider when mount'+ );++ t.end();+});++test('Components -> ShareMapUrlModal.mount with providers', t => {+ const onSetCloudProvider = sinon.spy();++ const mockProvider = {+ getAccessToken: () => true,+ name: 'taro'+ };+ // mount+ t.doesNotThrow(() => {+ mountWithTheme(+ <ShareMapUrlModal+ onSetCloudProvider={onSetCloudProvider}+ cloudProviders={[mockProvider]}+ />+ );+ }, 'Show not fail mount props');+ t.ok(+ onSetCloudProvider.calledWithExactly('taro'),+ 'should set default provider when mount'+ );++ const wrapper = mountWithTheme(+ <ShareMapUrlModal+ onSetCloudProvider={onSetCloudProvider}+ cloudProviders={[mockProvider]}+ currentProvider="hello"+ />+ );+ t.ok(+ onSetCloudProvider.calledOnce,+ 'should not set default provider if it is already set'+ );++ t.ok(wrapper.find(CloudTile).length === 1, 'should render 1 cloud provider');+ t.ok(wrapper.find(StatusPanel).length === 0, 'should not render StatusPanel');++ t.end();+});++test('Components -> ShareMapUrlModal.mount with isLoading', t => {+ const mockProvider = {+ getAccessToken: () => true,+ name: 'taro'+ };+ // mount+ let wrapper;+ t.doesNotThrow(() => {+ wrapper = mountWithTheme(+ <ShareMapUrlModal+ isLoading+ onSetCloudProvider={() => {}}+ cloudProviders={[mockProvider]}+ />+ );+ }, 'Show not fail mount with isLoading');++ t.ok(+ wrapper.find(StatusPanel).length === 1,+ 'should render StatusPanel when loading'+ );++ wrapper = mountWithTheme(+ <ShareMapUrlModal+ error="something is wrong"+ onSetCloudProvider={() => {}}+ cloudProviders={[mockProvider]}+ />+ );+ t.ok(+ wrapper.find(StatusPanel).length === 1,+ 'should render StatusPanel when error'+ );+ t.equal(+ wrapper.find('.notification-item--message').length,+ 1,+ 'should render 1 message'+ );+ t.equal(+ wrapper+ .find('.notification-item--message')+ .find('p')+ .text(),+ 'something is wrong',+ 'should render error msg'+ );+ t.end();+});++test('Components -> ShareMapUrlModal.mount with SharingUrl', t => {+ const shareUrl = 'http://taro-and-blue';+ const mockProvider = {+ getAccessToken: () => true,+ name: 'taro',+ getMapPermalink: () => shareUrl+ };++ // mount+ let wrapper;+ t.doesNotThrow(() => {+ wrapper = mountWithTheme(+ <ShareMapUrlModal+ successInfo={{metaUrl: 'http://somdthing'}}+ cloudProviders={[mockProvider]}+ currentProvider="taro"+ onSetCloudProvider={() => {}}+ />+ );+ }, 'Show not fail mount with successInfo');++ t.ok(+ wrapper.find(SharingUrl).length === 1,+ 'should render SharingUrl when loading'+ );++ t.equal(+ wrapper+ .find(SharingUrl)+ .find('input')+ .props().value,+ shareUrl,+ 'should render with successInfo.metaUrl'+ );++ t.end();+});diff --git a/test/browser/components/side-panel/save-export-dropdown-test.js b/test/browser/components/side-panel/save-export-dropdown-test.jsindex e5aeae3b6..741af55fc 100644--- a/test/browser/components/side-panel/save-export-dropdown-test.js+++ b/test/browser/components/side-panel/save-export-dropdown-test.js@@ -20,28 +20,19 @@import React from 'react';import test from 'tape';-import {shallow} from 'enzyme';+import {mount} from 'enzyme';import sinon from 'sinon';import {- ExportImageFactory,- ExportDataFactory,- ExportMapFactory,- SaveMapFactory,- SaveExportDropdownFactory+ SaveExportDropdownFactory,+ PanelHeaderDropdownFactory} from 'components/side-panel/panel-header';+import ToolbarItem from 'components/common/toolbar-item';test('SaveExportDropdown', t => {- const ExportImage = ExportImageFactory();- const ExportData = ExportDataFactory();- const ExportMap = ExportMapFactory();- const SaveMap = SaveMapFactory();-+ const PanelHeaderDropdown = PanelHeaderDropdownFactory();const SaveExportDropdown = SaveExportDropdownFactory(- ExportImage,- ExportData,- ExportMap,- SaveMap+ PanelHeaderDropdown);const onExportImage = sinon.spy();@@ -51,7 +42,7 @@ test('SaveExportDropdown', t => {const onSaveMap = sinon.spy();const onClose = sinon.spy();- const $ = shallow(+ const wrapper = mount(<SaveExportDropdownonExportImage={onExportImage}onExportData={onExportData}@@ -62,53 +53,39 @@ test('SaveExportDropdown', t => {onClose={onClose}/>);-- t.equal(- $.find('ExportImage').length,- 1,- 'We should display 1 ExportImage'- );-- t.equal(- $.find('ExportData').length,- 1,- 'We should display 1 ExportData'- );-t.equal(- $.find('ExportMap').length,+ wrapper.find(PanelHeaderDropdown).length,1,- 'We should display 1 ExportMap'+ 'We should display 1 PanelHeaderDropdown');-t.equal(- $.find('SaveMap').length,- 1,- 'We should display 1 SaveMap'+ wrapper.find(ToolbarItem).length,+ 4,+ 'We should display 4 ToolbarItems');- $.find('ExportImage').simulate('click');+ wrapper.find('.toolbar-item').at(0).simulate('click');t.equal(onExportImage.called,true,'Should have called export image callback');- $.find('ExportData').simulate('click');+ wrapper.find('.toolbar-item').at(1).simulate('click');t.equal(onExportData.called,true,'Should have called export data callback');- $.find('ExportMap').simulate('click');+ wrapper.find('.toolbar-item').at(2).simulate('click');t.equal(onExportMap.called,true,'Should have called export map callback');- $.find('SaveMap').simulate('click');+ wrapper.find('.toolbar-item').at(3).simulate('click');t.equal(onSaveMap.called,true,diff --git a/test/node/reducers/index.js b/test/node/reducers/index.jsindex 67f96e219..f5fc09880 100644--- a/test/node/reducers/index.js+++ b/test/node/reducers/index.js@@ -24,6 +24,7 @@ import './map-style-test';import './vis-state-test';import './ui-state-test';import './composer-state-test';+import './provider-state-test';import './root-test';// test mergersdiff --git a/test/node/reducers/provider-state-test.js b/test/node/reducers/provider-state-test.jsnew file mode 100644index 000000000..2f257e1da--- /dev/null+++ b/test/node/reducers/provider-state-test.js@@ -0,0 +1,365 @@+// 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 test from 'tape';+import React from 'react';+import {+ drainTasksForTesting,+ succeedTaskInTest,+ errorTaskInTest+} from 'react-palm/tasks';+import sinon from 'sinon';+import {default as Console} from 'global/console';+import ActionTypes from 'constants/action-types';++import {+ exportFileToCloud,+ resetProviderStatus,+ setCloudProvider+} from 'actions/provider-actions';+import reducer, {providerStateReducerFactory} from 'reducers/provider-state';+import {INITIAL_PROVIDER_STATE} from 'reducers/provider-state-updaters';++const MockIcon = () => <div id="provider-icon" />;++class MockProvider {+ constructor() {+ // All cloud-providers providers must implement the following properties+ this.name = 'taro';+ this.displayName = 'Taro';+ this.icon = MockIcon;+ }+ login(onSuccess) {+ onSuccess();+ return;+ }+ logout(onSuccess) {+ onSuccess();+ return;+ }+ hasPrivateStorage() {+ return true;+ }+ hasSharingUrl() {+ return true;+ }+ async uploadFile(args) {+ const promise = new Promise((resolve, reject) => {+ () => resolve('done!')();+ });+ await promise;+ }+}++test('#providerStateReducer', t => {+ t.deepEqual(+ reducer(undefined, {}),+ {...INITIAL_PROVIDER_STATE, initialState: {}},+ 'should return the initial provider state'+ );+ t.end();+});++test('#providerStateReducerFactory', t => {+ const providerStateReducer = providerStateReducerFactory({+ currentProvider: 'taro'+ });++ t.deepEqual(+ providerStateReducer(undefined, {}),+ {+ ...INITIAL_PROVIDER_STATE,+ currentProvider: 'taro',+ initialState: {currentProvider: 'taro'}+ },+ 'should return the initial state'+ );+ t.end();+});++test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD', t => {+ const errSpy = sinon.spy(Console, 'error');++ // null+ reducer(undefined, exportFileToCloud({provider: null}));+ t.ok(errSpy.calledOnce, 'should call console.error if provider is undefined');+ t.equal(+ errSpy.getCall(0).args[0],+ 'provider is not defined',+ 'should warn when cannot find kepler.gl state'+ );+ reducer(+ undefined,+ exportFileToCloud({provider: {name: 'taro', hello: true}})+ );++ // uploadFile+ t.ok(+ errSpy.calledTwice,+ 'should call console.error if provider does not have uploadFile'+ );+ t.equal(+ errSpy.getCall(1).args[0],+ 'uploadFile is not a function of Cloud provider: taro',+ 'should warn when cannot find uploadFile function'+ );++ // mapData+ const mockProvider = new MockProvider();+ const nextState = reducer(+ undefined,+ exportFileToCloud({+ mapData: {data: []},+ provider: mockProvider,+ isPublic: false+ })+ );++ const [task1, ...more] = drainTasksForTesting();++ t.ok(more.length === 0, 'should create 1 task');+ t.deepEqual(+ nextState,+ {+ isLoading: true,+ error: null,+ currentProvider: 'taro',+ successInfo: {},+ initialState: {}+ },+ 'Should set isLoading and current provider'+ );++ t.equal(+ task1.type,+ 'EXPORT_FILE_TO_CLOUD_TASK',+ 'should create export file tasks'+ );+ t.deepEqual(+ task1.payload,+ {+ provider: mockProvider,+ payload: {+ mapData: {data: []},+ blob: null,+ fileName: null,+ isPublic: false+ }+ },+ 'should call upload file with correct payload'+ );++ // success+ const resultState1 = reducer(+ nextState,+ succeedTaskInTest(task1, {url: 'taro_and_blue'})+ );++ t.deepEqual(+ resultState1,+ {+ isLoading: false,+ error: null,+ currentProvider: 'taro',+ initialState: {},+ successInfo: {metaUrl: 'taro_and_blue', folderLink: undefined}+ },+ 'Should set isLoading to false and successInfo'+ );+ const task2 = drainTasksForTesting();+ t.ok(task2.length === 0, 'should create 0 task');++ // error+ const resultState2 = reducer(+ nextState,+ errorTaskInTest(task1, new Error('hello'))+ );+ t.deepEqual(+ resultState2,+ {+ isLoading: false,+ error: 'hello',+ currentProvider: 'taro',+ initialState: {},+ successInfo: {}+ },+ 'Should set isLoading to false and error'+ );+ t.end();+});++// eslint-disable-next-line max-statements+test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD -> onSuccess : onError', t => {+ const mockResponse = {url: 'taro_and_blue'};+ const mockProvider = new MockProvider();+ const mockError = new Error('ooops');++ const testUpdaters = {+ [ActionTypes.TOGGLE_MODAL]: (state, action) => ({+ ...state,+ modalId: action.payload+ }),+ [ActionTypes.ADD_NOTIFICATION]: (state, action) => ({+ ...state,+ notification: action.payload+ }),+ [ActionTypes.REMOVE_NOTIFICATION]: (state, action) => ({+ ...state,+ remove: true+ })+ };++ const composedReducer = (state, action) => {+ if (testUpdaters[action.type]) {+ return testUpdaters[action.type](state, action);+ }+ return reducer(state, action);+ };++ const onSuccess = args => {+ t.deepEqual(+ args,+ {response: mockResponse, provider: mockProvider},+ 'should call onSuccess with arguments'+ );+ return {};+ };+ const onError = args => {+ t.deepEqual(args, mockError, 'should call onError with arguments');+ return {};+ };++ // mapData+ const state = reducer(+ undefined,+ exportFileToCloud({+ mapData: {data: []},+ provider: mockProvider,+ onSuccess,+ onError,+ closeModal: true+ })+ );+ const [task1, ...more] = drainTasksForTesting();+ t.ok(more.length === 0, 'should create 1 task');+ t.equal(+ task1.type,+ 'EXPORT_FILE_TO_CLOUD_TASK',+ 'should create export file tasks'+ );++ // success+ const nextState = reducer(state, succeedTaskInTest(task1, mockResponse));+ const [task2, task3, ...more2] = drainTasksForTesting();+ t.ok(more2.length === 0, 'should create 1 task');+ t.ok(task2.type === 'ACTION_TASK', 'should create 2 ACTION_TASK');+ t.ok(task3.type === 'ACTION_TASK', 'should create 2 ACTION_TASK');++ t.deepEqual(+ nextState,+ {+ isLoading: false,+ error: null,+ currentProvider: 'taro',+ initialState: {},+ successInfo: {metaUrl: 'taro_and_blue', folderLink: undefined}+ },+ 'Should set isLoading to false and successInfo'+ );++ const resultState1 = reducer(nextState, succeedTaskInTest(task2, undefined));+ const resultState2 = reducer(+ resultState1,+ succeedTaskInTest(task3, undefined)+ );++ // saveToCloudSuccess+ const [task4, task5, task6, ...more3] = drainTasksForTesting();+ t.ok(more3.length === 0, 'should create 3 tasks');++ t.ok(task4.type === 'ACTION_TASK', 'should create 2 ACTION_TASKS');+ t.ok(task5.type === 'ACTION_TASK', 'should create 2 ACTION_TASKS');+ t.ok(task6.type === 'DELAY_TASK', 'should create 1 DELAY_TASK');++ // toggleModal(null),+ const resultState3 = composedReducer(resultState2, succeedTaskInTest(task4, undefined));+ t.deepEqual(+ resultState3,+ {+ isLoading: false,+ error: null,+ currentProvider: 'taro',+ initialState: {},+ successInfo: {metaUrl: 'taro_and_blue', folderLink: undefined},+ modalId: null+ },+ 'Should call toggleModal(null'+ );+ const resultState4 = composedReducer(resultState3, succeedTaskInTest(task5, undefined));+ t.equal(resultState4.notification.type, 'success', 'Should call addNotification with successNote');++ const resultState5 = composedReducer(resultState4, succeedTaskInTest(task6, undefined));+ t.equal(resultState5.remove, true, 'Should call removeNotification');++ t.end();+});++test('#providerStateReducer -> RESET_PROVIDER_STATUS', t => {+ const mockProvider = new MockProvider();+ const nextState = reducer(+ undefined,+ exportFileToCloud({+ mapData: {data: []},+ provider: mockProvider,+ isPublic: false+ })+ );+ const nextState1 = reducer(nextState, resetProviderStatus());++ t.deepEqual(+ nextState1,+ {+ isLoading: false,+ error: null,+ currentProvider: 'taro',+ successInfo: {},+ initialState: {}+ },+ 'Should resetProviderStatus'+ );++ t.end();+})++test('#providerStateReducer -> SET_CLOUD_PROVIDER', t => {+ const nextState = reducer(undefined, setCloudProvider('blue'));+ t.deepEqual(+ nextState,+ {+ isLoading: false,+ error: null,+ currentProvider: 'blue',+ successInfo: {},+ initialState: {}+ },+ 'Should setCloudProvider'+ );+ t.end();+});diff --git a/test/node/reducers/ui-state-test.js b/test/node/reducers/ui-state-test.jsindex 0566c3b2d..03878d8b6 100644--- a/test/node/reducers/ui-state-test.js+++ b/test/node/reducers/ui-state-test.js@@ -24,9 +24,7 @@ import {toggleSidePanel,toggleModal,openDeleteModal,- setResolution,- setRatio,- toggleLegend,+ setExportImageSetting,toggleMapControl,setExportSelectedDataset,setExportDataType,@@ -38,10 +36,7 @@ import reducer, {uiStateReducerFactory} from 'reducers/ui-state';import {INITIAL_UI_STATE} from 'reducers/ui-state-updaters';import {EXPORT_DATA_TYPE,- EXPORT_IMG_RATIOS,- RESOLUTIONS-} from 'constants/default-settings';-import {+ RESOLUTIONS,DEFAULT_NOTIFICATION_TOPICS,DEFAULT_NOTIFICATION_TYPES} from 'constants/default-settings';@@ -116,33 +111,10 @@ test('#uiStateReducer -> OPEN_DELETE_MODAL', t => {t.end();});-test('#uiStateReducer -> SET_RATIO', t => {+test('#uiStateReducer -> SET_EXPORT_IMAGE_SETTING', t => {const newReducer = reducer(INITIAL_UI_STATE,- setRatio({ratio: EXPORT_IMG_RATIOS.SIXTEEN_BY_NINE})- );-- const expectedState = {- ...INITIAL_UI_STATE,- exportImage: {- ...INITIAL_UI_STATE.exportImage,- ratio: EXPORT_IMG_RATIOS.SIXTEEN_BY_NINE- }- };-- t.deepEqual(- newReducer,- expectedState,- 'should set the ratio to SIXTEEN_BY_NINE'- );-- t.end();-});--test('#uiStateReducer -> SET_RESOLUTION', t => {- const newReducer = reducer(- INITIAL_UI_STATE,- setResolution({resolution: RESOLUTIONS.TWO_X})+ setExportImageSetting({resolution: RESOLUTIONS.TWO_X}));const expectedState = {@@ -158,22 +130,6 @@ test('#uiStateReducer -> SET_RESOLUTION', t => {t.end();});-test('#uiStateReducer -> TOGGLE_LEGEND', t => {- const newReducer = reducer(INITIAL_UI_STATE, toggleLegend());-- const expectedState = {- ...INITIAL_UI_STATE,- exportImage: {- ...INITIAL_UI_STATE.exportImage,- legend: true- }- };-- t.deepEqual(newReducer, expectedState, 'should set the legend to true');-- t.end();-});-test('#uiStateReducer -> TOGGLE_MAP_CONTROL', t => {const newReducer = reducer(INITIAL_UI_STATE, toggleMapControl('mapLegend'));diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.jsindex 6bc255cc6..c5b99bbd7 100644--- a/test/node/reducers/vis-state-test.js+++ b/test/node/reducers/vis-state-test.js@@ -1591,27 +1591,34 @@ test('#visStateReducer -> UPDATE_VIS_DATA -> mergeFilters', t => {}];+ const expectedFilterProps = {+ domain: [12.25, 12.29],+ step: 0.001,+ histogram: [1], // test not empty+ enlargedHistogram: [2], // test not empty+ fieldType: 'real',+ type: mockFilter.type,+ gpu: true,+ typeOptions: ['range'],+ value: [12.25, 12.29]+ };+const expectedFilter = {+ ...expectedFilterProps,dataId: ['smoothie'],- domain: [12.25, 12.29],- enlarged: true,fieldIdx: [0],id: '38chejr',- fieldType: 'real',- fixedDomain: false,freeze: true,+ fixedDomain: false,+ enlarged: true,plotType: 'histogram',yAxis: null,gpu: true,gpuChannel: [0],interval: null,- histogram: [],- enlargedHistogram: [],- isAnimating: false,name: [mockFilter.name],speed: 1,- step: 0.001,- type: mockFilter.type,+ isAnimating: false,typeOptions: ['range'],value: mockFilter.value};@@ -1630,7 +1637,10 @@ test('#visStateReducer -> UPDATE_VIS_DATA -> mergeFilters', t => {const expectedDatasets = {smoothie: {- fields: expectedFields,+ fields: expectedFields.map(f => f.name === mockFilter.name ? {+ ...f,+ filterProps: expectedFilterProps+ } : f),// gpu filter in place, filteredIndex should not be updatedfilteredIndex: allIndexes,filteredIndexForDomain: [0],@@ -1698,15 +1708,7 @@ test('#visStateReducer -> UPDATE_VIS_DATA -> mergeFilters', t => {const expectedState = {filterToBeMerged: [- {- ...getDefaultFilter('nothing_here'),- id: 'vuey55d',- enlarged: true,- name: 'test_test',- type: 'select',- value: true,- fieldIdx: [0]- }+ oldState.filterToBeMerged[1]],filters: [expectedFilter],datasets: expectedDatasets@@ -1714,13 +1716,13 @@ test('#visStateReducer -> UPDATE_VIS_DATA -> mergeFilters', t => {cmpFilters(t, expectedState.filters, newState.filters);- // t.deepEqual(- // newState.filterToBeMerged,- // expectedState.filterToBeMerged,- // 'should saved unmerged filter to filterToBeMerged'- // );- //- // cmpDatasets(t, expectedState.datasets, newState.datasets);+ t.deepEqual(+ newState.filterToBeMerged,+ expectedState.filterToBeMerged,+ 'should saved unmerged filter to filterToBeMerged'+ );++ cmpDatasets(t, expectedState.datasets, newState.datasets);// filteredIndex should be shallow equalt.equal(@@ -2678,7 +2680,11 @@ test('#visStateReducer -> REMOVE_DATASET w filter and layer', t => {filterToBeMerged: [],splitMapsToBeMerged: [],interactionToBeMerged: [],- editor: oldState.editor+ editor: oldState.editor,+ mapInfo: {+ title: '',+ description: ''+ }};const newReducer = reducer(@@ -2897,7 +2903,11 @@ test('#visStateReducer -> SPLIT_MAP: REMOVE_DATASET', t => {filterToBeMerged: [],splitMapsToBeMerged: [],interactionToBeMerged: [],- editor: oldState.editor+ editor: oldState.editor,+ mapInfo: {+ title: '',+ description: ''+ }};const newReducer = reducer(diff --git a/test/node/utils/util-test.js b/test/node/utils/util-test.jsindex 251a3314f..f136cd861 100644--- a/test/node/utils/util-test.js+++ b/test/node/utils/util-test.js@@ -19,7 +19,7 @@// THE SOFTWARE.import test from 'tape';-import {set, toArray} from 'utils/utils';+import {set, toArray, getError} from 'utils/utils';test('Utils -> set', t => {const obj1 = {map: {map1: 'world'}};@@ -61,3 +61,15 @@ test('Utils -> toArray', t => {t.end();});++test('Utils -> getError', t => {+ t.equal(getError(new Error('oops')), 'oops', 'should find error message from Error object');+ t.equal(getError('sorry'), 'sorry', 'should find error message from string');+ t.equal(getError(), 'Something went wrong', 'should find error message from empty');++ t.equal(getError({error: {message: 'not good'}}), 'not good', 'should find error message from object');+ t.equal(getError({err: {error: 'not good'}}), 'not good', 'should find error message from object');+ t.equal(getError({status: 400}), '{"status":400}', 'should find error message from object');++ t.end()+});diff --git a/yarn.lock b/yarn.lockindex bcabd1727..1e79760b0 100644--- a/yarn.lock+++ b/yarn.lock@@ -4238,6 +4238,13 @@ copy-descriptor@^0.1.0:resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=+copy-to-clipboard@^3:+ version "3.2.0"+ resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.2.0.tgz#d2724a3ccbfed89706fac8a894872c979ac74467"+ integrity sha512-eOZERzvCmxS8HWzugj4Uxl8OJxa7T2k1Gi0X5qavwydHIfuSHq2dTD09LOg/XyGq4Zpb5IsR/2OJ5lbOegz78w==+ dependencies:+ toggle-selection "^1.0.6"+core-js-compat@^3.6.0:version "3.6.0"resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.6.0.tgz#4eb6cb69d03d99159ed7c860cd5fcf7d23a62ea9"@@ -10989,6 +10996,14 @@ react-color@^2.17.3:reactcss "^1.2.0"tinycolor2 "^1.4.1"+react-copy-to-clipboard@^5.0.2:+ version "5.0.2"+ resolved "https://registry.yarnpkg.com/react-copy-to-clipboard/-/react-copy-to-clipboard-5.0.2.tgz#d82a437e081e68dfca3761fbd57dbf2abdda1316"+ integrity sha512-/2t5mLMMPuN5GmdXo6TebFa8IoFxZ+KTDDqYhcDm0PhkgEzSxVvIX26G20s1EB02A4h2UZgwtfymZ3lGJm0OLg==+ dependencies:+ copy-to-clipboard "^3"+ prop-types "^15.5.8"+react-deep-force-update@^2.1.1:version "2.1.3"resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-2.1.3.tgz#740612322e617bcced38f61794a4af75dc3d98e7"@@ -13269,6 +13284,11 @@ to-through@^2.0.0:dependencies:through2 "^2.0.3"+toggle-selection@^1.0.6:+ version "1.0.6"+ resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"+ integrity sha1-bkWxJj8gF/oKzH2J14sVuL932jI=+version "1.0.0"resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"