Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

fix `react/prefer-stateless-function` errors

Jason Kentd96ecf0fb917
diff --git a/.eslintrc b/.eslintrc
index e1df34d3e..d8ba7d77b 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -117,7 +117,7 @@
// React rules overrides
"react/jsx-props-no-spreading": "warn",
"react/jsx-filename-extension": "off",
- "react/prefer-stateless-function": "warn", // 20 errors, consider fixing
+ // "react/prefer-stateless-function": "warn", // 20 errors, consider fixing
"react/sort-comp": "off",
"react/no-unused-state": "warn", // 38 errors
"react/no-unused-prop-types": "warn", // 66 errors
diff --git a/web/js/components/animation-widget/loop-button.js b/web/js/components/animation-widget/loop-button.js
index a3794dba1..2288ea770 100644
--- a/web/js/components/animation-widget/loop-button.js
+++ b/web/js/components/animation-widget/loop-button.js
@@ -8,23 +8,19 @@ import { faRetweet } from '@fortawesome/free-solid-svg-icons';
* @class LoopButton
* @extends React.Component
*/
-class LoopButton extends React.Component {
- render() {
- return (
- <a
- title={this.props.looping ? 'Stop Loop' : 'Loop video'}
- className={
- this.props.looping
+const LoopButton = (props) => (
+ <a
+ title={props.looping ? 'Stop Loop' : 'Loop video'}
+ className={
+ props.looping
? 'wv-loop-icon-case wv-icon-case active'
: 'wv-loop-icon-case wv-icon-case'
}
- onClick={this.props.onLoop}
- >
- <FontAwesomeIcon icon={faRetweet} className="wv-animation-widget-icon" />
- </a>
- );
- }
-}
+ onClick={props.onLoop}
+ >
+ <FontAwesomeIcon icon={faRetweet} className="wv-animation-widget-icon" />
+ </a>
+);
LoopButton.propTypes = {
looping: PropTypes.bool,
diff --git a/web/js/components/animation-widget/play-button.js b/web/js/components/animation-widget/play-button.js
index dba79d347..ca643e747 100644
--- a/web/js/components/animation-widget/play-button.js
+++ b/web/js/components/animation-widget/play-button.js
@@ -8,21 +8,20 @@ import { faPause, faPlay } from '@fortawesome/free-solid-svg-icons';
* @class PlayButton
* @extends React.Component
*/
-class PlayButton extends React.Component {
- render() {
- return (
- <a
- title={this.props.playing ? 'Pause video' : 'Play video'}
- className="wv-anim-play-case wv-icon-case"
- onClick={this.props.playing ? this.props.pause : this.props.play}
- >
- {this.props.playing
- ? <FontAwesomeIcon icon={faPause} className="wv-animation-widget-icon" />
- : <FontAwesomeIcon icon={faPlay} className="wv-animation-widget-icon" />}
- </a>
- );
- }
-}
+const PlayButton = (props) => {
+ const { playing, pause, play } = props;
+ return (
+ <a
+ title={playing ? 'Pause video' : 'Play video'}
+ className="wv-anim-play-case wv-icon-case"
+ onClick={playing ? pause : play}
+ >
+ {playing
+ ? <FontAwesomeIcon icon={faPause} className="wv-animation-widget-icon" />
+ : <FontAwesomeIcon icon={faPlay} className="wv-animation-widget-icon" />}
+ </a>
+ );
+};
PlayButton.propTypes = {
pause: PropTypes.func,
diff --git a/web/js/components/compare/alert.js b/web/js/components/compare/alert.js
index 6b5c77f2b..47e838972 100644
--- a/web/js/components/compare/alert.js
+++ b/web/js/components/compare/alert.js
@@ -1,35 +1,31 @@
import React from 'react';
-export class CompareAlertModalBody extends React.Component {
- render() {
- return (
- <div className="compare-dialog">
- <p>How to get started?</p>
- <ul>
- <li className="compare-dialog-list-item">
- <p>
- Select the respective tab (A or B) in order to update the layers
- and date of that state.
- </p>
- <img src="images/ab-tabs.png" />
- </li>
- <li className="compare-dialog-list-item">
- <p>
- There are now two time sliders on the timeline. You can click on
- the deactivated time slider to activate that state and change the
- date.
- </p>
- <img src="images/ab-picks.png" />
- </li>
- <li className="compare-dialog-list-item">
- <p>
- There are three compare modes. You can choose different modes
- using the selection at the bottom of the layer list.
- </p>
- <img src="images/ab-modes.png" />
- </li>
- </ul>
- </div>
- );
- }
-}
+export const CompareAlertModalBody = () => (
+ <div className="compare-dialog">
+ <p>How to get started?</p>
+ <ul>
+ <li className="compare-dialog-list-item">
+ <p>
+ Select the respective tab (A or B) in order to update the layers
+ and date of that state.
+ </p>
+ <img src="images/ab-tabs.png" />
+ </li>
+ <li className="compare-dialog-list-item">
+ <p>
+ There are now two time sliders on the timeline. You can click on
+ the deactivated time slider to activate that state and change the
+ date.
+ </p>
+ <img src="images/ab-picks.png" />
+ </li>
+ <li className="compare-dialog-list-item">
+ <p>
+ There are three compare modes. You can choose different modes
+ using the selection at the bottom of the layer list.
+ </p>
+ <img src="images/ab-modes.png" />
+ </li>
+ </ul>
+ </div>
+);
diff --git a/web/js/components/events/alert-body.js b/web/js/components/events/alert-body.js
index f8d008a36..69ed28f36 100644
--- a/web/js/components/events/alert-body.js
+++ b/web/js/components/events/alert-body.js
@@ -1,51 +1,47 @@
import React from 'react';
-export class EventsAlertModalBody extends React.Component {
- render() {
- return (
- <div className="event-alert-modal-body">
- <h3 className="wv-data-unavailable-header">
- Why can’t I see an event?
- </h3>
- <p>
- There are a variety of factors as to why you may not be seeing an
- event in Worldview at the moment.
- </p>
- <ul>
- <li>
- Satellite overpass may have occurred before the event. Check out
- subsequent days or try a different satellite/sensor which has a
- different overpass time.
- </li>
- <li>Cloud cover may obscure the event.</li>
- <li>
- Some events don’t appear on the day that they are reported, you may
- have to wait a day or two for an event to become visible. Try and
- scroll through the days to see an event’s progression and/or change
- the satellite/sensor. NOTE: Wildfire events are currently set to
- automatically display the next day, as fire events often do not
- appear in the satellite imagery on the day they are reported.
- </li>
- <li>
- The resolution of the imagery may be too coarse to see an event.
- </li>
- <li>
- There are normal swath data gaps in some of the imagery layers due
- to way the satellite orbits the Earth, and an event may have
- occurred in the data gap.
- </li>
- </ul>
- <p>
- This is currently an experimental feature and we are working closely
- with the provider of these events, the
- {' '}
- <a href="https://eonet.sci.gsfc.nasa.gov/" target="_blank" rel="noopener noreferrer">
- Earth Observatory Natural Event Tracker
- </a>
- , to refine this listing to only show events that are visible with our
- satellite imagery.
- </p>
- </div>
- );
- }
-}
+export const EventsAlertModalBody = () => (
+ <div className="event-alert-modal-body">
+ <h3 className="wv-data-unavailable-header">
+ Why can’t I see an event?
+ </h3>
+ <p>
+ There are a variety of factors as to why you may not be seeing an
+ event in Worldview at the moment.
+ </p>
+ <ul>
+ <li>
+ Satellite overpass may have occurred before the event. Check out
+ subsequent days or try a different satellite/sensor which has a
+ different overpass time.
+ </li>
+ <li>Cloud cover may obscure the event.</li>
+ <li>
+ Some events don’t appear on the day that they are reported, you may
+ have to wait a day or two for an event to become visible. Try and
+ scroll through the days to see an event’s progression and/or change
+ the satellite/sensor. NOTE: Wildfire events are currently set to
+ automatically display the next day, as fire events often do not
+ appear in the satellite imagery on the day they are reported.
+ </li>
+ <li>
+ The resolution of the imagery may be too coarse to see an event.
+ </li>
+ <li>
+ There are normal swath data gaps in some of the imagery layers due
+ to way the satellite orbits the Earth, and an event may have
+ occurred in the data gap.
+ </li>
+ </ul>
+ <p>
+ This is currently an experimental feature and we are working closely
+ with the provider of these events, the
+ {' '}
+ <a href="https://eonet.sci.gsfc.nasa.gov/" target="_blank" rel="noopener noreferrer">
+ Earth Observatory Natural Event Tracker
+ </a>
+ , to refine this listing to only show events that are visible with our
+ satellite imagery.
+ </p>
+ </div>
+);
diff --git a/web/js/components/image-download/notify.js b/web/js/components/image-download/notify.js
index dbc489022..ff94d2ed4 100644
--- a/web/js/components/image-download/notify.js
+++ b/web/js/components/image-download/notify.js
@@ -3,22 +3,20 @@ import PropTypes from 'prop-types';
import { ModalFooter } from 'reactstrap';
import Button from '../util/button';
-export class Notify extends React.Component {
- render() {
- const { bodyText, cancel, accept } = this.props;
- return (
- <>
- <div className="notify">
- <p>{bodyText}</p>
- </div>
- <ModalFooter>
- <Button className="cancel-notify" text="Cancel" onClick={cancel} />
- <Button className="accept-notify" text="OK" onClick={accept} />
- </ModalFooter>
- </>
- );
- }
-}
+export const Notify = (props) => {
+ const { bodyText, cancel, accept } = props;
+ return (
+ <>
+ <div className="notify">
+ <p>{bodyText}</p>
+ </div>
+ <ModalFooter>
+ <Button className="cancel-notify" text="Cancel" onClick={cancel} />
+ <Button className="accept-notify" text="OK" onClick={accept} />
+ </ModalFooter>
+ </>
+ );
+};
Notify.propTypes = {
accept: PropTypes.func,
diff --git a/web/js/components/layer/product-picker/category-cell.js b/web/js/components/layer/product-picker/category-cell.js
index 42c1048d7..9f8bd96ee 100644
--- a/web/js/components/layer/product-picker/category-cell.js
+++ b/web/js/components/layer/product-picker/category-cell.js
@@ -6,105 +6,103 @@ import PropTypes from 'prop-types';
* @class LayerList
* @extends React.Component
*/
-class CategoryCell extends React.Component {
- render() {
- const {
- category,
- measurementConfig,
- drawMeasurements,
- hasMeasurementSource,
- categoryType,
- } = this.props;
- const bgImage = category.image
- ? `images/layers/categories/${category.image}`
- : '';
- const categoryBgImage = bgImage
- ? {
- backgroundImage: `url(${bgImage})`,
- }
- : {};
+const CategoryCell = (props) => {
+ const {
+ category,
+ measurementConfig,
+ drawMeasurements,
+ hasMeasurementSource,
+ categoryType,
+ } = props;
+ const bgImage = category.image
+ ? `images/layers/categories/${category.image}`
+ : '';
+ const categoryBgImage = bgImage
+ ? {
+ backgroundImage: `url(${bgImage})`,
+ }
+ : {};
- return (
- <div
- key={category.id}
- className={
+ return (
+ <div
+ key={category.id}
+ className={
`layer-category layer-category${interestCssName(categoryType)}`
}
- id={category.id}
- >
- <div className="category-background-cover" style={categoryBgImage}>
- <div className="category-background-cover">
- <h3>
- <a
- className="layer-category-name"
- alt={category.title}
- onClick={() => drawMeasurements(category)}
- >
- {category.title}
- </a>
- </h3>
- <ul>
- {category.measurements
- .filter((measurement) => hasMeasurementSource(measurementConfig[measurement]))
- .slice(0, 7)
- .map((measurement, index) => {
- const current = measurementConfig[measurement];
- if (measurement in measurementConfig === false) {
- throw new Error(
- 'in category',
- category.title,
- 'unknown measurement',
- measurement,
- );
- }
- if (measurementConfig[measurement] === undefined) {
- throw new Error(
- `Error: Measurement '${
- measurement
- }' stated in category '${
- category.title
- }' does not exist `
+ id={category.id}
+ >
+ <div className="category-background-cover" style={categoryBgImage}>
+ <div className="category-background-cover">
+ <h3>
+ <a
+ className="layer-category-name"
+ alt={category.title}
+ onClick={() => drawMeasurements(category)}
+ >
+ {category.title}
+ </a>
+ </h3>
+ <ul>
+ {category.measurements
+ .filter((measurement) => hasMeasurementSource(measurementConfig[measurement]))
+ .slice(0, 7)
+ .map((measurement, index) => {
+ const current = measurementConfig[measurement];
+ if (measurement in measurementConfig === false) {
+ throw new Error(
+ 'in category',
+ category.title,
+ 'unknown measurement',
+ measurement,
+ );
+ }
+ if (measurementConfig[measurement] === undefined) {
+ throw new Error(
+ `Error: Measurement '${
+ measurement
+ }' stated in category '${
+ category.title
+ }' does not exist `
+ 'in measurement list!',
- );
- }
- return index === 6 ? (
- <li
- className="layer-category-item"
+ );
+ }
+ return index === 6 ? (
+ <li
+ className="layer-category-item"
/* eslint react/no-array-index-key: 1 */
- key={category.id + index}
+ key={category.id + index}
+ >
+ <a
+ className="layer-category-name"
+ onClick={() => drawMeasurements(category)}
>
- <a
- className="layer-category-name"
- onClick={() => drawMeasurements(category)}
- >
- ...
- </a>
- </li>
- ) : (
- <li
- className="layer-category-item"
- key={category.id + index}
- id={
+ ...
+ </a>
+ </li>
+ ) : (
+ <li
+ className="layer-category-item"
+ key={category.id + index}
+ id={
`layer-category-item-${category.id}-${current.id}`
}
+ >
+ <a
+ className="layer-category-name"
+ onClick={() => drawMeasurements(category, current.id, index)}
>
- <a
- className="layer-category-name"
- onClick={() => drawMeasurements(category, current.id, index)}
- >
- {current.title}
- </a>
- {' '}
- </li>
- );
- })}
- </ul>
- </div>
+ {current.title}
+ </a>
+ {' '}
+ </li>
+ );
+ })}
+ </ul>
</div>
</div>
- );
- }
-}
+ </div>
+ );
+};
const interestCssName = function(name) {
if (name === 'hazards and disasters') {
return 'legacy';
diff --git a/web/js/components/layer/product-picker/category-grid.js b/web/js/components/layer/product-picker/category-grid.js
index b97715766..a9f5f3181 100644
--- a/web/js/components/layer/product-picker/category-grid.js
+++ b/web/js/components/layer/product-picker/category-grid.js
@@ -9,45 +9,43 @@ import CategoryCell from './category-cell';
* @class LayerList
* @extends React.Component
*/
-class CategoryGrid extends React.Component {
- render() {
- const {
- categories,
- measurementConfig,
- drawMeasurements,
- hasMeasurementSource,
- categoryType,
- width,
- } = this.props;
- const masonryOptions = {
- transitionDuration: '0.6s',
- columnWidth: width >= 630 ? 310 : width - 26,
- gutter: 10,
- };
- categories.map((item) => {
- item.sortOrder = item.placement === 'first' ? 1 : item.placement === 'last' ? 3 : 2;
- });
- const orderedCategories = lodashOrderBy(
- categories,
- ['sortOrder', 'title'],
- ['asc'],
- );
- return (
- <Masonry className="category-masonry-case" options={masonryOptions}>
- {orderedCategories.map((category) => (
- <CategoryCell
- key={category.id}
- category={category}
- categoryType={categoryType}
- measurementConfig={measurementConfig}
- drawMeasurements={drawMeasurements}
- hasMeasurementSource={hasMeasurementSource}
- />
- ))}
- </Masonry>
- );
- }
-}
+const CategoryGrid = (props) => {
+ const {
+ categories,
+ measurementConfig,
+ drawMeasurements,
+ hasMeasurementSource,
+ categoryType,
+ width,
+ } = props;
+ const masonryOptions = {
+ transitionDuration: '0.6s',
+ columnWidth: width >= 630 ? 310 : width - 26,
+ gutter: 10,
+ };
+ categories.forEach((item) => {
+ item.sortOrder = item.placement === 'first' ? 1 : item.placement === 'last' ? 3 : 2;
+ });
+ const orderedCategories = lodashOrderBy(
+ categories,
+ ['sortOrder', 'title'],
+ ['asc'],
+ );
+ return (
+ <Masonry className="category-masonry-case" options={masonryOptions}>
+ {orderedCategories.map((category) => (
+ <CategoryCell
+ key={category.id}
+ category={category}
+ categoryType={categoryType}
+ measurementConfig={measurementConfig}
+ drawMeasurements={drawMeasurements}
+ hasMeasurementSource={hasMeasurementSource}
+ />
+ ))}
+ </Masonry>
+ );
+};
CategoryGrid.propTypes = {
categories: PropTypes.array,
diff --git a/web/js/components/layer/settings/orbit-tracks-toggle.js b/web/js/components/layer/settings/orbit-tracks-toggle.js
index 97f9d3c2e..fbc2849f3 100644
--- a/web/js/components/layer/settings/orbit-tracks-toggle.js
+++ b/web/js/components/layer/settings/orbit-tracks-toggle.js
@@ -5,36 +5,34 @@ import { Checkbox } from '../../util/checkbox';
import { addLayer, removeLayer } from '../../../modules/layers/actions';
import { getOrbitTrackTitle } from '../../../modules/layers/util';
-class OrbitTracksToggle extends React.Component {
- render() {
- const {
- trackLayers,
- addLayer,
- removeLayer,
- activeLayers,
- } = this.props;
+const OrbitTracksToggle = (props) => {
+ const {
+ trackLayers,
+ addLayer,
+ removeLayer,
+ activeLayers,
+ } = props;
- return (
- <div className="layer-orbit-tracks settings-component">
- <h2 className="wv-header"> Orbit Tracks </h2>
- { trackLayers.map((layer) => {
- const { id } = layer;
- const isEnabled = activeLayers.some((l) => l.id === id);
- const onCheck = () => (isEnabled ? removeLayer(id) : addLayer(id));
- return (
- <Checkbox
- key={id}
- title="Enable/disable orbit tracks for this layer"
- checked={isEnabled}
- onCheck={onCheck}
- label={getOrbitTrackTitle(layer)}
- />
- );
- }) }
- </div>
- );
- }
-}
+ return (
+ <div className="layer-orbit-tracks settings-component">
+ <h2 className="wv-header"> Orbit Tracks </h2>
+ { trackLayers.map((layer) => {
+ const { id } = layer;
+ const isEnabled = activeLayers.some((l) => l.id === id);
+ const onCheck = () => (isEnabled ? removeLayer(id) : addLayer(id));
+ return (
+ <Checkbox
+ key={id}
+ title="Enable/disable orbit tracks for this layer"
+ checked={isEnabled}
+ onCheck={onCheck}
+ label={getOrbitTrackTitle(layer)}
+ />
+ );
+ }) }
+ </div>
+ );
+};
const mapStateToProps = (state, ownProps) => {
const { config, compare, layers } = state;
diff --git a/web/js/components/notifications/notification-block.js b/web/js/components/notifications/notification-block.js
index 12c5c9cb3..0b60e3180 100644
--- a/web/js/components/notifications/notification-block.js
+++ b/web/js/components/notifications/notification-block.js
@@ -16,34 +16,32 @@ const listIcons = {
outage: faExclamationCircle,
};
-class NotificationBlock extends React.Component {
- render() {
- const { arr, type, numberNotSeen } = this.props;
- return (
- <ul>
- {arr.map((notification, i) => {
- const dateObject = new Date(notification.created_at);
- const date = `${dateObject.getDate()
- } ${
- util.giveMonth(dateObject)
- } ${
- dateObject.getFullYear()}`;
- const activeClass = numberNotSeen > i ? `${type}-notification-item` : '';
- return (
- /* eslint react/no-array-index-key: 1 */
- <li key={type + i} className={activeClass}>
- <h2>
- <FontAwesomeIcon icon={listIcons[type]} />
- <span>{`Posted ${date}`}</span>
- </h2>
- <p dangerouslySetInnerHTML={{ __html: notification.message }} />
- </li>
- );
- })}
- </ul>
- );
- }
-}
+const NotificationBlock = (props) => {
+ const { arr, type, numberNotSeen } = props;
+ return (
+ <ul>
+ {arr.map((notification, i) => {
+ const dateObject = new Date(notification.created_at);
+ const date = `${dateObject.getDate()
+ } ${
+ util.giveMonth(dateObject)
+ } ${
+ dateObject.getFullYear()}`;
+ const activeClass = numberNotSeen > i ? `${type}-notification-item` : '';
+ return (
+ /* eslint react/no-array-index-key: 1 */
+ <li key={type + i} className={activeClass}>
+ <h2>
+ <FontAwesomeIcon icon={listIcons[type]} />
+ <span>{`Posted ${date}`}</span>
+ </h2>
+ <p dangerouslySetInnerHTML={{ __html: notification.message }} />
+ </li>
+ );
+ })}
+ </ul>
+ );
+};
export default NotificationBlock;
diff --git a/web/js/components/sidebar/collapsed-button.js b/web/js/components/sidebar/collapsed-button.js
index 7441ca57c..1726e2a0b 100644
--- a/web/js/components/sidebar/collapsed-button.js
+++ b/web/js/components/sidebar/collapsed-button.js
@@ -4,46 +4,44 @@ import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faLayerGroup } from '@fortawesome/free-solid-svg-icons';
-class CollapsedButton extends React.Component {
- render() {
- const {
- isMobile,
- isCollapsed,
- numberOfLayers,
- onclick,
- } = this.props;
+const CollapsedButton = (props) => {
+ const {
+ isMobile,
+ isCollapsed,
+ numberOfLayers,
+ onclick,
+ } = props;
- return (
- <div
- id="productsHoldertoggleButtonHolder"
- className="toggleButtonHolder"
- style={!isCollapsed ? { display: 'none' } : {}}
+ return (
+ <div
+ id="productsHoldertoggleButtonHolder"
+ className="toggleButtonHolder"
+ style={!isCollapsed ? { display: 'none' } : {}}
+ >
+ <a
+ id="accordionTogglerButton"
+ className="accordionToggler dateHolder staticLayers"
+ title="Show Layer Selector"
+ onClick={onclick}
>
- <a
- id="accordionTogglerButton"
- className="accordionToggler dateHolder staticLayers"
- title="Show Layer Selector"
- onClick={onclick}
- >
- <FontAwesomeIcon icon={faLayerGroup} />
- {isMobile
- ? (
- <span className="layer-count mobile">
- {numberOfLayers.toString()}
- </span>
- )
- : (
- <span className="layer-count ">
- {numberOfLayers.toString()}
- {' '}
- Layers
- </span>
- )}
- </a>
- </div>
- );
- }
-}
+ <FontAwesomeIcon icon={faLayerGroup} />
+ {isMobile
+ ? (
+ <span className="layer-count mobile">
+ {numberOfLayers.toString()}
+ </span>
+ )
+ : (
+ <span className="layer-count ">
+ {numberOfLayers.toString()}
+ {' '}
+ Layers
+ </span>
+ )}
+ </a>
+ </div>
+ );
+};
CollapsedButton.propTypes = {
isCollapsed: PropTypes.bool,
isMobile: PropTypes.bool,
diff --git a/web/js/components/sidebar/nav/nav-item.js b/web/js/components/sidebar/nav/nav-item.js
index 6983f7835..9a399ba4f 100644
--- a/web/js/components/sidebar/nav/nav-item.js
+++ b/web/js/components/sidebar/nav/nav-item.js
@@ -2,41 +2,39 @@ import React from 'react';
import PropTypes from 'prop-types';
import { NavItem, NavLink } from 'reactstrap';
-class CustomNavItem extends React.Component {
- render() {
- const {
- isMobile,
- shouldHideInMobile,
- isDisabled,
- title,
- className,
- onTabClick,
- id,
- iconClassName,
- text,
- } = this.props;
- return (
- <NavItem
- style={
+const CustomNavItem = (props) => {
+ const {
+ isMobile,
+ shouldHideInMobile,
+ isDisabled,
+ title,
+ className,
+ onTabClick,
+ id,
+ iconClassName,
+ text,
+ } = props;
+ return (
+ <NavItem
+ style={
shouldHideInMobile && isMobile
? { display: 'none' }
: { display: 'block' }
}
+ >
+ <NavLink
+ disabled={isDisabled}
+ title={title}
+ className={className}
+ id={`${id}-sidebar-tab`}
+ onClick={() => onTabClick(id)}
>
- <NavLink
- disabled={isDisabled}
- title={title}
- className={className}
- id={`${this.props.id}-sidebar-tab`}
- onClick={() => onTabClick(id)}
- >
- <i className={`productsIcon selected ${iconClassName}`} />
- {text}
- </NavLink>
- </NavItem>
- );
- }
-}
+ <i className={`productsIcon selected ${iconClassName}`} />
+ {text}
+ </NavLink>
+ </NavItem>
+ );
+};
CustomNavItem.propTypes = {
className: PropTypes.string,
diff --git a/web/js/components/tour/content-intro.js b/web/js/components/tour/content-intro.js
index b5d9ccee3..a32944fef 100644
--- a/web/js/components/tour/content-intro.js
+++ b/web/js/components/tour/content-intro.js
@@ -4,23 +4,19 @@ import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faArrowRight } from '@fortawesome/free-solid-svg-icons';
-class TourIntro extends React.Component {
- render() {
- return (
- <div className="tour-intro">
- <p className="intro">
- Visually explore the past and the present of this dynamic planet from a satellite&apos;s perspective.
- Select from an array of stories below to learn more about Worldview, the satellite imagery we provide and events occurring around the world.
- {' '}
- <a href="#" title="Start using Worldview" onClick={this.props.toggleModalStart}>
- Start using Worldview
- <FontAwesomeIcon icon={faArrowRight} />
- </a>
- </p>
- </div>
- );
- }
-}
+const TourIntro = (props) => (
+ <div className="tour-intro">
+ <p className="intro">
+ Visually explore the past and the present of this dynamic planet from a satellite&apos;s perspective.
+ Select from an array of stories below to learn more about Worldview, the satellite imagery we provide and events occurring around the world.
+ {' '}
+ <a href="#" title="Start using Worldview" onClick={props.toggleModalStart}>
+ Start using Worldview
+ <FontAwesomeIcon icon={faArrowRight} />
+ </a>
+ </p>
+ </div>
+);
TourIntro.propTypes = {
toggleModalStart: PropTypes.func.isRequired,
diff --git a/web/js/components/tour/modal-tour-complete.js b/web/js/components/tour/modal-tour-complete.js
index 6563e33a2..26f424581 100644
--- a/web/js/components/tour/modal-tour-complete.js
+++ b/web/js/components/tour/modal-tour-complete.js
@@ -4,76 +4,74 @@ import {
Modal, ModalHeader, ModalBody, ModalFooter,
} from 'reactstrap';
-class ModalComplete extends React.Component {
- render() {
- const {
- currentStory, modalComplete, resetTour, endTour,
- } = this.props;
- const { readMoreLinks } = currentStory;
- let list;
- if (
- readMoreLinks
+const ModalComplete = (props) => {
+ const {
+ currentStory, modalComplete, resetTour, endTour,
+ } = props;
+ const { readMoreLinks } = currentStory;
+ let list;
+ if (
+ readMoreLinks
&& (Array.isArray(readMoreLinks) && readMoreLinks.length)
- ) {
- list = (
- <>
- <p>Read more about this story at the links below:</p>
- <ul>
- {readMoreLinks.map((linkId, i) => (
- /* eslint react/no-array-index-key: 1 */
- <li key={i} index={i}>
- <a href={linkId.link} target="_blank" rel="noopener noreferrer">
- {linkId.title}
- </a>
- </li>
- ))}
- </ul>
- </>
- );
- }
- return (
- <div>
- <Modal
- isOpen={modalComplete}
- toggle={endTour}
- wrapClassName="tour tour-complete"
- backdrop="static"
- fade={false}
- keyboard
- >
- <ModalHeader toggle={endTour} charCode="">
- Story Complete
- </ModalHeader>
- <ModalBody>
- <p>
- You have now completed a story in Worldview. To view more stories,
- click the &ldquo;More Stories&rdquo; button below to explore more events
- within the app. Click the &ldquo;Exit Tutorial&rdquo; button or close this
- window to start using Worldview on your own.
- </p>
- {list}
- </ModalBody>
- <ModalFooter>
- <button
- type="button"
- className="btn btn-primary"
- onClick={resetTour}
- >
- More Stories
- </button>
- <button
- type="button"
- className="btn btn-secondary"
- onClick={endTour}
- >
- Exit Tutorial
- </button>
- </ModalFooter>
- </Modal>
- </div>
+ ) {
+ list = (
+ <>
+ <p>Read more about this story at the links below:</p>
+ <ul>
+ {readMoreLinks.map((linkId, i) => (
+ /* eslint react/no-array-index-key: 1 */
+ <li key={i} index={i}>
+ <a href={linkId.link} target="_blank" rel="noopener noreferrer">
+ {linkId.title}
+ </a>
+ </li>
+ ))}
+ </ul>
+ </>
);
}
-}
+ return (
+ <div>
+ <Modal
+ isOpen={modalComplete}
+ toggle={endTour}
+ wrapClassName="tour tour-complete"
+ backdrop="static"
+ fade={false}
+ keyboard
+ >
+ <ModalHeader toggle={endTour} charCode="">
+ Story Complete
+ </ModalHeader>
+ <ModalBody>
+ <p>
+ You have now completed a story in Worldview. To view more stories,
+ click the &ldquo;More Stories&rdquo; button below to explore more events
+ within the app. Click the &ldquo;Exit Tutorial&rdquo; button or close this
+ window to start using Worldview on your own.
+ </p>
+ {list}
+ </ModalBody>
+ <ModalFooter>
+ <button
+ type="button"
+ className="btn btn-primary"
+ onClick={resetTour}
+ >
+ More Stories
+ </button>
+ <button
+ type="button"
+ className="btn btn-secondary"
+ onClick={endTour}
+ >
+ Exit Tutorial
+ </button>
+ </ModalFooter>
+ </Modal>
+ </div>
+ );
+};
ModalComplete.propTypes = {
currentStory: PropTypes.object.isRequired,
diff --git a/web/js/components/tour/tour-boxes.js b/web/js/components/tour/tour-boxes.js
index bb1e82945..0af3528bb 100644
--- a/web/js/components/tour/tour-boxes.js
+++ b/web/js/components/tour/tour-boxes.js
@@ -3,22 +3,34 @@ import React from 'react';
import PropTypes from 'prop-types';
import TourBox from './tour-box';
-class TourBoxes extends React.Component {
- render() {
- const { stories, storyOrder, selectTour } = this.props;
- return (
- <div className="tour-box-container">
- <div className="tour-box-row">
- {storyOrder.map((storyId, i) => {
- const story = stories[storyId];
+const TourBoxes = (props) => {
+ const { stories, storyOrder, selectTour } = props;
+ return (
+ <div className="tour-box-container">
+ <div className="tour-box-row">
+ {storyOrder.map((storyId, i) => {
+ const story = stories[storyId];
+ return (
+ <TourBox
/* eslint react/no-array-index-key: 1 */
- return (<TourBox key={i} index={i} story={story} storyId={story.id} storyOrder={storyOrder} title={story.title} description={story.description} backgroundImage={story.backgroundImage} backgroundImageHover={story.backgroundImageHover} selectTour={selectTour} className={`tour-box ${story.type}`} />);
- })}
- </div>
+ key={i}
+ index={i}
+ story={story}
+ storyId={story.id}
+ storyOrder={storyOrder}
+ title={story.title}
+ description={story.description}
+ backgroundImage={story.backgroundImage}
+ backgroundImageHover={story.backgroundImageHover}
+ selectTour={selectTour}
+ className={`tour-box ${story.type}`}
+ />
+ );
+ })}
</div>
- );
- }
-}
+ </div>
+ );
+};
TourBoxes.propTypes = {
selectTour: PropTypes.func.isRequired,
diff --git a/web/js/components/tour/widget-steps.js b/web/js/components/tour/widget-steps.js
index f821334cd..b51ed68f6 100644
--- a/web/js/components/tour/widget-steps.js
+++ b/web/js/components/tour/widget-steps.js
@@ -4,42 +4,40 @@ import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCheckCircle, faArrowCircleLeft, faArrowCircleRight } from '@fortawesome/free-solid-svg-icons';
-class Steps extends React.Component {
- render() {
- const {
- currentStep, decreaseStep, incrementStep, totalSteps,
- } = this.props;
- return (
- <div className="step-container">
- <a
- className="step-previous"
- aria-label="Previous"
- onClick={decreaseStep}
- >
- <FontAwesomeIcon icon={faArrowCircleLeft} />
- </a>
- <div className="step-counter">
- <p>
- Step
- {' '}
- <span className="step-current">{currentStep}</span>
- /
- <span className="step-total">{totalSteps}</span>
- </p>
- </div>
- <a
- className="step-next"
- aria-label="Next"
- onClick={incrementStep}
- >
- {currentStep === totalSteps
- ? <FontAwesomeIcon icon={faCheckCircle} />
- : <FontAwesomeIcon icon={faArrowCircleRight} />}
- </a>
+const Steps = (props) => {
+ const {
+ currentStep, decreaseStep, incrementStep, totalSteps,
+ } = props;
+ return (
+ <div className="step-container">
+ <a
+ className="step-previous"
+ aria-label="Previous"
+ onClick={decreaseStep}
+ >
+ <FontAwesomeIcon icon={faArrowCircleLeft} />
+ </a>
+ <div className="step-counter">
+ <p>
+ Step
+ {' '}
+ <span className="step-current">{currentStep}</span>
+ /
+ <span className="step-total">{totalSteps}</span>
+ </p>
</div>
- );
- }
-}
+ <a
+ className="step-next"
+ aria-label="Next"
+ onClick={incrementStep}
+ >
+ {currentStep === totalSteps
+ ? <FontAwesomeIcon icon={faCheckCircle} />
+ : <FontAwesomeIcon icon={faArrowCircleRight} />}
+ </a>
+ </div>
+ );
+};
Steps.propTypes = {
currentStep: PropTypes.number.isRequired,
diff --git a/web/js/components/util/button.js b/web/js/components/util/button.js
index 488b370ee..9fe0d6ca1 100644
--- a/web/js/components/util/button.js
+++ b/web/js/components/util/button.js
@@ -5,26 +5,27 @@ import PropTypes from 'prop-types';
* @class Button
* @extends React.Component
*/
-export default class Button extends React.Component {
- render() {
- return (
- <button
- type="button"
- onClick={this.props.onClick}
- onMouseDown={(e) => e.stopPropagation()}
- style={this.props.style}
- id={this.props.id}
- disabled={!this.props.valid}
- className={
- this.props.valid
- ? `wv-button ${this.props.className}`
- : `wv-disabled wv-button ${this.props.className}`
+export default function Button(props) {
+ const {
+ id, onClick, style, valid, className, text,
+ } = props;
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ onMouseDown={(e) => e.stopPropagation()}
+ style={style}
+ id={id}
+ disabled={!valid}
+ className={
+ valid
+ ? `wv-button ${className}`
+ : `wv-disabled wv-button ${className}`
}
- >
- <span className="button-text">{this.props.text}</span>
- </button>
- );
- }
+ >
+ <span className="button-text">{text}</span>
+ </button>
+ );
}
Button.defaultProps = {
diff --git a/web/js/components/util/list.js b/web/js/components/util/list.js
index bf2516177..faef8ab0c 100644
--- a/web/js/components/util/list.js
+++ b/web/js/components/util/list.js
@@ -44,31 +44,30 @@ const listIcons = {
* @class List
* @extends React.Component
*/
-export default class List extends React.Component {
- render() {
- const {
- list, listClass, active, disabled, onClick, size,
- } = this.props;
- return (
- <ListGroup className={listClass}>
- {list.map((item) => {
- const { iconName } = item;
- const { iconClass } = item;
- const isActive = item.key && active ? item.key === active : false;
- const isDisabled = item.key && disabled ? item.key === disabled : false;
- const { badge } = item;
- const className = item.className ? item.className : '';
- const tagType = item.href ? 'a' : 'button';
- return (
- <ListGroupItem
- key={item.key || item.id || ''}
- tag={tagType}
- active={isActive}
- id={item.id || ''}
- className={`${className} ${size}-item`}
- href={item.href ? item.href : undefined}
- target={item.href ? '_blank' : undefined}
- onClick={
+export default function List(props) {
+ const {
+ list, listClass, active, disabled, onClick, size,
+ } = props;
+ return (
+ <ListGroup className={listClass}>
+ {list.map((item) => {
+ const { iconName } = item;
+ const { iconClass } = item;
+ const isActive = item.key && active ? item.key === active : false;
+ const isDisabled = item.key && disabled ? item.key === disabled : false;
+ const { badge } = item;
+ const className = item.className ? item.className : '';
+ const tagType = item.href ? 'a' : 'button';
+ return (
+ <ListGroupItem
+ key={item.key || item.id || ''}
+ tag={tagType}
+ active={isActive}
+ id={item.id || ''}
+ className={`${className} ${size}-item`}
+ href={item.href ? item.href : undefined}
+ target={item.href ? '_blank' : undefined}
+ onClick={
item.onClick
? item.onClick
: onClick
@@ -77,17 +76,16 @@ export default class List extends React.Component {
}
: null
}
- disabled={isDisabled}
- >
- {iconName ? <FontAwesomeIcon icon={listIcons[iconName]} className={iconClass} fixedWidth /> : ''}
- {item.text || ''}
- {badge ? <Badge pill>{item.badge}</Badge> : ''}
- </ListGroupItem>
- );
- })}
- </ListGroup>
- );
- }
+ disabled={isDisabled}
+ >
+ {iconName ? <FontAwesomeIcon icon={listIcons[iconName]} className={iconClass} fixedWidth /> : ''}
+ {item.text || ''}
+ {badge ? <Badge pill>{item.badge}</Badge> : ''}
+ </ListGroupItem>
+ );
+ })}
+ </ListGroup>
+ );
}
List.defaultProps = {
size: 'medium',
diff --git a/web/js/containers/notifications.js b/web/js/containers/notifications.js
index 11bc4e64d..bdc210129 100644
--- a/web/js/containers/notifications.js
+++ b/web/js/containers/notifications.js
@@ -1,33 +1,31 @@
-import React, { Component } from 'react';
+import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import NotificationBlock from '../components/notifications/notification-block';
import { getNumberOfTypeNotSeen } from '../modules/notifications/util';
-class Notifications extends Component {
- render() {
- const { object } = this.props;
- return (
- <div className="wv-notify-modal">
- <NotificationBlock
- arr={object.outages}
- type="outage"
- numberNotSeen={getNumberOfTypeNotSeen('outage', object.outages)}
- />
- <NotificationBlock
- arr={object.alerts}
- type="alert"
- numberNotSeen={getNumberOfTypeNotSeen('alert', object.alerts)}
- />
- <NotificationBlock
- arr={object.messages}
- type="message"
- numberNotSeen={getNumberOfTypeNotSeen('message', object.messages)}
- />
- </div>
- );
- }
-}
+const Notifications = (props) => {
+ const { object } = props;
+ return (
+ <div className="wv-notify-modal">
+ <NotificationBlock
+ arr={object.outages}
+ type="outage"
+ numberNotSeen={getNumberOfTypeNotSeen('outage', object.outages)}
+ />
+ <NotificationBlock
+ arr={object.alerts}
+ type="alert"
+ numberNotSeen={getNumberOfTypeNotSeen('alert', object.alerts)}
+ />
+ <NotificationBlock
+ arr={object.messages}
+ type="message"
+ numberNotSeen={getNumberOfTypeNotSeen('message', object.messages)}
+ />
+ </div>
+ );
+};
function mapStateToProps(state) {
const { object } = state.notifications;
diff --git a/web/js/containers/sidebar/data.js b/web/js/containers/sidebar/data.js
index d111c35c2..79bd99f6a 100644
--- a/web/js/containers/sidebar/data.js
+++ b/web/js/containers/sidebar/data.js
@@ -51,50 +51,48 @@ const CustomBodyModalContent = () => (
</>
);
-class Data extends React.Component {
- render() {
- const {
- isActive,
- height,
- findProductToSelect,
- counts,
- selectedProduct,
- selectProduct,
- activeLayers,
- products,
- showUnavailableReason,
- tabTypes,
- } = this.props;
- if (!tabTypes.download) return null;
- const dataArray = Object.entries(products);
- if (dataArray.length > 0 && !selectedProduct && isActive) {
- findProductToSelect(activeLayers, selectedProduct);
- } else if (selectedProduct && !doesSelectedExist(dataArray, selectedProduct)) {
- findProductToSelect(activeLayers, selectedProduct);
- }
- return (
- <Scrollbars style={{ maxHeight: `${height}px` }}>
- <div id="wv-data">
- <div className="wv-datalist sidebar-panel content">
- <div id="wv-datacontent">
- {dataArray.map((product, i) => (
- <Products
- key={product[0]}
- id={product[0]}
- productObject={product[1]}
- countsObject={counts}
- isSelected={selectedProduct === product[0]}
- selectProduct={selectProduct}
- showUnavailableReason={showUnavailableReason}
- />
- ))}
- </div>
+const Data = (props) => {
+ const {
+ isActive,
+ height,
+ findProductToSelect,
+ counts,
+ selectedProduct,
+ selectProduct,
+ activeLayers,
+ products,
+ showUnavailableReason,
+ tabTypes,
+ } = props;
+ if (!tabTypes.download) return null;
+ const dataArray = Object.entries(products);
+ if (dataArray.length > 0 && !selectedProduct && isActive) {
+ findProductToSelect(activeLayers, selectedProduct);
+ } else if (selectedProduct && !doesSelectedExist(dataArray, selectedProduct)) {
+ findProductToSelect(activeLayers, selectedProduct);
+ }
+ return (
+ <Scrollbars style={{ maxHeight: `${height}px` }}>
+ <div id="wv-data">
+ <div className="wv-datalist sidebar-panel content">
+ <div id="wv-datacontent">
+ {dataArray.map((product, i) => (
+ <Products
+ key={product[0]}
+ id={product[0]}
+ productObject={product[1]}
+ countsObject={counts}
+ isSelected={selectedProduct === product[0]}
+ selectProduct={selectProduct}
+ showUnavailableReason={showUnavailableReason}
+ />
+ ))}
</div>
</div>
- </Scrollbars>
- );
- }
-}
+ </div>
+ </Scrollbars>
+ );
+};
Data.propTypes = {
activeLayers: PropTypes.array,
counts: PropTypes.object,
diff --git a/web/js/containers/sidebar/layers.js b/web/js/containers/sidebar/layers.js
index 976f95c97..42b077acc 100644
--- a/web/js/containers/sidebar/layers.js
+++ b/web/js/containers/sidebar/layers.js
@@ -5,45 +5,43 @@ import LayerList from './layer-list';
import { getLayers } from '../../modules/layers/selectors';
import Scrollbars from '../../components/util/scrollbar';
-class Layers extends React.Component {
- render() {
- const {
- overlays,
- baselayers,
- isActive,
- layerGroupName,
- height,
- checkerBoardPattern,
- layerSplit,
- } = this.props;
- const outterClass = 'layer-container sidebar-panel';
- return isActive && (
- <Scrollbars style={{ maxHeight: `${height}px` }}>
- <div
- className={isActive ? outterClass : `hidden ${outterClass}`}
- style={{ display: isActive ? 'block' : 'none' }}
- >
- <LayerList
- title="Overlays"
- groupId="overlays"
- layerGroupName={layerGroupName}
- layerSplit={layerSplit}
- layers={overlays}
- checkerBoardPattern={checkerBoardPattern}
- />
- <LayerList
- title="Base Layers"
- groupId="baselayers"
- layerGroupName={layerGroupName}
- layers={baselayers}
- layerSplit={layerSplit}
- checkerBoardPattern={checkerBoardPattern}
- />
- </div>
- </Scrollbars>
- );
- }
-}
+const Layers = (props) => {
+ const {
+ overlays,
+ baselayers,
+ isActive,
+ layerGroupName,
+ height,
+ checkerBoardPattern,
+ layerSplit,
+ } = props;
+ const outterClass = 'layer-container sidebar-panel';
+ return isActive && (
+ <Scrollbars style={{ maxHeight: `${height}px` }}>
+ <div
+ className={isActive ? outterClass : `hidden ${outterClass}`}
+ style={{ display: isActive ? 'block' : 'none' }}
+ >
+ <LayerList
+ title="Overlays"
+ groupId="overlays"
+ layerGroupName={layerGroupName}
+ layerSplit={layerSplit}
+ layers={overlays}
+ checkerBoardPattern={checkerBoardPattern}
+ />
+ <LayerList
+ title="Base Layers"
+ groupId="baselayers"
+ layerGroupName={layerGroupName}
+ layers={baselayers}
+ layerSplit={layerSplit}
+ checkerBoardPattern={checkerBoardPattern}
+ />
+ </div>
+ </Scrollbars>
+ );
+};
function mapStateToProps(state, ownProps) {
const { layers, proj } = state;