Interactive interface for browsing global, full-resolution satellite imagery
disable embed nav link tab on data download and tour active, re use tooltip in hover-tooltip
Ed Platoab32aaa856a2
diff --git a/web/js/components/location-search/location-search-modal.js b/web/js/components/location-search/location-search-modal.jsindex c0ce93127..fab1819ae 100644--- a/web/js/components/location-search/location-search-modal.js+++ b/web/js/components/location-search/location-search-modal.js@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';import React, { Component } from 'react';import { connect } from 'react-redux';import {- Button, InputGroup, InputGroupAddon, UncontrolledTooltip,+ Button, InputGroup, InputGroupAddon,} from 'reactstrap';import {debounce as lodashDebounce,@@ -12,6 +12,7 @@ import googleTagManager from 'googleTagManager';import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';import SearchBox from './location-search-input';import Alert from '../util/alert';+import HoverTooltip from '../util/hover-tooltip';import { getCoordinateFixedPrecision, isValidCoordinates } from './util';import {clearSuggestions,@@ -231,18 +232,14 @@ class LocationSearchModal extends Component {});}- // render hover tooltiprenderTooltip = (buttonId, labelText) => {const { isMobile } = this.props;- return !isMobile && (- <UncontrolledTooltip- trigger="hover"+ return (+ <HoverTooltip+ isMobile={isMobile}+ labelText={labelText}target={buttonId}- boundariesElement="window"- placement="bottom"- >- {labelText}- </UncontrolledTooltip>+ />);}diff --git a/web/js/components/util/hover-tooltip.js b/web/js/components/util/hover-tooltip.jsnew file mode 100644index 000000000..a4d52cb63--- /dev/null+++ b/web/js/components/util/hover-tooltip.js@@ -0,0 +1,40 @@+import React from 'react';+import PropTypes from 'prop-types';+import {+ UncontrolledTooltip,+} from 'reactstrap';++/*+ *+ * @class HoverTooltip+ * @extends React.Component+ */+const HoverTooltip = (props) => {+ const {+ isMobile, labelText, placement, target,+ } = props;++ return !isMobile && (+ <UncontrolledTooltip+ trigger="hover"+ target={target}+ boundariesElement="window"+ placement={placement}+ >+ {labelText}+ </UncontrolledTooltip>+ );+};++HoverTooltip.defaultProps = {+ placement: 'bottom',+};++HoverTooltip.propTypes = {+ isMobile: PropTypes.bool,+ labelText: PropTypes.string,+ placement: PropTypes.string,+ target: PropTypes.string,+};++export default HoverTooltip;diff --git a/web/js/containers/embed.js b/web/js/containers/embed.jsindex 27812df70..c650db052 100644--- a/web/js/containers/embed.js+++ b/web/js/containers/embed.js@@ -1,10 +1,11 @@import React from 'react';import PropTypes from 'prop-types';import { connect } from 'react-redux';-import { Button, UncontrolledTooltip } from 'reactstrap';+import { Button } from 'reactstrap';import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';import { getPermalink } from '../modules/link/util';import getSelectedDate from '../modules/date/selectors';+import HoverTooltip from '../components/util/hover-tooltip';import history from '../main';class Embed extends React.Component {@@ -22,20 +23,6 @@ class Embed extends React.Component {this.setState({ showOverlay: false });}- renderTooltip = (buttonId, labelText) => {- const { isMobile } = this.props;- return !isMobile && (- <UncontrolledTooltip- trigger="hover"- target={buttonId}- boundariesElement="window"- placement="bottom"- >- {labelText}- </UncontrolledTooltip>- );- }-newTabLink() {const { selectedDate } = this.props;const queryString = history.location.search || '';@@ -44,6 +31,7 @@ class Embed extends React.Component {}renderEmbedLinkBtn() {+ const { isMobile } = this.props;const buttonId = 'wv-embed-button';const labelText = 'Open new tab with content in Worldview';return (@@ -53,7 +41,11 @@ class Embed extends React.Component {aria-label={labelText}onClick={() => this.newTabLink()}>- {this.renderTooltip(buttonId, labelText)}+ <HoverTooltip+ isMobile={isMobile}+ labelText={labelText}+ target={buttonId}+ /><FontAwesomeIcon icon="external-link-alt" size="2x" fixedWidth /></Button>);diff --git a/web/js/containers/share.js b/web/js/containers/share.jsindex 69adb7c6a..d70e358c1 100644--- a/web/js/containers/share.js+++ b/web/js/containers/share.js@@ -19,6 +19,7 @@ import ShareToolTips from '../components/toolbar/share/tooltips';import { getPermalink, getShareLink, wrapWithIframe } from '../modules/link/util';import getSelectedDate from '../modules/date/selectors';import Checkbox from '../components/util/checkbox';+import HoverTooltip from '../components/util/hover-tooltip';import { requestShortLink } from '../modules/link/actions';import history from '../main';@@ -156,22 +157,37 @@ class ShareLinkContainer extends Component {}renderNavTabs = () => {- const {- activeTab,- } = this.state;-+ const { embedDisableNavLink, isMobile } = this.props;+ const { activeTab } = this.state;+ const isDisabled = {+ embed: embedDisableNavLink,+ };return (<Nav tabs>- {SOCIAL_SHARE_TABS.map((type) => (- <NavItem key={type}>- <NavLink- onClick={() => this.setActiveTab(type)}- active={activeTab === type}- >- {lodashStartCase(type)}- </NavLink>- </NavItem>- ))}+ {SOCIAL_SHARE_TABS.map((type) => {+ const navTitle = lodashStartCase(type);+ const navDisabledMessage = `${navTitle} is not available when the current application features are in use.`;+ const navTitleClass = `${navTitle}-nav`;+ return (+ <NavItem key={type} className={navTitleClass}>+ <NavLink+ onClick={() => this.setActiveTab(type)}+ active={activeTab === type}+ disabled={isDisabled[type]}+ >+ {isDisabled[type] && (+ <HoverTooltip+ isMobile={isMobile}+ labelText={navDisabledMessage}+ target={`.${navTitleClass}`}+ placement="top"+ />+ )}+ {navTitle}+ </NavLink>+ </NavItem>+ );+ })}</Nav>);}@@ -309,9 +325,15 @@ class ShareLinkContainer extends Component {}function mapStateToProps(state) {- const { config, shortLink } = state;+ const {+ browser, config, shortLink, sidebar, tour,+ } = state;+ const isMobile = browser.lessThan.medium;+ const embedDisableNavLink = sidebar.activeTab === 'download' || tour.active;return {+ embedDisableNavLink,+ isMobile,shortLink,selectedDate: getSelectedDate(state),mock:@@ -332,6 +354,8 @@ export default connect()(ShareLinkContainer);ShareLinkContainer.propTypes = {+ embedDisableNavLink: PropTypes.bool,+ isMobile: PropTypes.bool,mock: PropTypes.string,requestShortLinkAction: PropTypes.func,selectedDate: PropTypes.object,diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.jsindex f63132846..4c04b62ca 100644--- a/web/js/containers/toolbar.js+++ b/web/js/containers/toolbar.js@@ -1,7 +1,7 @@import React, { Component } from 'react';import PropTypes from 'prop-types';import { connect } from 'react-redux';-import { ButtonToolbar, Button, UncontrolledTooltip } from 'reactstrap';+import { ButtonToolbar, Button } from 'reactstrap';import {get as lodashGet,find as lodashFind,@@ -16,6 +16,7 @@ import ImageDownload from './image-download';import Projection from './projection';import InfoList from './info';import ShareLinks from './share';+import HoverTooltip from '../components/util/hover-tooltip';import ErrorBoundary from './error-boundary';import {requestNotifications,@@ -164,15 +165,12 @@ class toolbarContainer extends Component {renderTooltip = (buttonId, labelText) => {const { isMobile } = this.props;- return !isMobile && (- <UncontrolledTooltip- trigger="hover"+ return (+ <HoverTooltip+ isMobile={isMobile}+ labelText={labelText}target={buttonId}- boundariesElement="window"- placement="bottom"- >- {labelText}- </UncontrolledTooltip>+ />);}diff --git a/web/js/modules/tour/util.js b/web/js/modules/tour/util.jsindex ac78c9cca..e0280b536 100644--- a/web/js/modules/tour/util.js+++ b/web/js/modules/tour/util.js@@ -18,7 +18,8 @@ export function mapLocationToTourState(state,config,) {- if (parameters.tr) {+ const isEmbedModeActive = parameters.em && parameters.em === 'true';+ if (parameters.tr && !isEmbedModeActive) {stateFromLocation = update(stateFromLocation, {tour: { active: { $set: true } },});