Interactive interface for browsing global, full-resolution satellite imagery
Show Tour no longer exists alert #1798
Benjamin Kingb2eae687148c
diff --git a/web/js/components/util/alert.js b/web/js/components/util/alert.jsindex e01fc0123..79a2719c6 100644--- a/web/js/components/util/alert.js+++ b/web/js/components/util/alert.js@@ -10,6 +10,22 @@ import { Portal } from 'react-portal';* @extends React.Component*/export default class AlertComponent extends React.Component {+ constructor(props) {+ super(props);+ if (props.timeout && props.onDismiss) {+ this.timeout = setTimeout(() => {+ props.onDismiss();+ }, props.timeout);+ }+ }+ componentDidMount() {+ this.mounted = true;+ }+ componentWillUnmount() {+ if (this.timeout) {+ clearTimeout(this.timeout);+ }+ }render() {return (<Portal node={document && document.getElementById('wv-content')}>@@ -26,7 +42,9 @@ export default class AlertComponent extends React.Component {'')}{this.props.message}- Read More...+ {this.props.onClick+ ? ' Read More...'+ : null}</span></div><div className="close-alert" onClick={this.props.onDismiss}>@@ -47,5 +65,6 @@ AlertComponent.propTypes = {message: PropTypes.string,onClick: PropTypes.func,onDismiss: PropTypes.func,+ timeout: PropTypes.number,title: PropTypes.string};diff --git a/web/js/containers/tour.js b/web/js/containers/tour.jsindex 9fbc1a0ed..0d16bdb54 100644--- a/web/js/containers/tour.js+++ b/web/js/containers/tour.js@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';import TourStart from '../components/tour/modal-tour-start';import TourInProgress from '../components/tour/modal-tour-in-progress';import TourComplete from '../components/tour/modal-tour-complete';+import AlertUtil from '../components/util/alert';+import {preloadPalettes,hasCustomTypePalette@@ -37,14 +39,16 @@ class Tour extends React.Component {const storyOrder = props.storyOrder;const stories = props.stories;const currentStoryIndex =- lodashFindIndex(storyOrder, { id: props.currentStoryId }) || null;+ lodashFindIndex(storyOrder, id => {+ return id === props.currentStoryId;+ }) || null;const currentStory =currentStoryIndex >= 0 ? stories[props.currentStoryId] : {};const steps = lodashGet(currentStory, 'steps') || [];-this.state = {- modalStart: true,- modalInProgress: false,+ modalStart: !props.currentStoryId,+ showSupportAlert: props.currentStoryId && currentStoryIndex === -1,+ modalInProgress: currentStoryIndex !== -1,modalComplete: false,currentStep: currentStoryIndex !== -1 ? 1 : 0,totalSteps: steps.length,@@ -60,6 +64,7 @@ class Tour extends React.Component {this.toggleModalComplete = this.toggleModalComplete.bind(this);this.incrementStep = this.incrementStep.bind(this);this.decreaseStep = this.decreaseStep.bind(this);+ if (currentStory && currentStoryIndex !== -1) this.fetchMetadata(currentStory, 0);}toggleModalStart(e) {e.preventDefault();@@ -222,6 +227,19 @@ class Tour extends React.Component {this.setState(DEFAULT_STATE);this.props.endTour();}+ renderSupportAlert() {+ return (+ <AlertUtil+ isOpen={true}+ timeout={10000}+ onDismiss={() => {+ this.props.endTour();+ }}+ iconClassName=' '+ message='Sorry, this tour is no longer supported.'+ />+ );+ }render() {const {stories,@@ -248,11 +266,15 @@ class Tour extends React.Component {modalStart,currentStoryIndex,description,- isLoadingMeta+ isLoadingMeta,+ showSupportAlert} = this.state;if (screenWidth < 740 || screenHeight < 450) {endTour();}+ if (showSupportAlert) {+ return this.renderSupportAlert();+ }if (stories && isActive) {if (!modalStart && !modalInProgress && !modalComplete) {this.setState({ modalStart: true });diff --git a/web/js/location.js b/web/js/location.jsindex 28a8897fb..be46a4532 100644--- a/web/js/location.js+++ b/web/js/location.js@@ -3,7 +3,10 @@ import { encode } from './modules/link/util';// legacy crutches// import { getLayersParameterSetup } from './modules/layers/util';import { serializeDate, tryCatchDate } from './modules/date/util';-import { checkTourBuildTimestamp } from './modules/tour/util';+import {+ checkTourBuildTimestamp,+ mapLocationToTourState+} from './modules/tour/util';import { getMapParameterSetup } from './modules/map/util';import { eventParse, serializeEvent } from './modules/natural-events/util';import { mapLocationToCompareState } from './modules/compare/util';@@ -75,6 +78,12 @@ export const mapLocationToState = (state, location) => {state,config);+ stateFromLocation = mapLocationToTourState(+ parameters,+ stateFromLocation,+ state,+ config+ );// one level deep merge of newState with defaultStatefor (var key in stateFromLocation) {diff --git a/web/js/modules/tour/util.js b/web/js/modules/tour/util.jsindex 329b00000..7d8bd5d6f 100644--- a/web/js/modules/tour/util.js+++ b/web/js/modules/tour/util.js@@ -1,5 +1,32 @@import googleTagManager from 'googleTagManager';import util from '../../util/util';+import update from 'immutability-helper';+/**+ * Update Tour state when location-pop action occurs+ *+ * @param {Object} parameters | parameters parsed from permalink+ * @param {Object} stateFromLocation | State derived from permalink parsers+ * @param {Object} state | initial state before location POP action+ * @param {Object} config+ */+export function mapLocationToTourState(+ parameters,+ stateFromLocation,+ state,+ config+) {+ if (parameters.tr) {+ stateFromLocation = update(stateFromLocation, {+ tour: { active: { $set: true } }+ });+ } else {+ stateFromLocation = update(stateFromLocation, {+ tour: { active: { $set: false } }+ });+ }+ return stateFromLocation;+}+/*** Determine if tour should be shown based on* user's browser and is 'hidestore' key is in localStorage