Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Show notification #1805

Benjamin King9c075f785dd4
diff --git a/web/js/components/alert/alert.js b/web/js/components/alert/alert.js
deleted file mode 100644
index 41c793234..000000000
--- a/web/js/components/alert/alert.js
+++ /dev/null
@@ -1,37 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import { Alert } from 'reactstrap';
-
-class TourAlert extends React.Component {
- constructor(props) {
- super(props);
-
- this.state = {
- visible: props.visible,
- message: props.message
- };
-
- this.onDismiss = this.onDismiss.bind(this);
- }
-
- onDismiss() {
- this.setState({ visible: false });
- }
-
- render() {
- return (
- <div>
- <Alert className="wv-alert" isOpen={this.state.visible} toggle={this.onDismiss}>
- <p>{this.state.message}</p>
- </Alert>
- </div>
- );
- };
-}
-
-TourAlert.propTypes = {
- visible: PropTypes.bool.isRequired,
- message: PropTypes.string
-};
-
-export default TourAlert;
diff --git a/web/js/components/tour/alert.js b/web/js/components/tour/alert.js
deleted file mode 100644
index 84b031489..000000000
--- a/web/js/components/tour/alert.js
+++ /dev/null
@@ -1,56 +0,0 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import TourAlert from '../components/alert/alert';
-import util from '../util/util';
-
-export function alertUi(ui) {
- var self = {};
-
- var init = function() {
- self.reactComponent = ReactDOM.render(
- React.createElement(TourAlert, getInitialAlertProps()),
- document.getElementById('wv-alerts')
- );
- };
-
- var getInitialAlertProps = function() {
- return {
- visible: false,
- showTourAlert: self.showTourAlert,
- message: null
- };
- };
-
- self.showTourAlert = function(e) {
- if (!util.browser.localStorage) return;
- var hideTour = localStorage.getItem('hideTour');
- if (!hideTour) return;
-
- self.reactComponent.setState({
- visible: true,
- message: 'To view these tours again, click the \'Explore Worldview\' link in the “i” menu.'
- });
-
- setTimeout(() => {
- self.reactComponent.setState({
- visible: false
- });
- }, 10000);
- };
-
- self.noTourAvailable = function(e) {
- self.reactComponent.setState({
- visible: true,
- message: 'Sorry, this tour is no longer supported.'
- });
-
- setTimeout(() => {
- self.reactComponent.setState({
- visible: false
- });
- }, 10000);
- };
-
- init();
- return self;
-}
diff --git a/web/js/containers/tour.js b/web/js/containers/tour.js
index 0d16bdb54..9bf193772 100644
--- a/web/js/containers/tour.js
+++ b/web/js/containers/tour.js
@@ -21,18 +21,6 @@ import update from 'immutability-helper';
import { history } from '../main';
import util from '../util/util';
-const DEFAULT_STATE = {
- modalStart: true,
- modalInProgress: false,
- modalComplete: false,
- currentStep: 0,
- totalSteps: 0,
- metaLoaded: false,
- isLoadingMeta: false,
- currentStory: {},
- currentStoryId: '',
- currentStoryIndex: -1
-};
class Tour extends React.Component {
constructor(props) {
super(props);
@@ -48,6 +36,7 @@ class Tour extends React.Component {
this.state = {
modalStart: !props.currentStoryId,
showSupportAlert: props.currentStoryId && currentStoryIndex === -1,
+ showDisabledAlert: false,
modalInProgress: currentStoryIndex !== -1,
modalComplete: false,
currentStep: currentStoryIndex !== -1 ? 1 : 0,
@@ -56,7 +45,8 @@ class Tour extends React.Component {
isLoadingMeta: false,
currentStory,
currentStoryId: props.currentStoryId,
- currentStoryIndex: currentStoryIndex
+ currentStoryIndex: currentStoryIndex,
+ tourEnded: false
};
this.toggleModalStart = this.toggleModalStart.bind(this);
@@ -224,22 +214,34 @@ class Tour extends React.Component {
}
endTour(e) {
e.preventDefault();
- this.setState(DEFAULT_STATE);
- this.props.endTour();
+ if (!this.state.showDisabledAlert) {
+ this.props.endTour();
+ } else {
+ this.setState({ tourEnded: true });
+ }
}
renderSupportAlert() {
return (
<AlertUtil
isOpen={true}
timeout={10000}
- onDismiss={() => {
- this.props.endTour();
- }}
+ onDismiss={this.props.endTour}
iconClassName=' '
message='Sorry, this tour is no longer supported.'
/>
);
}
+ renderDisableAlert() {
+ return (
+ <AlertUtil
+ isOpen={true}
+ timeout={10000}
+ onDismiss={this.props.endTour}
+ iconClassName=' '
+ message="To view these tours again, click the 'Explore Worldview' link in the “i” menu."
+ />
+ );
+ }
render() {
const {
stories,
@@ -267,11 +269,15 @@ class Tour extends React.Component {
currentStoryIndex,
description,
isLoadingMeta,
- showSupportAlert
+ showSupportAlert,
+ showDisabledAlert,
+ tourEnded
} = this.state;
if (screenWidth < 740 || screenHeight < 450) {
endTour();
}
+ if (showDisabledAlert && tourEnded) return this.renderDisableAlert();
+
if (showSupportAlert) {
return this.renderSupportAlert();
}
@@ -297,8 +303,14 @@ class Tour extends React.Component {
toggleModalComplete={this.toggleModalComplete}
selectTour={this.selectTour.bind(this)}
showTourAlert={showTourAlert}
- hideTour={hideTour}
- showTour={showTour}
+ hideTour={() => {
+ hideTour();
+ this.setState({ showDisabledAlert: true });
+ }}
+ showTour={() => {
+ showTour();
+ this.setState({ showDisabledAlert: false });
+ }}
endTour={this.endTour.bind(this)}
/>
) : modalInProgress ? (