Interactive interface for browsing global, full-resolution satellite imagery
add ui state to related components
Edward Platoe013575982b8
diff --git a/web/js/components/map/ol-coordinates.js b/web/js/components/map/ol-coordinates.jsindex 1a1b97732..56a4eae70 100644--- a/web/js/components/map/ol-coordinates.js+++ b/web/js/components/map/ol-coordinates.js@@ -1,5 +1,6 @@import React from 'react';import PropTypes from 'prop-types';+import { connect } from 'react-redux';import Coordinates from './coordinates';import util from '../../util/util';import { transform } from 'ol/proj';@@ -77,7 +78,7 @@ class OlCoordinates extends React.Component {}return (- <div>+ <div style={{ display: this.props.isDistractionFreeModeActive ? 'none' : 'block' }}><Coordinatesformat={this.state.format}latitude={this.state.latitude}@@ -90,8 +91,18 @@ class OlCoordinates extends React.Component {}}+function mapStateToProps(state) {+ return {+ isDistractionFreeModeActive: state.ui.isDistractionFreeModeActive+ };+}+OlCoordinates.propTypes = {mouseEvents: PropTypes.object.isRequired};-export default OlCoordinates;+// export default OlCoordinates;++export default connect(+ mapStateToProps+)(OlCoordinates);diff --git a/web/js/components/measure-tool/measure-button.js b/web/js/components/measure-tool/measure-button.jsindex 2dd7279f1..eab283ab9 100644--- a/web/js/components/measure-tool/measure-button.js+++ b/web/js/components/measure-tool/measure-button.js@@ -67,6 +67,7 @@ class MeasureButton extends React.Component {/>}<Button+ style={{ display: this.props.isDistractionFreeModeActive ? 'none' : 'block' }}id="wv-measure-button"className="wv-measure-button wv-toolbar-button"title="Measure distances & areas"@@ -82,7 +83,8 @@ class MeasureButton extends React.Component {const mapStateToProps = (state, ownProps) => {return {- isActive: state.measure.isActive+ isActive: state.measure.isActive,+ isDistractionFreeModeActive: state.ui.isDistractionFreeModeActive};};const mapDispatchToProps = dispatch => ({diff --git a/web/js/containers/sidebar/sidebar.js b/web/js/containers/sidebar/sidebar.jsindex 2824bc11d..8722154d7 100644--- a/web/js/containers/sidebar/sidebar.js+++ b/web/js/containers/sidebar/sidebar.js@@ -196,11 +196,10 @@ class Sidebar extends React.Component {ref={el => {this.sideBarCase = el;}}- style={- isCollapsed- ? { maxHeight: '0' }- : { maxHeight: screenHeight + 'px' }- }+ style={{+ maxHeight: isCollapsed ? '0' : screenHeight + 'px',+ display: this.props.isDistractionFreeModeActive ? 'none' : 'block'+ }}onWheel={wheelCallBack}><NavCase@@ -257,9 +256,11 @@ function mapStateToProps(state) {modal,measure,animation,- events+ events,+ ui} = state;const { screenHeight } = browser;+ const isDistractionFreeModeActive = ui.isDistractionFreeModeActive;const { activeTab, isCollapsed, mobileCollapsed } = sidebar;const { activeString } = compare;const numberOfLayers = getLayers(layers[activeString], {}, state).length;@@ -279,7 +280,8 @@ function mapStateToProps(state) {isDataDisabled: events.isAnimatingToEvent,isCollapsed: isMobile ? mobileCollapsed : (isCollapsed || shouldBeCollapsed),tabTypes,- config+ config,+ isDistractionFreeModeActive};}const mapDispatchToProps = dispatch => ({diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 8b2a7fed9..2be638279 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -897,7 +897,7 @@ class Timeline extends React.Component {const isTimelineHidden = timelineHidden || hideTimeline;const chevronDirection = isTimelineHidden ? 'left' : 'right';return (- <div className="timeline-container">+ <div className="timeline-container" style={{ display: this.props.isDistractionFreeModeActive ? 'none' : 'block' }}>{initialLoadComplete? <ErrorBoundary>{isSmallScreen@@ -1120,7 +1120,8 @@ function mapStateToProps(state) {animation,sidebar,modal,- tour+ tour,+ ui} = state;let {customSelected,@@ -1137,6 +1138,7 @@ function mapStateToProps(state) {const { screenWidth, lessThan } = browser;const { isCompareA, activeString } = compare;const isCompareModeActive = compare.active;+ const isDistractionFreeModeActive = ui.isDistractionFreeModeActive;const isSmallScreen = lessThan.medium;let hasSubdailyLayers = hasSubDaily(layers[compare.activeString]);@@ -1223,7 +1225,8 @@ function mapStateToProps(state) {isDataDownload: sidebar.activeTab === 'download',isAnimationPlaying: animation.isPlaying,isGifActive: animation.gifActive,- timelineCustomModalOpen+ timelineCustomModalOpen,+ isDistractionFreeModeActive};}diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.jsindex 10f260692..e3062970d 100644--- a/web/js/containers/toolbar.js+++ b/web/js/containers/toolbar.js@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';import { connect } from 'react-redux';import { ButtonToolbar, Button } from 'reactstrap';import { openCustomContent, onToggle } from '../modules/modal/actions';+import { toggleDistractionFreeMode } from '../modules/ui/actions';import ImageDownload from './image-download';import Projection from './projection';import InfoList from './info';@@ -138,74 +139,91 @@ class toolbarContainer extends Component {: ' wv-status-hide';return (<ErrorBoundary>- <ButtonToolbar id="wv-toolbar" className={'wv-toolbar'}>- <Button- id="wv-link-button"- className="wv-toolbar-button"- title="Share this map"- onClick={() =>- openModal(- 'TOOLBAR_SHARE_LINK',- CUSTOM_MODAL_PROPS.TOOLBAR_SHARE_LINK- )- }- >- <i className="fas fa-share-square fa-2x" />- </Button>- {config.ui && config.ui.projections ? (- <Button- id="wv-proj-button"+ <ButtonToolbar+ id="wv-toolbar"+ className={'wv-toolbar'}+ >+ {/* add custom distraction free mode icon, template, modal ? */}+ { this.props.isDistractionFreeModeActive+ ? <Button+ id="wv-link-button"className="wv-toolbar-button"- title="Switch projection"- onClick={() =>- openModal(- 'TOOLBAR_PROJECTION',- CUSTOM_MODAL_PROPS.TOOLBAR_PROJECTION- )- }+ title="Toggle Distraction Free Mode"+ onClick={() => this.props.toggleDistractionFreeMode() }>- <i className="fas fa-globe-asia fa-2x" />{' '}+ <i className="fas fa-share-square fa-2x" /></Button>- ) : (- ''- )}- <Button- id="wv-image-button"- className={- isImageDownloadActive- ? 'wv-toolbar-button'- : 'wv-toolbar-button disabled'- }- disabled={!isImageDownloadActive}- title={- isCompareActive- ? 'You must exit comparison mode to use the snapshot feature'- : !isImageDownloadActive- ? 'You must exit data download mode to use the snapshot feature'- : 'Take a snapshot'- }- onClick={this.openImageDownload}- >- <i className="fa fa-camera fa-2x" />{' '}- </Button>- <Button- id="wv-info-button"- title="Information"- className={'wv-toolbar-button' + notificationClass}- onClick={() =>- openModal('TOOLBAR_INFO', CUSTOM_MODAL_PROPS.TOOLBAR_INFO)- }- data-content={notificationContentNumber}- >- <i className="fa fa-info-circle fa-2x" />{' '}- </Button>+ : <React.Fragment>+ <Button+ id="wv-link-button"+ className="wv-toolbar-button"+ title="Share this map"+ onClick={() =>+ openModal(+ 'TOOLBAR_SHARE_LINK',+ CUSTOM_MODAL_PROPS.TOOLBAR_SHARE_LINK+ )+ }+ >+ <i className="fas fa-share-square fa-2x" />+ </Button>+ {config.ui && config.ui.projections ? (+ <Button+ id="wv-proj-button"+ className="wv-toolbar-button"+ title="Switch projection"+ onClick={() =>+ openModal(+ 'TOOLBAR_PROJECTION',+ CUSTOM_MODAL_PROPS.TOOLBAR_PROJECTION+ )+ }+ >+ <i className="fas fa-globe-asia fa-2x" />{' '}+ </Button>+ ) : (+ ''+ )}+ <Button+ id="wv-image-button"+ className={+ isImageDownloadActive+ ? 'wv-toolbar-button'+ : 'wv-toolbar-button disabled'+ }+ disabled={!isImageDownloadActive}+ title={+ isCompareActive+ ? 'You must exit comparison mode to use the snapshot feature'+ : !isImageDownloadActive+ ? 'You must exit data download mode to use the snapshot feature'+ : 'Take a snapshot'+ }+ onClick={this.openImageDownload}+ >+ <i className="fa fa-camera fa-2x" />{' '}+ </Button>+ <Button+ id="wv-info-button"+ title="Information"+ className={'wv-toolbar-button' + notificationClass}+ onClick={() =>+ openModal('TOOLBAR_INFO', CUSTOM_MODAL_PROPS.TOOLBAR_INFO)+ }+ data-content={notificationContentNumber}+ >+ <i className="fa fa-info-circle fa-2x" />{' '}+ </Button>+ </React.Fragment>+ }</ButtonToolbar></ErrorBoundary>);}}function mapStateToProps(state) {- const { notifications, palettes, compare, map, layers, proj, data } = state;+ const { notifications, palettes, compare, map, layers, proj, data, ui } = state;+ const isDistractionFreeModeActive = ui.isDistractionFreeModeActive;const { number, type } = notifications;const activeString = compare.activeString;const activeLayersForProj = getLayers(@@ -235,10 +253,14 @@ function mapStateToProps(state) {lodashFind(layers[activeString], { id: 'Graticule' }) || {},'visible')- )+ ),+ isDistractionFreeModeActive};}const mapDispatchToProps = dispatch => ({+ toggleDistractionFreeMode: () => {+ dispatch(toggleDistractionFreeMode());+ },openModal: (key, customParams) => {dispatch(openCustomContent(key, customParams));},diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex 57bc30753..c7be685a0 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -30,6 +30,7 @@ import { measure } from './measure/ui';import { CALCULATE_RESPONSIVE_STATE } from 'redux-responsive';import { LOCATION_POP_ACTION } from '../redux-location-state-customs';import { CHANGE_PROJECTION } from '../modules/projection/constants';+import { TOGGLE_DISTRACTION_FREE_MODE } from '../modules/ui/constants';import { SELECT_DATE } from '../modules/date/constants';import { openCustomContent } from '../modules/modal/actions';import { CHANGE_UNITS, USE_GREAT_CIRCLE } from '../modules/measure/constants';@@ -97,6 +98,23 @@ export function mapui(models, config, store, ui) {*/const subscribeToStore = function(action) {switch (action.type) {+ case TOGGLE_DISTRACTION_FREE_MODE: {+ var map = self.selected;+ if (action.isDistractionFreeModeActive) {+ map.removeControl(map.wv.scaleImperial);+ map.removeControl(map.wv.scaleMetric);+ $('#' + map.getTarget() + ' .select-wrapper').hide();+ $('.wv-map-zoom-in').hide();+ $('.wv-map-zoom-out').hide();+ } else {+ map.addControl(map.wv.scaleImperial);+ map.addControl(map.wv.scaleMetric);+ $('#' + map.getTarget() + ' .select-wrapper').show();+ $('.wv-map-zoom-in').show();+ $('.wv-map-zoom-out').show();+ }+ return;+ }case layerConstants.ADD_LAYER: {const def = lodashFind(action.layers, { id: action.id });return addLayer(def);diff --git a/web/js/modules/combine-reducers.js b/web/js/modules/combine-reducers.jsindex c028c3c25..7d1199581 100644--- a/web/js/modules/combine-reducers.js+++ b/web/js/modules/combine-reducers.js@@ -40,6 +40,8 @@ import { imageDownloadReducer } from './image-download/reducers';import measureReducer from './measure/reducers';import { LOCATION_POP_ACTION } from '../redux-location-state-customs';+import uiReducers from './ui/reducers';+function lastAction(state = null, action) {return action;}@@ -127,7 +129,8 @@ const reducers = {notificationsRequest,lastAction: lastAction,location: locationReducer,- measure: measureReducer+ measure: measureReducer,+ ui: uiReducers};const appReducer = combineReducers(reducers);/**