// Copyright (c) 2022 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} from 'react'; import styled, {ThemeProvider} from 'styled-components'; import {CopyToClipboard} from 'react-copy-to-clipboard'; import {themeLT} from 'styles/base'; import ImageModalContainer, {ImageModalContainerProps} from './image-modal-container'; import ProviderModalContainer from './provider-modal-container'; import { StyledModalContent, StyledExportSection, InputLight, Button } from 'components/common/styled-components'; import CloudTile from './cloud-tile'; import StatusPanel from './status-panel'; import {FormattedMessage} from 'localization'; import {Provider} from 'cloud-providers'; import {cleanupExportImage, SetCloudProviderPayload} from 'actions'; 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; } `; interface SharingUrlProps { url: string; message?: string; } export const SharingUrl: React.FC = ({url, message = ''}) => { const [copied, setCopy] = useState(false); return ( {message}
setCopy(true)}>
); }; const nop = () => {}; const StyledShareMapModal = styled(StyledModalContent)` padding: 24px 72px 40px 72px; margin: 0 -72px -40px -72px; `; const StyledInnerDiv = styled.div` min-height: 500px; `; interface ShareMapUrlModalFactoryProps { isProviderLoading?: boolean; isReady?: boolean; onExport?: (provider: Provider) => void; cloudProviders?: Provider[]; currentProvider: string | null; providerError?: string; successInfo?: {shareUrl?: string; folderLink?: string}; onSetCloudProvider?: (provider: SetCloudProviderPayload) => void; onUpdateImageSetting: ImageModalContainerProps['onUpdateImageSetting']; cleanupExportImage: typeof cleanupExportImage; } export default function ShareMapUrlModalFactory() { const ShareMapUrlModal: React.FC = ({ isProviderLoading = false, isReady, onExport = nop, cloudProviders = [], currentProvider = null, providerError = null, successInfo = {}, onSetCloudProvider = nop, onUpdateImageSetting = nop, cleanupExportImage }) => { const {shareUrl, folderLink} = successInfo; const provider = currentProvider ? cloudProviders.find(p => p.name === currentProvider) : null; return (
{cloudProviders.map(cloudProvider => ( onExport(cloudProvider)} onSetCloudProvider={onSetCloudProvider} cloudProvider={cloudProvider} actionName="Upload" isSelected={cloudProvider.name === currentProvider} isConnected={Boolean(cloudProvider.getAccessToken())} isReady={isReady} /> ))}
{isProviderLoading || providerError ? ( ) : null} {shareUrl && (
Share Url
{provider && folderLink && ( )}
)}
); }; return ShareMapUrlModal; }