Interactive interface for browsing global, full-resolution satellite imagery
update tooltip target, refactor reuse rendering in share, update e2e
Ed Platoe18a844b3c1c
diff --git a/e2e/reuseables/selectors.js b/e2e/reuseables/selectors.jsindex c75ac70fa..ddd589f68 100644--- a/e2e/reuseables/selectors.js+++ b/e2e/reuseables/selectors.js@@ -162,8 +162,8 @@ module.exports = {// socialsocialToolbar: '#toolbar_share_link',- socialCopyLinkButton: '#wv-link-button',- socialLinkInput: '#permalink_content',+ socialCopyLinkButton: '#wv-share-button',+ socialLinkInput: '#permalink-content-link',// Location SearchlocationSearchComponent: '.location-search-component',diff --git a/web/js/components/toolbar/share/tooltips.js b/web/js/components/toolbar/share/tooltips.jsindex f5e48fede..2ae819e2b 100644--- a/web/js/components/toolbar/share/tooltips.js+++ b/web/js/components/toolbar/share/tooltips.js@@ -19,16 +19,23 @@ class ShareToolTips extends PureComponent {}componentDidUpdate(prevProps) {- const { tooltipToggleTime, tooltipErrorTime } = this.props;+ const { activeTab, tooltipToggleTime, tooltipErrorTime } = this.props;const toolTipChange = tooltipToggleTime !== prevProps.tooltipToggleTime;const tooltipErrorChange = tooltipErrorTime !== prevProps.tooltipErrorTime;- if (toolTipChange || tooltipErrorChange) {+ const activeTabChange = activeTab !== prevProps.activeTab;+ if (activeTabChange) {+ this.clearPendingTimeouts();+ this.updateToolTipState(false, false);+ } else if (toolTipChange || tooltipErrorChange) {this.updateToolTipState(toolTipChange, tooltipErrorChange);}}componentWillUnmount() {- // clear pending timeouts+ this.clearPendingTimeouts();+ }++ clearPendingTimeouts = () => {clearTimeout(this.showCopiedToolTipTimeout);clearTimeout(this.showErrorTimeout);}@@ -57,16 +64,18 @@ class ShareToolTips extends PureComponent {return (<><Tooltip- placement="left"+ placement="right"isOpen={showErrorTooltip}- target="permalink_content"+ target=".share-body"+ fade={false}>Link cannot be shortened at this time.</Tooltip><Tooltipplacement="right"isOpen={showCopiedToolTip}- target="copy-to-clipboard-button"+ target=".share-body"+ fade={false}>Copied!</Tooltip>@@ -76,6 +85,7 @@ class ShareToolTips extends PureComponent {}ShareToolTips.propTypes = {+ activeTab: PropTypes.string,tooltipErrorTime: PropTypes.number,tooltipToggleTime: PropTypes.number,};diff --git a/web/js/containers/share.js b/web/js/containers/share.jsindex 2235ad4a4..fb3c6156a 100644--- a/web/js/containers/share.js+++ b/web/js/containers/share.js@@ -3,6 +3,9 @@ import PropTypes from 'prop-types';import { connect } from 'react-redux';import googleTagManager from 'googleTagManager';import copy from 'copy-to-clipboard';+import {+ startCase as lodashStartCase,+} from 'lodash';import {InputGroupAddon,Input,@@ -32,6 +35,8 @@ const getShortenRequestString = (mock, permalink) => {);};+const SOCIAL_SHARE_TABS = ['link', 'embed', 'social'];+class ShareLinkContainer extends Component {constructor(props) {super(props);@@ -77,10 +82,10 @@ class ShareLinkContainer extends Component {}getShortLink = () => {- const { requestShortLink, mock } = this.props;+ const { requestShortLinkAction, mock } = this.props;const link = this.getPermalink();const location = getShortenRequestString(mock, link);- return requestShortLink(location);+ return requestShortLinkAction(location);}onToggleShorten = () => {@@ -157,26 +162,49 @@ class ShareLinkContainer extends Component {return (<Nav tabs>- <NavItem>- <NavLink onClick={() => this.setActiveTab('link')} active={activeTab === 'link'}>Link</NavLink>- </NavItem>- <NavItem>- <NavLink onClick={() => this.setActiveTab('embed')} active={activeTab === 'embed'}>Embed</NavLink>- </NavItem>- <NavItem>- <NavLink onClick={() => this.setActiveTab('social')} active={activeTab === 'social'}>Social</NavLink>- </NavItem>+ {SOCIAL_SHARE_TABS.map((type) => (+ <NavItem key={type}>+ <NavLink+ onClick={() => this.setActiveTab(type)}+ active={activeTab === type}+ >+ {lodashStartCase(type)}+ </NavLink>+ </NavItem>+ ))}</Nav>);}+ renderInputGroup = (value, type) => (+ <InputGroup>+ <Input+ type="text"+ value={value}+ name={`permalink-content-${type}`}+ id={`permalink-content-${type}`}+ onChange={(e) => {+ e.preventDefault();+ }}+ />+ <InputGroupAddon addonType="append">+ <Button+ id={`copy-to-clipboard-button-${type}`}+ onClick={() => this.copyToClipboard(value)}+ onTouchEnd={() => this.copyToClipboard(value)}+ >+ COPY+ </Button>+ </InputGroupAddon>+ </InputGroup>+ )+renderLinkTab = () => {const { shortLink } = this.props;const {activeTab,isShort,} = this.state;-const value = shortLink.isLoading && isShort? 'Please wait...': isShort@@ -191,7 +219,6 @@ class ShareLinkContainer extends Component {<><p>Copy URL to share link.-</p>{' '}<Checkbox@@ -201,26 +228,7 @@ class ShareLinkContainer extends Component {checked={isShort}disabled={!shortLink.isLoading}/>- <InputGroup>- <Input- type="text"- value={value}- name="permalink_content"- id="permalink_content"- onChange={(e) => {- e.preventDefault();- }}- />- <InputGroupAddon addonType="append">- <Button- id="copy-to-clipboard-button"- onClick={() => this.copyToClipboard(value)}- onTouchEnd={() => this.copyToClipboard(value)}- >- COPY- </Button>- </InputGroupAddon>- </InputGroup>+ {this.renderInputGroup(value, 'link')}</>)}</TabPane>@@ -231,7 +239,6 @@ class ShareLinkContainer extends Component {const {activeTab,} = this.state;-const embedValue = this.getPermalink(true);return (@@ -245,26 +252,7 @@ class ShareLinkContainer extends Component {{' '}for a guide.</p>- <InputGroup>- <Input- type="text"- value={embedValue}- name="permalink_content"- id="permalink_content"- onChange={(e) => {- e.preventDefault();- }}- />- <InputGroupAddon addonType="append">- <Button- id="copy-to-clipboard-button"- onClick={() => this.copyToClipboard(embedValue)}- onTouchEnd={() => this.copyToClipboard(embedValue)}- >- COPY- </Button>- </InputGroupAddon>- </InputGroup>+ {this.renderInputGroup(embedValue, 'embed')}</>)}</TabPane>@@ -301,6 +289,7 @@ class ShareLinkContainer extends Component {<><div className="share-body"><ShareToolTips+ activeTab={activeTab}tooltipErrorTime={tooltipErrorTime}tooltipToggleTime={tooltipToggleTime}/>@@ -319,10 +308,10 @@ class ShareLinkContainer extends Component {}function mapStateToProps(state) {- const { config } = state;+ const { config, shortLink } = state;return {- shortLink: state.shortLink,+ shortLink,selectedDate: getSelectedDate(state),mock:config.parameters && config.parameters.shorten@@ -331,7 +320,7 @@ function mapStateToProps(state) {};}const mapDispatchToProps = (dispatch) => ({- requestShortLink: (location, options) => dispatch(+ requestShortLinkAction: (location, options) => dispatch(requestShortLink(location, 'application/json', null, options),),});@@ -343,7 +332,7 @@ export default connect(ShareLinkContainer.propTypes = {mock: PropTypes.string,- requestShortLink: PropTypes.func,+ requestShortLinkAction: PropTypes.func,selectedDate: PropTypes.object,shortLink: PropTypes.object,};diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.jsindex 8bcae39eb..f63132846 100644--- a/web/js/containers/toolbar.js+++ b/web/js/containers/toolbar.js@@ -178,7 +178,7 @@ class toolbarContainer extends Component {renderShareButton() {const { faSize, openModal, isDistractionFreeModeActive } = this.props;- const buttonId = 'wv-link-button';+ const buttonId = 'wv-share-button';const labelText = 'Share this map';return !isDistractionFreeModeActive && (<Buttondiff --git a/web/js/modules/embed/actions.js b/web/js/modules/embed/actions.jsdeleted file mode 100644index 77ce6d7a4..000000000--- a/web/js/modules/embed/actions.js+++ /dev/null@@ -1,24 +0,0 @@-// import googleTagManager from 'googleTagManager';--// import { TOGGLE_EMBED_MODE } from './constants';-// import { CLOSE as CLOSE_MODAL } from '../modal/constants';--// export default function toggleDistractionFreeMode() {-// return (dispatch, getState) => {-// const { modal, ui } = getState();-// const { isDistractionFreeModeActive } = ui;-// const modalIsOpen = modal.isOpen;-// if (!isDistractionFreeModeActive) {-// googleTagManager.pushEvent({-// event: 'init_distraction_free_mode',-// });-// }-// dispatch({-// type: TOGGLE_EMBED_MODE,-// isDistractionFreeModeActive: !isDistractionFreeModeActive,-// });-// if (!isDistractionFreeModeActive && modalIsOpen) {-// dispatch({ type: CLOSE_MODAL });-// }-// };-// }diff --git a/web/js/modules/embed/constants.js b/web/js/modules/embed/constants.jsdeleted file mode 100644index bf449aa8f..000000000--- a/web/js/modules/embed/constants.js+++ /dev/null@@ -1,2 +0,0 @@-// eslint-disable-next-line import/prefer-default-export-// export const TOGGLE_EMBED_MODE = 'EMBED/TOGGLE_EMBED_MODE';diff --git a/web/js/modules/embed/reducers.js b/web/js/modules/embed/reducers.jsindex 00c13902f..1ee7b9c7c 100644--- a/web/js/modules/embed/reducers.js+++ b/web/js/modules/embed/reducers.js@@ -1,16 +1,9 @@-// import { assign as lodashAssign } from 'lodash';-// import { TOGGLE_EMBED_MODE } from './constants';-export const embedState = {isEmbedModeActive: false,};export default function embedReducers(state = embedState, action) {switch (action.type) {- // case TOGGLE_EMBED_MODE:- // return lodashAssign({}, state, {- // isEmbedModeActive: !state.isEmbedModeActive,- // });default:return state;}diff --git a/web/js/modules/embed/util.js b/web/js/modules/embed/util.jsindex 9f9e55c23..ecf1a022b 100644--- a/web/js/modules/embed/util.js+++ b/web/js/modules/embed/util.js@@ -9,7 +9,6 @@ import { getOverlayGroups } from '../layers/util';** @param {Object} parameters | parameters parsed from permalink* @param {Object} stateFromLocation | State derived from permalink parsers- * @param {Object} state*/// eslint-disable-next-line import/prefer-default-exportexport function mapLocationToEmbedState(