Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-2817: ESLint Cleanup - Reenable 'no-nested-ternary' rule and update files (#6415)

Jason Hurley58b4979dabd9
diff --git a/web/.eslintrc b/web/.eslintrc
index 0b4386888..fa284a6a1 100644
--- a/web/.eslintrc
+++ b/web/.eslintrc
@@ -85,7 +85,6 @@
/* Error Counts compiled 8/22/2023 */
// Base rule overrides
- "no-nested-ternary": "off", // 164 errors across 40 files
"max-len": "error",
"no-underscore-dangle": "error",
// Import rules overrides
diff --git a/web/js/components/animation-widget/gif-post-creation.js b/web/js/components/animation-widget/gif-post-creation.js
index 69dbc22a2..a8179c657 100644
--- a/web/js/components/animation-widget/gif-post-creation.js
+++ b/web/js/components/animation-widget/gif-post-creation.js
@@ -115,11 +115,12 @@ export default class GifResults extends Component {
e.stopPropagation();
e.preventDefault();
FileSaver.saveAs(blob, dlURL);
+ const upperSizeRage = size >= 5 && size <= 25
+ ? '5MB-25MB'
+ : '>25MB';
const sizeRange = size < 5
? '<5MB'
- : size >= 5 && size <= 25
- ? '5MB-25MB'
- : '>25MB';
+ : upperSizeRage;
googleTagManager.pushEvent({
event: 'GIF_download',
diff --git a/web/js/components/animation-widget/play-button.js b/web/js/components/animation-widget/play-button.js
index 99d00e4ef..019e6edb8 100644
--- a/web/js/components/animation-widget/play-button.js
+++ b/web/js/components/animation-widget/play-button.js
@@ -11,11 +11,12 @@ function PlayButton({
playing, pause, play, isDisabled, isMobile,
}) {
const buttonId = 'play-button';
+ const isPlayingString = playing ? 'Pause animation' : 'Play animation';
const labelText = isDisabled
? 'Too many animation frames. Reduce time range or increase increment size.'
- : playing
- ? 'Pause animation' : 'Play animation';
- const onClick = isDisabled ? () => {} : playing ? pause : play;
+ : isPlayingString;
+ const isPlaying = playing ? pause : play;
+ const onClick = isDisabled ? () => {} : isPlaying;
return (
<a
diff --git a/web/js/components/charting/chart-component.js b/web/js/components/charting/chart-component.js
index 1d9f3ef14..0351de1e4 100644
--- a/web/js/components/charting/chart-component.js
+++ b/web/js/components/charting/chart-component.js
@@ -172,9 +172,8 @@ function ChartComponent(props) {
// Build display string "YYYY-MM-DD, YYYY-MM-DD, ..." with non-breaking spaces
const errorDatesDisplay = useMemo(() => errors?.error_days
.map((item) => {
- const dateStr = typeof item === 'string'
- ? item
- : item && typeof item === 'object' && 'date' in item ? item.date : String(item || '');
+ const isItemObject = item && typeof item === 'object' && 'date' in item ? item.date : String(item || '');
+ const dateStr = typeof item === 'string' ? item : isItemObject;
return (dateStr || '').split('T')[0];
})
.filter(Boolean)
diff --git a/web/js/components/date-selector/date-input-column.js b/web/js/components/date-selector/date-input-column.js
index e7a913c6a..58c262464 100644
--- a/web/js/components/date-selector/date-input-column.js
+++ b/web/js/components/date-selector/date-input-column.js
@@ -295,11 +295,8 @@ class DateInputColumn extends Component {
const containerBorderStyle = isValid ? {} : { borderColor: '#ff0000' };
const inputClassName = `button-input-group${isValid ? '' : ' invalid-input'}`;
const fontSizeStyle = fontSize ? { fontSize: `${fontSize}px` } : {};
- const inputId = isStartDate
- ? `${type}-${idSuffix}-start`
- : isEndDate
- ? `${type}-${idSuffix}-end`
- : `${type}-${idSuffix}`;
+ const isEndDateString = isEndDate ? `${type}-${idSuffix}-end` : `${type}-${idSuffix}`;
+ const inputId = isStartDate ? `${type}-${idSuffix}-start` : isEndDateString;
return (
<div
diff --git a/web/js/components/layer/product-picker/browse/category-grid.js b/web/js/components/layer/product-picker/browse/category-grid.js
index 33326846b..7497dcdbe 100644
--- a/web/js/components/layer/product-picker/browse/category-grid.js
+++ b/web/js/components/layer/product-picker/browse/category-grid.js
@@ -31,8 +31,9 @@ function CategoryGrid(props) {
gutter: 10,
};
categories.forEach((item) => {
+ const itemPlacementInteger = item.placement === 'last' ? 3 : 2;
let { sortOrder } = item;
- sortOrder = item.placement === 'first' ? 1 : item.placement === 'last' ? 3 : 2;
+ sortOrder = item.placement === 'first' ? 1 : itemPlacementInteger;
return sortOrder;
});
const orderedCategories = lodashOrderBy(
diff --git a/web/js/components/location-search/location-search-input.js b/web/js/components/location-search/location-search-input.js
index 95b87ff83..0896d5f30 100644
--- a/web/js/components/location-search/location-search-input.js
+++ b/web/js/components/location-search/location-search-input.js
@@ -194,11 +194,10 @@ class SearchBox extends Component {
} = this.props;
// handle mobile/desktop input padding with/without alert
- const paddingRightStyle = inputValue
- ? activeAlert
- ? isMobile ? '68px' : '84px'
- : isMobile ? '42px' : '60px'
- : '0';
+ const mobileSmallPadding = isMobile ? '42px' : '60px';
+ const mobileLargerPadding = isMobile ? '68px' : '84px';
+ const mobileActiveAlertSize = activeAlert ? mobileLargerPadding : mobileSmallPadding;
+ const paddingRightStyle = inputValue ? mobileActiveAlertSize : '0';
return {
width: isMobile ? '90%' : '298px',
diff --git a/web/js/components/location-search/util.js b/web/js/components/location-search/util.js
index 5c0c165cc..9544c816a 100644
--- a/web/js/components/location-search/util.js
+++ b/web/js/components/location-search/util.js
@@ -26,10 +26,8 @@ export function getNormalizedCoordinate([lon, lat]) {
}
const isNegative = lon < 0;
const remainder = lon % 360;
- const longitude = isNegative
- && remainder < -180
- ? remainder + 360
- : !isNegative && remainder > 180 ? remainder - 360 : remainder;
+ const positiveRemainder = !isNegative && remainder > 180 ? remainder - 360 : remainder;
+ const longitude = isNegative && remainder < -180 ? remainder + 360 : positiveRemainder;
return [longitude, lat];
}
diff --git a/web/js/components/range-selection/dragger-range.js b/web/js/components/range-selection/dragger-range.js
index 762a0a07c..536c9f786 100644
--- a/web/js/components/range-selection/dragger-range.js
+++ b/web/js/components/range-selection/dragger-range.js
@@ -116,7 +116,8 @@ class TimelineDraggerRange extends PureComponent {
// +/- {number} - change in x - set to 0 to 'stop' dragger movement
// - min/max of -55/55 to prevent overdrag
- let deltaX = d.deltaX < -55 ? -55 : d.deltaX > 55 ? 55 : d.deltaX;
+ const deltaXMax = d.deltaX > 55 ? 55 : d.deltaX;
+ let deltaX = d.deltaX < -55 ? -55 : deltaXMax;
// +/- {number} - start position
const deltaStart = d.x;
diff --git a/web/js/components/sidebar/nav/nav-case.js b/web/js/components/sidebar/nav/nav-case.js
index 8e84b40f8..025a2b520 100644
--- a/web/js/components/sidebar/nav/nav-case.js
+++ b/web/js/components/sidebar/nav/nav-case.js
@@ -19,6 +19,12 @@ function NavCase (props) {
toggleSidebar,
} = props;
+ const dataDownloadLabel = isChartMode
+ ? 'You must exit charting mode to download data'
+ : 'Data Download';
+ const dataDownloadClassName = isChartMode
+ ? `${tabClasses} third-tab disabled`
+ : `${tabClasses} third-tab`;
const renderDataDownload = () => tabTypes.download && (
<CustomNavItem
isMobile={isMobile}
@@ -32,20 +38,22 @@ function NavCase (props) {
label={
isCompareMode
? 'You must exit comparison mode to download data'
- : isChartMode
- ? 'You must exit charting mode to download data'
- : 'Data Download'
+ : dataDownloadLabel
}
className={
activeTab === 'download'
? `${tabClasses} third-tab active`
- : isCompareMode || isChartMode
- ? `${tabClasses} third-tab disabled`
- : `${tabClasses} third-tab`
+ : isCompareMode || dataDownloadClassName
}
/>
);
+ const eventsTabLabel = isChartMode
+ ? 'You must exit charting mode to use the natural events feature'
+ : 'Natural Events';
+ const eventsTabClassName = isCompareMode || isChartMode
+ ? `${tabClasses} second-tab disabled`
+ : `${tabClasses} second-tab`;
const renderEvents = () => tabTypes.events && (
<CustomNavItem
id="events"
@@ -59,16 +67,12 @@ function NavCase (props) {
label={
isCompareMode
? 'You must exit comparison mode to use the natural events feature'
- : isChartMode
- ? 'You must exit charting mode to use the natural events feature'
- : 'Natural Events'
+ : eventsTabLabel
}
className={
activeTab === 'events'
? `${tabClasses} second-tab active`
- : isCompareMode || isChartMode
- ? `${tabClasses} second-tab disabled`
- : `${tabClasses} second-tab`
+ : eventsTabClassName
}
/>
);
diff --git a/web/js/components/sidebar/paletteLegend.js b/web/js/components/sidebar/paletteLegend.js
index 8fdfa7fd1..e03292939 100644
--- a/web/js/components/sidebar/paletteLegend.js
+++ b/web/js/components/sidebar/paletteLegend.js
@@ -297,6 +297,8 @@ class PaletteLegend extends React.Component {
marginRight: '0',
marginLeft: '0',
} : null;
+
+ const translateXOffset = xOffset > 0 ? xOffset + 0.5 : 0;
return (
<div
className={
@@ -329,7 +331,7 @@ class PaletteLegend extends React.Component {
className="wv-running-bar"
style={{
top: 7,
- transform: `translateX(${isHoveringLegend ? 0 : xOffset > 0 ? xOffset + 0.5 : 0}px)`,
+ transform: `translateX(${isHoveringLegend ? 0 : translateXOffset}px)`,
visibility: legendObj && !isHoveringLegend ? 'visible' : 'hidden',
}}
/>
@@ -400,9 +402,8 @@ class PaletteLegend extends React.Component {
const keyId = `${util.encodeId(legend.id)}-color${util.encodeId(parentLayerId)}-${util.encodeId(layer.id)}-${compareState}${keyIndex}`;
const keyLabel = activeKeyObj ? activeKeyObj.label : '';
const inActive = palette.disabled && palette.disabled.includes(keyIndex);
- const tooltipText = singleKey
- ? layer.track ? trackLabel : legendTooltip
- : keyLabel;
+ const trackLabelOrLegendTooltip = layer.track ? trackLabel : legendTooltip;
+ const tooltipText = singleKey ? trackLabelOrLegendTooltip : keyLabel;
const isInvisible = color === '00000000';
palletteClass = isInvisible ? `${palletteClass} checkerbox-bg` : palletteClass;
let legendColor = color;
@@ -473,7 +474,8 @@ class PaletteLegend extends React.Component {
paletteId, layer, isCustomPalette, showingVectorHand, showingChartingIcon,
} = this.props;
const { isHoveringLegend } = this.state;
- const customClass = (showingVectorHand && layer.id.includes('AERONET')) || showingChartingIcon ? ' bottomspace-palette' : isCustomPalette ? ' is_custom' : '';
+ const customPaletteClassName = isCustomPalette ? ' is_custom' : '';
+ const customClass = (showingVectorHand && layer.id.includes('AERONET')) || showingChartingIcon ? ' bottomspace-palette' : customPaletteClassName;
if (!layer.palette) return undefined;
return (
<div
diff --git a/web/js/components/timeline/timeline-axis/date-tooltip/date-tooltip.js b/web/js/components/timeline/timeline-axis/date-tooltip/date-tooltip.js
index 0e55d43f3..f8fde1598 100644
--- a/web/js/components/timeline/timeline-axis/date-tooltip/date-tooltip.js
+++ b/web/js/components/timeline/timeline-axis/date-tooltip/date-tooltip.js
@@ -151,12 +151,13 @@ class DateTooltip extends Component {
const tooltipStyle = this.getTooltipStyle(showDraggerTooltip, showHoverTooltip);
+ const doyValue = dayOfYear < 100
+ ? `0${dayOfYear}`
+ : dayOfYear;
// add leading zero(s) for single digits
dayOfYear = dayOfYear < 10
? `00${dayOfYear}`
- : dayOfYear < 100
- ? `0${dayOfYear}`
- : dayOfYear;
+ : doyValue;
const tooltipClass = `date-tooltip ${shouldDisplayDraggerTooltip ? 'date-tooltip-fade' : ''}`;
return (
diff --git a/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js b/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js
index b03dbeaa1..feaf11de7 100644
--- a/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js
+++ b/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js
@@ -11,10 +11,11 @@ const tileRectTimeScaleOptions = {
return {
lineLengthY: (item) => {
const timeScaleUnit = item.dateObject.minutes;
+ const timeScaleUnitMod = timeScaleUnit % 5 === 0 ? 20 : 10;
const lineLengthY = timeScaleUnit === 0
|| timeScaleUnit === 15
|| timeScaleUnit === 30
- || timeScaleUnit === 45 ? 62 : timeScaleUnit % 5 === 0 ? 20 : 10;
+ || timeScaleUnit === 45 ? 62 : timeScaleUnitMod;
return lineLengthY;
},
};
@@ -23,10 +24,11 @@ const tileRectTimeScaleOptions = {
return {
lineLengthY: (item) => {
const timeScaleUnit = item.dateObject.hours;
- const lineLengthY = timeScaleUnit === 0 ? 62
- : timeScaleUnit === 6
+ const nonZeroTimeScaleUnit = timeScaleUnit === 6
|| timeScaleUnit === 12
|| timeScaleUnit === 18 ? 22 : 10;
+ const lineLengthY = timeScaleUnit === 0 ? 62
+ : nonZeroTimeScaleUnit;
return lineLengthY;
},
};
@@ -36,7 +38,8 @@ const tileRectTimeScaleOptions = {
lineLengthY: (item) => {
const timeScaleUnit = item.dateObject.date;
const { dayOfWeek } = item;
- const lineLengthY = timeScaleUnit === 1 ? 62 : dayOfWeek === 0 ? 22 : 10;
+ const dayOfWeekLineLength = dayOfWeek === 0 ? 22 : 10;
+ const lineLengthY = timeScaleUnit === 1 ? 62 : dayOfWeekLineLength;
return lineLengthY;
},
};
@@ -45,7 +48,8 @@ const tileRectTimeScaleOptions = {
return {
lineLengthY: (item) => {
const timeScaleUnit = item.dateObject.months;
- const lineLengthY = timeScaleUnit === 0 ? 62 : timeScaleUnit % 3 === 0 ? 22 : 10;
+ const nonZeroTimeScaleUnit = timeScaleUnit % 3 === 0 ? 22 : 10;
+ const lineLengthY = timeScaleUnit === 0 ? 62 : nonZeroTimeScaleUnit;
return lineLengthY;
},
};
@@ -54,7 +58,8 @@ const tileRectTimeScaleOptions = {
return {
lineLengthY: (item) => {
const timeScaleUnit = item.dateObject.years;
- const lineLengthY = timeScaleUnit % 10 === 0 ? 62 : timeScaleUnit % 5 === 0 ? 22 : 10;
+ const timeScaleUnitMod = timeScaleUnit % 5 === 0 ? 22 : 10;
+ const lineLengthY = timeScaleUnit % 10 === 0 ? 62 : timeScaleUnitMod;
return lineLengthY;
},
};
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index 81c198dcd..c0f161e5b 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -237,12 +237,13 @@ class TimelineAxis extends Component {
const hasFutureLayersUpdated = prevProps.hasFutureLayers !== hasFutureLayers;
const isTimelineInteracting = isDraggerDragging || isTimelineDragging;
const didTimelineEndDateLimitUpdate = timelineEndDateLimit !== prevProps.timelineEndDateLimit;
+ const draggerGreaterDate = new Date(draggerDate) > new Date(timelineEndDateLimit)
+ ? timelineEndDateLimit
+ : draggerDate;
if (didTimelineEndDateLimitUpdate
&& (!isAnimationPlaying || hasFutureLayersUpdated) && !isTimelineInteracting) {
const updatedDraggerDate = hasFutureLayersUpdated
- ? new Date(draggerDate) > new Date(timelineEndDateLimit)
- ? timelineEndDateLimit
- : draggerDate
+ ? draggerGreaterDate
: draggerDate;
onDateChange(new Date(updatedDraggerDate));
this.updateScale(updatedDraggerDate, timeScale, 0.5);
@@ -322,11 +323,12 @@ class TimelineAxis extends Component {
const options = timeScaleOptions[timeScale].timeAxis;
const { gridWidth } = options;
const timelineAxisWidth = axisWidth;
+ const nonZeroLeftOffset = leftOffset === 0
+ ? timelineAxisWidth * 0.8
+ : leftOffset;
const hoverLeftOffset = leftOffsetFixedCoefficient
? timelineAxisWidth * leftOffsetFixedCoefficient
- : leftOffset === 0
- ? timelineAxisWidth * 0.8
- : leftOffset;
+ : nonZeroLeftOffset;
// visible tiles based on timeline axis width (screen/browser size dependent)
const numberOfVisibleTiles = Number((timelineAxisWidth / gridWidth).toFixed(8));
@@ -378,20 +380,22 @@ class TimelineAxis extends Component {
// conditionally determine dragger times
let draggerTime;
let draggerTimeB;
+ const setDraggerDateACompareMode = isCompareModeActive
+ ? dateA
+ : inputDate || draggerTimeState;
+ const setDraggerDateBCompareMode = isCompareModeActive
+ ? dateB
+ : inputDate || draggerTimeStateB;
if (draggerSelected === 'selected') {
draggerTime = hoverChange
? draggerTimeState
- : isCompareModeActive
- ? dateA
- : inputDate || draggerTimeState;
+ : setDraggerDateACompareMode;
draggerTimeB = isCompareModeActive ? dateB : draggerTimeStateB;
} else {
draggerTime = isCompareModeActive ? dateA : draggerTimeState;
draggerTimeB = hoverChange
? draggerTimeStateB
- : isCompareModeActive
- ? dateB
- : inputDate || draggerTimeStateB;
+ : setDraggerDateBCompareMode;
}
// value of hover time, hover time time unit zeroed, hover time next unit time unit zeroed
@@ -1412,12 +1416,12 @@ class TimelineAxis extends Component {
const timelineStartDateLimitDateObj = new Date(timelineStartDateLimit);
const timelineEndDateLimitDateObj = new Date(timelineEndDateLimit);
const hoverTimeDateObj = new Date(hoverTimeDate);
-
+ const constrainHoverTimeDateObj = hoverTimeDateObj < timelineStartDateLimitDateObj
+ ? timelineStartDateLimit
+ : hoverTimeDate;
hoverTimeDate = hoverTimeDateObj > timelineEndDateLimitDateObj
? timelineEndDateLimit
- : hoverTimeDateObj < timelineStartDateLimitDateObj
- ? timelineStartDateLimit
- : hoverTimeDate;
+ : constrainHoverTimeDateObj;
// parent update positioning and hover time
updatePositioningOnAxisStopDrag(updatePositioningArguments, hoverTimeDate);
diff --git a/web/js/components/timeline/timeline-controls/animation-button.js b/web/js/components/timeline/timeline-controls/animation-button.js
index 176d02aea..40f20484f 100644
--- a/web/js/components/timeline/timeline-controls/animation-button.js
+++ b/web/js/components/timeline/timeline-controls/animation-button.js
@@ -47,11 +47,20 @@ function AnimationButton(props) {
};
const buttonClass = getButtonClassName();
-
+ let animationButtonClassName;
+ if (isKioskModeActive) {
+ animationButtonClassName = 'd-none';
+ } else if (disabled) {
+ animationButtonClassName = 'wv-disabled-button button-action-group animate-button';
+ } else if (!isMobile && !isEmbedModeActive) {
+ animationButtonClassName = 'button-action-group animate-button';
+ } else {
+ animationButtonClassName = `button-action-group mobile-animate-button animate-button-${buttonClass}`;
+ }
return (
<div
onClick={clickAnimationButton}
- className={isKioskModeActive ? 'd-none' : disabled ? 'wv-disabled-button button-action-group animate-button' : !isMobile && !isEmbedModeActive ? 'button-action-group animate-button' : `button-action-group mobile-animate-button animate-button-${buttonClass}`}
+ className={animationButtonClassName}
aria-label={labelText}
>
<div id={buttonId}>
diff --git a/web/js/components/timeline/timeline-controls/timescale-interval-change.js b/web/js/components/timeline/timeline-controls/timescale-interval-change.js
index 5f0aec605..6b4bd6fc4 100644
--- a/web/js/components/timeline/timeline-controls/timescale-interval-change.js
+++ b/web/js/components/timeline/timeline-controls/timescale-interval-change.js
@@ -215,6 +215,7 @@ class TimeScaleIntervalChange extends PureComponent {
} = this.props;
const className = `no-drag interval-btn interval-btn-active${customSelected ? ' custom-interval-text' : ''} ${isDisabled ? ' disabled' : ''}`;
+ const spanInnerText = autoSelected ? 'AUTO' : `${1} ${TIME_SCALE_FROM_NUMBER[interval]}`;
return (
<div
id="timeline-interval-btn-container"
@@ -228,7 +229,7 @@ class TimeScaleIntervalChange extends PureComponent {
id="current-interval"
className={className}
>
- {customSelected ? customIntervalText : autoSelected ? 'AUTO' : `${1} ${TIME_SCALE_FROM_NUMBER[interval]}`}
+ {customSelected ? customIntervalText : spanInnerText}
</span>
{!isDisabled ? this.renderTooltip() : null}
diff --git a/web/js/components/timeline/timeline-coverage/coverage-item-list.js b/web/js/components/timeline/timeline-coverage/coverage-item-list.js
index 5cb7acc97..de4af83df 100644
--- a/web/js/components/timeline/timeline-coverage/coverage-item-list.js
+++ b/web/js/components/timeline/timeline-coverage/coverage-item-list.js
@@ -110,13 +110,10 @@ class CoverageItemList extends Component {
* @returns {String} formatted period
*/
static getFormattedTimePeriod (period) {
- return period === 'daily'
- ? 'day'
- : period === 'monthly'
- ? 'month'
- : period === 'yearly'
- ? 'year'
- : 'minute';
+ if (period === 'daily') return 'day';
+ if (period === 'monthly') return 'monthly';
+ if (period === 'yearly') return 'year';
+ return 'minute';
}
diff --git a/web/js/components/timeline/timeline-draggers/timeline-dragger.js b/web/js/components/timeline/timeline-draggers/timeline-dragger.js
index 169d79e4b..d5e7fe73d 100644
--- a/web/js/components/timeline/timeline-draggers/timeline-dragger.js
+++ b/web/js/components/timeline/timeline-draggers/timeline-dragger.js
@@ -128,16 +128,10 @@ class Dragger extends PureComponent {
? false
: isHoveredDrag || isHoveredDragging;
// handle fill for hover vs non-hover and slightly different A/B draggers
- const draggerFill = disabled
- ? isHovered
- ? '#8e8e8e'
- : '#666666'
- : isHovered
- ? isCompareModeActive
- ? '#a3a3a3'
- : '#8e8e8e'
- : '#ccc';
-
+ const disabledFillColor = isHovered ? '#8e8e8e' : '#666666';
+ const comparedModeFillColor = isCompareModeActive ? '#a3a3a3' : '#8e8e8e';
+ const enabledFillColor = isHovered ? comparedModeFillColor : '#ccc';
+ const draggerFill = disabled ? disabledFillColor : enabledFillColor;
const draggerStroke = isHovered
? '#ccc'
: '#333';
diff --git a/web/js/components/vector-metadata/table.js b/web/js/components/vector-metadata/table.js
index d4b897fae..d33991b7e 100644
--- a/web/js/components/vector-metadata/table.js
+++ b/web/js/components/vector-metadata/table.js
@@ -40,10 +40,13 @@ export default class VectorMetaTable extends React.Component {
} = properties;
const isIntegerToStyle = Function !== 'Identify' && (DataType === 'int');
+ const metaFeaturesIdentifierValue = metaFeatures[Identifier]
+ ? metaFeatures[Identifier] : null;
+ const metaFeaturesResult = isIntegerToStyle ? metaFeatures[Identifier].toLocaleString('en')
+ : metaFeaturesIdentifierValue;
const value = ValueMap
? ValueMap[metaFeatures[Identifier]]
- : isIntegerToStyle ? metaFeatures[Identifier].toLocaleString('en')
- : metaFeatures[Identifier] ? metaFeatures[Identifier] : null;
+ : metaFeaturesResult;
const id = util.cleanId(String(`${title}-${metaIndex + index}`));
if (!value) return undefined;
diff --git a/web/js/containers/animation-widget/animation-widget.js b/web/js/containers/animation-widget/animation-widget.js
index 2b5ff80ee..208c2945a 100644
--- a/web/js/containers/animation-widget/animation-widget.js
+++ b/web/js/containers/animation-widget/animation-widget.js
@@ -228,130 +228,136 @@ function AnimationWidget (props) {
onPushPlay();
};
- return isActive ? (
+ const renderPlayQueue = isPlaying ? (
+ <PlayQueue
+ isMobile={isMobile}
+ isLoopActive={looping}
+ isPlaying={isPlaying}
+ numberOfFrames={numberOfFrames}
+ snappedCurrentDate={snappedCurrentDate}
+ currentDate={currentDate}
+ startDate={startDate}
+ endDate={endDate}
+ interval={interval}
+ isKioskModeActive={isKioskModeActive}
+ delta={delta}
+ speed={speed}
+ selectDate={selectDate}
+ togglePlaying={onPushPause}
+ promiseImageryForTime={promiseImageryForTime}
+ onClose={onPushPause}
+ map={map}
+ autoSelected={autoSelected}
+ layers={layers}
+ />
+ ) : null;
+
+ const renderAnimationTileCheck = checkAnimationAvailability ? (
+ <AnimationTileCheck
+ startDate={startDate}
+ endDate={endDate}
+ interval={interval}
+ delta={delta}
+ isPlaying={isPlaying}
+ />
+ ) : renderPlayQueue;
+
+ const renderDesktopAnimationWidget = (
+ <DesktopAnimationWidget
+ animationCustomModalOpen={animationCustomModalOpen}
+ autoplay={autoplay}
+ customModalType={customModalType}
+ isDistractionFreeModeActive={isDistractionFreeModeActive}
+ endDate={endDate}
+ handleDragStart={handleDragStart}
+ hasSubdailyLayers={hasSubdailyLayers}
+ interval={interval}
+ isKioskModeActive={isKioskModeActive}
+ isPlaying={isPlaying}
+ looping={looping}
+ maxDate={maxDate}
+ minDate={minDate}
+ numberOfFrames={numberOfFrames}
+ onClose={onClose}
+ onDateChange={onDateChange}
+ onExpandedDrag={onExpandedDrag}
+ onLoop={onLoop}
+ onPushPause={onPushPause}
+ onPushPlay={onPushPlayFunc}
+ onSlide={onSlide}
+ playDisabled={playDisabled}
+ toggleCollapse={toggleCollapse}
+ setSpeed={setSpeed}
+ sliderLabel={sliderLabel}
+ speed={speed}
+ startDate={startDate}
+ subDailyMode={subDailyMode}
+ widgetPosition={widgetPosition}
+ zeroDates={zeroDates}
+ />
+ );
+ const renderMobileOrDesktopWidget = isMobile ? (
+ <MobileAnimationWidget
+ breakpoints={breakpoints}
+ endDate={endDate}
+ hasSubdailyLayers={hasSubdailyLayers}
+ isEmbedModeActive={isEmbedModeActive}
+ isLandscape={isLandscape}
+ isMobile={isMobile}
+ isMobilePhone={isMobilePhone}
+ isMobileTablet={isMobileTablet}
+ isPlaying={isPlaying}
+ isPortrait={isPortrait}
+ looping={looping}
+ maxDate={maxDate}
+ minDate={minDate}
+ onLoop={onLoop}
+ onSlide={onSlide}
+ onUpdateEndDate={onUpdateEndDate}
+ onUpdateStartDate={onUpdateStartDate}
+ playDisabled={playDisabled}
+ selectDate={selectDate}
+ screenHeight={screenHeight}
+ screenWidth={screenWidth}
+ setSpeed={setSpeed}
+ sliderLabel={sliderLabel}
+ speed={speed}
+ startDate={startDate}
+ subDailyMode={subDailyMode}
+ toggleCollapse={toggleCollapse}
+ />
+ ) : renderDesktopAnimationWidget;
+ const renderCollapsedAnimationWidget = isCollapsed ? (
+ <CollapsedAnimationWidget
+ isDistractionFreeModeActive={isDistractionFreeModeActive}
+ hasSubdailyLayers={hasSubdailyLayers}
+ isMobile={isMobile}
+ isPlaying={isPlaying}
+ onClose={onClose}
+ onPushPause={onPushPause}
+ playDisabled={playDisabled}
+ isPortrait={isPortrait}
+ isLandscape={isLandscape}
+ isMobilePhone={isMobilePhone}
+ isMobileTablet={isMobileTablet}
+ screenWidth={screenWidth}
+ breakpoints={breakpoints}
+ collapsedWidgetPosition={collapsedWidgetPosition}
+ handleDragStart={handleDragStart}
+ onCollapsedDrag={onCollapsedDrag}
+ onPushPlay={onPushPlayFunc}
+ toggleCollapse={toggleCollapse}
+ />
+ ) : renderMobileOrDesktopWidget;
+
+
+ const renderWidget = () => (
<ErrorBoundary>
- {
- checkAnimationAvailability ? (
- <AnimationTileCheck
- startDate={startDate}
- endDate={endDate}
- interval={interval}
- delta={delta}
- isPlaying={isPlaying}
- />
- ) : isPlaying ? (
- <PlayQueue
- isMobile={isMobile}
- isLoopActive={looping}
- isPlaying={isPlaying}
- numberOfFrames={numberOfFrames}
- snappedCurrentDate={snappedCurrentDate}
- currentDate={currentDate}
- startDate={startDate}
- endDate={endDate}
- interval={interval}
- isKioskModeActive={isKioskModeActive}
- delta={delta}
- speed={speed}
- selectDate={selectDate}
- togglePlaying={onPushPause}
- promiseImageryForTime={promiseImageryForTime}
- onClose={onPushPause}
- map={map}
- autoSelected={autoSelected}
- layers={layers}
- />
- ) : null
- }
- {isCollapsed ? (
- <CollapsedAnimationWidget
- isDistractionFreeModeActive={isDistractionFreeModeActive}
- hasSubdailyLayers={hasSubdailyLayers}
- isMobile={isMobile}
- isPlaying={isPlaying}
- onClose={onClose}
- onPushPause={onPushPause}
- playDisabled={playDisabled}
- isPortrait={isPortrait}
- isLandscape={isLandscape}
- isMobilePhone={isMobilePhone}
- isMobileTablet={isMobileTablet}
- screenWidth={screenWidth}
- breakpoints={breakpoints}
- collapsedWidgetPosition={collapsedWidgetPosition}
- handleDragStart={handleDragStart}
- onCollapsedDrag={onCollapsedDrag}
- onPushPlay={onPushPlayFunc}
- toggleCollapse={toggleCollapse}
- />
- ) : isMobile ? (
- <MobileAnimationWidget
- breakpoints={breakpoints}
- endDate={endDate}
- hasSubdailyLayers={hasSubdailyLayers}
- isEmbedModeActive={isEmbedModeActive}
- isLandscape={isLandscape}
- isMobile={isMobile}
- isMobilePhone={isMobilePhone}
- isMobileTablet={isMobileTablet}
- isPlaying={isPlaying}
- isPortrait={isPortrait}
- looping={looping}
- maxDate={maxDate}
- minDate={minDate}
- onLoop={onLoop}
- onSlide={onSlide}
- onUpdateEndDate={onUpdateEndDate}
- onUpdateStartDate={onUpdateStartDate}
- playDisabled={playDisabled}
- selectDate={selectDate}
- screenHeight={screenHeight}
- screenWidth={screenWidth}
- setSpeed={setSpeed}
- sliderLabel={sliderLabel}
- speed={speed}
- startDate={startDate}
- subDailyMode={subDailyMode}
- toggleCollapse={toggleCollapse}
- />
- ) : isKioskModeActive
- ? null
- : (
- <DesktopAnimationWidget
- animationCustomModalOpen={animationCustomModalOpen}
- autoplay={autoplay}
- customModalType={customModalType}
- isDistractionFreeModeActive={isDistractionFreeModeActive}
- endDate={endDate}
- handleDragStart={handleDragStart}
- hasSubdailyLayers={hasSubdailyLayers}
- interval={interval}
- isKioskModeActive={isKioskModeActive}
- isPlaying={isPlaying}
- looping={looping}
- maxDate={maxDate}
- minDate={minDate}
- numberOfFrames={numberOfFrames}
- onClose={onClose}
- onDateChange={onDateChange}
- onExpandedDrag={onExpandedDrag}
- onLoop={onLoop}
- onPushPause={onPushPause}
- onPushPlay={onPushPlayFunc}
- onSlide={onSlide}
- playDisabled={playDisabled}
- toggleCollapse={toggleCollapse}
- setSpeed={setSpeed}
- sliderLabel={sliderLabel}
- speed={speed}
- startDate={startDate}
- subDailyMode={subDailyMode}
- widgetPosition={widgetPosition}
- zeroDates={zeroDates}
- />
- )}
+ {renderAnimationTileCheck}
+ {renderCollapsedAnimationWidget}
</ErrorBoundary>
- ) : null;
+ );
+ return isActive ? renderWidget() : null;
}
const mapStateToProps = (state) => {
diff --git a/web/js/containers/info.js b/web/js/containers/info.js
index 7c1a3e847..c6f4d80f3 100644
--- a/web/js/containers/info.js
+++ b/web/js/containers/info.js
@@ -41,14 +41,15 @@ function InfoList (props) {
function getNotificationListItem() {
const { numberUnseen, type, object } = notifications;
+ const iconName = () => {
+ if (type === 'message') return 'gift';
+ if (type === 'outage') return 'exclamation-circle';
+ return ['fas', 'bolt'];
+ };
return {
text: 'Notifications',
iconClass: 'ui-icon',
- iconName: type === 'message'
- ? 'gift'
- : type === 'outage'
- ? 'exclamation-circle'
- : ['fas', 'bolt'],
+ iconName: iconName(),
id: 'notifications_info_item',
badge: type ? numberUnseen : 0,
className: type ? `${type}-notification` : '',
diff --git a/web/js/containers/map-interactions/ol-vector-interactions.js b/web/js/containers/map-interactions/ol-vector-interactions.js
index 437767219..6ad70d13d 100644
--- a/web/js/containers/map-interactions/ol-vector-interactions.js
+++ b/web/js/containers/map-interactions/ol-vector-interactions.js
@@ -196,14 +196,16 @@ export class VectorInteractions extends React.Component {
let clickObj = getDialogObject(pixels, map);
const metaArray = clickObj.metaArray || [];
const isAeronet = !!metaArray[0] && metaArray[0].id.includes('AERONET');
+ const aeronetMobileSize = isAeronet ? 250 : 445;
clickObj = getDialogObject(pixels, map, isMobile
- ? screenSize.screenWidth : isAeronet ? 250 : 445);
+ ? screenSize.screenWidth : aeronetMobileSize);
const selected = clickObj.selected || {};
const offsetLeft = clickObj.offsetLeft || 10;
const offsetTop = clickObj.offsetTop || 100;
const isCoordinatesMarker = clickObj.isCoordinatesMarker || false;
const exceededLengthLimit = clickObj.exceededLengthLimit || false;
- const dialogId = clickObj.modalShouldFollowClicks ? `vector_dialog${pixels[0]}${pixels[1]}` : isVectorModalOpen ? modalState.id : `vector_dialog${pixels[0]}${pixels[1]}`;
+ const vectorModalOpenId = isVectorModalOpen ? modalState.id : `vector_dialog${pixels[0]}${pixels[1]}`;
+ const dialogId = clickObj.modalShouldFollowClicks ? `vector_dialog${pixels[0]}${pixels[1]}` : vectorModalOpenId;
if (isCoordinatesMarker) return;
@@ -356,7 +358,8 @@ const mapDispatchToProps = (dispatch) => ({
const dialogKey = new Date().getUTCMilliseconds();
const modalClassName = isEmbedModeActive && !isMobile ? 'vector-modal light modal-embed' : 'vector-modal light';
const mobileTopOffset = 106;
- const modalWidth = isMobile ? screenWidth : isAeronet ? 250 : 445;
+ const aeroNetModalWidth = isAeronet ? 250 : 445;
+ const modalWidth = isMobile ? screenWidth : aeroNetModalWidth;
const modalHeight = isMobile ? screenHeight - mobileTopOffset : 300;
dispatch(openCustomContent(
diff --git a/web/js/containers/modal.js b/web/js/containers/modal.js
index 4839844b1..f1589c9d8 100644
--- a/web/js/containers/modal.js
+++ b/web/js/containers/modal.js
@@ -247,7 +247,7 @@ function ModalContainer(props) {
&times;
</button>
);
-
+ const renderModalBodyText = isTemplateModal ? getTemplateBody() : (<p>{bodyText}</p>) || '';
return (
<ErrorBoundary>
<InteractionWrap
@@ -300,7 +300,7 @@ function ModalContainer(props) {
closeModal={toggleFunction}
/>
)
- : isTemplateModal ? getTemplateBody() : (<p>{bodyText}</p>) || ''}
+ : renderModalBodyText}
</ModalBody>
{footer && (<ModalFooter />)}
</DetectOuterClick>
diff --git a/web/js/containers/share.js b/web/js/containers/share.js
index e16a78d13..3a49ce1f4 100644
--- a/web/js/containers/share.js
+++ b/web/js/containers/share.js
@@ -240,18 +240,20 @@ class ShareLinkContainer extends Component {
activeTab,
isShort,
} = this.state;
- const value = shortLink.isLoading && isShort
- ? 'Please wait...'
- : isShort
+ const shortLinkValue = isShort
&& shortLink.response
&& shortLink.response.link
- ? shortLink.response.link
- : this.getPermalink();
+ ? shortLink.response.link
+ : this.getPermalink();
+ const value = shortLink.isLoading && isShort
+ ? 'Please wait...'
+ : shortLinkValue;
const url = window.location.href;
const preventShorten = url.length > 2048;
const isDisabled = shortLink.isLoading || preventShorten;
- const tooltipText = isDisabled ? preventShorten ? 'URL has too many characters to shorten' : 'Link cannot be shortened at this time' : '';
+ const shortenWarning = preventShorten ? 'URL has too many characters to shorten' : 'Link cannot be shortened at this time';
+ const tooltipText = isDisabled ? shortenWarning : '';
return (
<TabPane tabId="link" className="share-tab-link">
diff --git a/web/js/containers/sidebar/events.js b/web/js/containers/sidebar/events.js
index db86fd623..aa32615f2 100644
--- a/web/js/containers/sidebar/events.js
+++ b/web/js/containers/sidebar/events.js
@@ -64,12 +64,12 @@ function Events(props) {
const startDate = formatDisplayDate(selectedStartDate);
const endDate = formatDisplayDate(selectedEndDate);
-
+ const requestErrorMessage = hasRequestError
+ ? 'There has been an ERROR retrieving events from the EONET events API. Please try again later.'
+ : '';
const errorOrLoadingText = isLoading
? 'Loading ...'
- : hasRequestError
- ? 'There has been an ERROR retrieving events from the EONET events API. Please try again later.'
- : '';
+ : requestErrorMessage;
const renderFilterControls = () => (
<div className="filter-controls">
diff --git a/web/js/containers/sidebar/layer-list.js b/web/js/containers/sidebar/layer-list.js
index 34961b0b6..f9c5c2bd9 100644
--- a/web/js/containers/sidebar/layer-list.js
+++ b/web/js/containers/sidebar/layer-list.js
@@ -188,9 +188,13 @@ function LayerList(props) {
ref={provided.innerRef}
{...provided.droppableProps}
>
- {layers.sort((layerA, layerB) => (isChartingActive
- ? layerB.shouldHide === layerA.shouldHide
- ? 0 : layerB.shouldHide ? -1 : 1 : 0)).map(renderLayer)}
+ {layers.sort((layerA, layerB) => {
+ const shouldHideLayerB = layerB.shouldHide ? -1 : 1;
+ const shouldHideLayers = layerB.shouldHide === layerA.shouldHide
+ ? 0 : shouldHideLayerB;
+ return isChartingActive
+ ? shouldHideLayers : 0;
+ }).map(renderLayer)}
{provided.placeholder}
</ul>
)}
diff --git a/web/js/containers/sidebar/layer-row.js b/web/js/containers/sidebar/layer-row.js
index bd759f968..d1b437e4c 100644
--- a/web/js/containers/sidebar/layer-row.js
+++ b/web/js/containers/sidebar/layer-row.js
@@ -484,17 +484,11 @@ function LayerRow (props) {
return baseClasses;
};
- const visibilityTitle = !isVisible && !disabled
- ? 'Show layer'
- : disabled
- ? getDisabledTitle(layer)
- : 'Hide layer';
-
- const visibilityIconClass = disabled
- ? 'ban'
- : !isVisible
- ? ['fas', 'eye-slash']
- : ['fas', 'eye'];
+ const disabledTitle = disabled ? getDisabledTitle(layer) : 'Hide layer';
+ const visibilityTitle = !isVisible && !disabled ? 'Show layer' : disabledTitle;
+
+ const visibilityIcon = !isVisible ? ['fas', 'eye-slash'] : ['fas', 'eye'];
+ const visibilityIconClass = disabled ? 'ban' : visibilityIcon;
const collectionClass = collections?.type === 'NRT' ? 'collection-title badge rounded-pill bg-secondary' : 'collection-title badge rounded-pill text-dark bg-light';
@@ -504,6 +498,8 @@ function LayerRow (props) {
}
};
+ const vectorLayerMinHeight = isVectorLayer ? '60px' : '40px';
+
const renderLayerRow = () => (
<>
{(!isEmbedModeActive && !isChartingActive) && (
@@ -563,7 +559,7 @@ function LayerRow (props) {
<Zot zot={activeZot || zot} layer={layer.id} isMobile={isMobile} />
<div className={isVectorLayer ? 'layer-main wv-vector-layer' : 'layer-main'}>
- <div className="layer-info" style={{ minHeight: layer.shouldHide ? '22px' : isVectorLayer ? '60px' : '40px' }}>
+ <div className="layer-info" style={{ minHeight: layer.shouldHide ? '22px' : vectorLayerMinHeight }}>
<div className="layer-buttons">
{showButtons && renderControls()}
</div>
diff --git a/web/js/containers/sidebar/sidebar.js b/web/js/containers/sidebar/sidebar.js
index 2352f0d94..041ab62c8 100644
--- a/web/js/containers/sidebar/sidebar.js
+++ b/web/js/containers/sidebar/sidebar.js
@@ -115,7 +115,8 @@ class Sidebar extends React.Component {
} = this.props;
const footerHeight = lodashGet(this, 'footerElement.clientHeight') || 20;
const addLayersHeight = lodashGet(this, 'addLayersElement.clientHeight') || 30;
- const tabHeight = isMobile ? isCompareMode ? 80 : 40 : 32;
+ const compareModeHeight = isCompareMode ? 80 : 40;
+ const tabHeight = isMobile ? compareModeHeight : 32;
const groupCheckboxHeight = 35;
let newHeight;
if (!isMobile) {
@@ -326,35 +327,38 @@ class Sidebar extends React.Component {
const { naturalEvents } = config.features;
const { smartHandoffs } = config.features;
+ const embedModeHeight = isEmbedModeActive
+ ? '95vh'
+ : `${screenHeight}px`;
const maxHeight = isCollapsed
? '0'
- : isEmbedModeActive
- ? '95vh'
- : `${screenHeight}px`;
+ : embedModeHeight;
const displayStyle = isDistractionFreeModeActive ? 'none' : 'block';
const mobileWVSidebarStyle = !isDistractionFreeModeActive && isMobile ? {
position: 'static',
} : null;
+ const mobileProductHolderStyle = !isDistractionFreeModeActive && isMobile && !isEmbedModeActive
+ ? {
+ cssFloat: 'left',
+ left: '0',
+ minWidth: '238px',
+ width: '100%',
+ height: '100%',
+ position: 'absolute !important',
+ overflow: 'hidden',
+ background: 'rgb(38 43 49)',
+ top: '0',
+ zIndex: 1000,
+ maxHeight: `${maxHeight}`,
+ display: `{${displayStyle}} !important`,
+ } : {
+ maxHeight: `${maxHeight}`,
+ };
const productsHolderStyle = isDistractionFreeModeActive && !isMobile ? {
display: 'none',
- } : !isDistractionFreeModeActive && isMobile && !isEmbedModeActive ? {
- cssFloat: 'left',
- left: '0',
- minWidth: '238px',
- width: '100%',
- height: '100%',
- position: 'absolute !important',
- overflow: 'hidden',
- background: 'rgb(38 43 49)',
- top: '0',
- zIndex: 1000,
- maxHeight: `${maxHeight}`,
- display: `{${displayStyle}} !important`,
- } : {
- maxHeight: `${maxHeight}`,
- };
+ } : mobileProductHolderStyle;
return (
<ErrorBoundary>
diff --git a/web/js/containers/sidebar/smart-handoff.js b/web/js/containers/sidebar/smart-handoff.js
index 55c2d45f0..cd393656c 100644
--- a/web/js/containers/sidebar/smart-handoff.js
+++ b/web/js/containers/sidebar/smart-handoff.js
@@ -343,11 +343,12 @@ class SmartHandoff extends Component {
showZoomedIntoDatelineAlert,
} = this.state;
+ const zoomedInDatelineAlertMsg = showZoomedIntoDatelineAlert
+ ? 'The map is zoomed into an area with no available data.'
+ : '';
const message = showBoundingBox && selectionOutsideExtents && !showZoomedIntoDatelineAlert
? 'The selection is outside the available map area.'
- : showZoomedIntoDatelineAlert
- ? 'The map is zoomed into an area with no available data.'
- : '';
+ : zoomedInDatelineAlertMsg;
return (selectionOutsideExtents || showZoomedIntoDatelineAlert) && message && (
<AlertUtil
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index fcffed249..788b360f6 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -1127,6 +1127,12 @@ class Timeline extends React.Component {
timelineStartDateLimit,
} = this.props;
+ const dataDownloadLabel = isDataDownload
+ ? 'Animation feature is deactivated when Data Download feature is active'
+ : '';
+ const chartingActiveLabel = isChartingActive
+ ? 'Animation feature is deactivated when Charting feature is active'
+ : dataDownloadLabel;
return (
<div id="timeline-header" className="timeline-header-mobile">
<MobileDatePicker
@@ -1162,15 +1168,9 @@ class Timeline extends React.Component {
isKioskModeActive={isKioskModeActive}
isEmbedModeActive={isEmbedModeActive}
disabled={animationDisabled}
- label={
- isCompareModeActive
- ? 'Animation feature is deactivated when Compare feature is active'
- : isChartingActive
- ? 'Animation feature is deactivated when Charting feature is active'
- : isDataDownload
- ? 'Animation feature is deactivated when Data Download feature is active'
- : ''
- }
+ label={isCompareModeActive
+ ? 'Animation feature is deactivated when Compare feature is active'
+ : chartingActiveLabel}
/>
)}
</div>
@@ -1265,6 +1265,14 @@ class Timeline extends React.Component {
const containerDisplayStyle = {
display: isDistractionFreeModeActive ? 'block' : 'block',
};
+
+ const dataDownloadLabel = isDataDownload
+ ? 'Animation feature is deactivated when Data Download feature is active'
+ : '';
+ const chartingActiveLabel = isChartingActive
+ ? 'Animation feature is deactivated when Charting feature is active'
+ : dataDownloadLabel;
+
return (
<div
className="timeline-container"
@@ -1315,15 +1323,9 @@ class Timeline extends React.Component {
isKioskModeActive={isKioskModeActive}
screenWidth={screenWidth}
breakpoints={breakpoints}
- label={
- isCompareModeActive
+ label={isCompareModeActive
? 'Animation feature is deactivated when Compare feature is active'
- : isChartingActive
- ? 'Animation feature is deactivated when Charting feature is active'
- : isDataDownload
- ? 'Animation feature is deactivated when Data Download feature is active'
- : ''
- }
+ : chartingActiveLabel}
/>
</div>
diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.js
index e8d4af377..2baa08f4e 100644
--- a/web/js/containers/toolbar.js
+++ b/web/js/containers/toolbar.js
@@ -326,13 +326,15 @@ class toolbarContainer extends Component {
isMobile,
} = this.props;
const buttonId = 'wv-image-button';
+ const activeImageDownloadLabel = !isImageDownloadActive
+ ? 'You must exit data download mode to use the snapshot feature'
+ : 'Take a snapshot';
+ const activeChartingLabel = isChartingActive
+ ? 'You must exit charting mode to use the snapshot feature'
+ : activeImageDownloadLabel;
const labelText = isCompareActive
? 'You must exit comparison mode to use the snapshot feature'
- : isChartingActive
- ? 'You must exit charting mode to use the snapshot feature'
- : !isImageDownloadActive
- ? 'You must exit data download mode to use the snapshot feature'
- : 'Take a snapshot';
+ : activeChartingLabel;
const mobileWVImageButtonStyle = isMobile ? {
display: 'none',
} : null;
diff --git a/web/js/containers/tour.js b/web/js/containers/tour.js
index 72793acd7..df6ad8fdd 100644
--- a/web/js/containers/tour.js
+++ b/web/js/containers/tour.js
@@ -483,6 +483,10 @@ class Tour extends React.Component {
return null;
}
+ const renderModalInProgress = modalInProgress
+ ? this.renderTourInProgress()
+ : this.renderTourComplete();
+
return (
<ErrorBoundary>
<div>
@@ -498,9 +502,7 @@ class Tour extends React.Component {
)}
{modalStart
? this.renderTourStart()
- : modalInProgress
- ? this.renderTourInProgress()
- : this.renderTourComplete()}
+ : renderModalInProgress}
</div>
</ErrorBoundary>
);
diff --git a/web/js/map/compare/swipe.js b/web/js/map/compare/swipe.js
index 703765246..b44d836dc 100644
--- a/web/js/map/compare/swipe.js
+++ b/web/js/map/compare/swipe.js
@@ -76,11 +76,10 @@ const dragLine = function(listenerObjArg, lineCase, map) {
swipeOffset = evt.clientX;
}
// Prevent swiper from being swiped off screen
+ const swipeOffsetValue = swipeOffset < SWIPE_PADDING ? SWIPE_PADDING : swipeOffset;
swipeOffset = swipeOffset > windowWidth - SWIPE_PADDING
? windowWidth - SWIPE_PADDING
- : swipeOffset < SWIPE_PADDING
- ? SWIPE_PADDING
- : swipeOffset;
+ : swipeOffsetValue;
percentSwipe = swipeOffset / windowWidth;
lineCaseEl.style.transform = `translateX( ${swipeOffset}px)`;
map.render();
diff --git a/web/js/map/natural-events/util.js b/web/js/map/natural-events/util.js
index cb2e1a593..5a6fcfc1b 100644
--- a/web/js/map/natural-events/util.js
+++ b/web/js/map/natural-events/util.js
@@ -250,7 +250,8 @@ export const getClusterPointEl = function (proj, cluster, map, pointClusterObj)
if (proj.selected.id !== 'geographic') {
coordinates = olProj.transform(coordinates, CRS.GEOGRAPHIC, proj.selected.crs);
}
- const sizeClass = number < 10 ? 'small' : number < 20 ? 'medium' : 'large';
+ const pointCountSizeClass = number < 20 ? 'medium' : 'large';
+ const sizeClass = number < 10 ? 'small' : pointCountSizeClass;
overlayEl.className = 'cluster-track-marker-case track-marker-case';
textEl.className = 'cluster-track-marker-date track-marker-date';
diff --git a/web/js/modules/animation/actions.js b/web/js/modules/animation/actions.js
index 66c74a60e..1e2631832 100644
--- a/web/js/modules/animation/actions.js
+++ b/web/js/modules/animation/actions.js
@@ -54,16 +54,18 @@ export function onActivate() {
? autoTenFramesBefore : util.dateAdd(activeDate, timeScaleChangeUnit, -tenFrameDelta);
const tenFramesAfter = autoSelected
? autoTenFramesAfter : util.dateAdd(activeDate, timeScaleChangeUnit, tenFrameDelta);
+ const calculateStartDate = date.appNow < tenFramesAfter
+ ? tenFramesBefore
+ : activeDate;
const startDate = animation.startDate
? animation.startDate
- : date.appNow < tenFramesAfter
- ? tenFramesBefore
- : activeDate;
+ : calculateStartDate;
+ const calculateEndDate = date.appNow < tenFramesAfter
+ ? activeDate
+ : tenFramesAfter;
const endDate = animation.endDate
? animation.endDate
- : date.appNow < tenFramesAfter
- ? activeDate
- : tenFramesAfter;
+ : calculateEndDate;
dispatch({ type: UPDATE_START_AND_END_DATE, startDate, endDate });
}
dispatch({ type: OPEN_ANIMATION });
diff --git a/web/js/modules/animation/gifstream.js b/web/js/modules/animation/gifstream.js
index 63bbbeb36..3f29d3998 100644
--- a/web/js/modules/animation/gifstream.js
+++ b/web/js/modules/animation/gifstream.js
@@ -69,20 +69,25 @@ export default class GifStream {
waterMarkXCoordinate,
waterMarkYCoordinate,
} = options;
+ const textAlignRightGifWidth = textAlign === 'right'
+ ? gifWidth
+ : gifWidth / 2;
+ const textAlignGifWidth = textAlign === 'left'
+ ? 1
+ : textAlignRightGifWidth;
const textXCoordinate = options.textXCoordinate
? options.textXCoordinate
- : textAlign === 'left'
- ? 1
- : textAlign === 'right'
- ? gifWidth
- : gifWidth / 2;
+ : textAlignGifWidth;
+
+ const textBaselineCenterGifHeight = textBaseline === 'center'
+ ? gifHeight / 2
+ : gifHeight;
+ const textBaselineGifHeight = textBaseline === 'top'
+ ? 1
+ : textBaselineCenterGifHeight;
const textYCoordinate = options.textYCoordinate
? options.textYCoordinate
- : textBaseline === 'top'
- ? 1
- : textBaseline === 'center'
- ? gifHeight / 2
- : gifHeight;
+ : textBaselineGifHeight;
const font = `${fontWeight} ${fontSize} ${fontFamily}`;
const textToUse = frameText && options.showFrameText ? frameText : text;
diff --git a/web/js/modules/animation/util.js b/web/js/modules/animation/util.js
index bea489ae7..595f8b13e 100644
--- a/web/js/modules/animation/util.js
+++ b/web/js/modules/animation/util.js
@@ -118,11 +118,12 @@ export function getStampProps(
} else {
stampWidth = width * 0.4;
stampHeightByImageWidth = stampWidth / stampWidthRatio;
+ const largerStampHeightWidth = stampHeightByImageWidth > 60
+ ? 60
+ : stampHeightByImageWidth;
stampHeight = stampHeightByImageWidth < 20
? 20
- : stampHeightByImageWidth > 60
- ? 60
- : stampHeightByImageWidth;
+ : largerStampHeightWidth;
dateStamp.fontSize = dimensions.h > stampHeight * 1.5 ? lodashRound(stampHeight * 0.65) : 0;
dateStamp.y = height - (dateStamp.fontSize + height * 0.01) - 4;
dateStamp.x = width * 0.01;
diff --git a/web/js/modules/layers/reducers.js b/web/js/modules/layers/reducers.js
index e2bdeb9bc..07a5923ed 100644
--- a/web/js/modules/layers/reducers.js
+++ b/web/js/modules/layers/reducers.js
@@ -121,7 +121,9 @@ export function layerReducer(state = initialState, action) {
});
case ADD_LAYERS_FOR_EVENT:
- case REORDER_OVERLAY_GROUPS:
+ case REORDER_OVERLAY_GROUPS: {
+ const handleDefinedEventLayers = action?.eventLayers?.length
+ ? { $set: action.eventLayers } : { $push: [] };
return update(state, {
[compareState]: {
layers: { $set: action.layers },
@@ -129,10 +131,9 @@ export function layerReducer(state = initialState, action) {
prevLayers: { $set: [] },
},
eventLayers: action.eventLayers === undefined
- ? { $push: [] } : action.eventLayers.length
- ? { $set: action.eventLayers } : { $push: [] },
+ ? { $push: [] } : handleDefinedEventLayers,
});
-
+ }
case TOGGLE_OVERLAY_GROUPS:
return update(state, {
[compareState]: {
diff --git a/web/js/modules/layers/selectors.js b/web/js/modules/layers/selectors.js
index 8bd5efa58..544e99ee6 100644
--- a/web/js/modules/layers/selectors.js
+++ b/web/js/modules/layers/selectors.js
@@ -176,12 +176,13 @@ export const getActiveLayerGroup = (state) => {
const { active, activeString } = compare || {};
if (active) {
const layerGroups = map.ui.selected.getLayers().getArray();
+ const selectedLayerGroup = layerGroups[1]?.get('group') === activeString
+ ? layerGroups[1]
+ : map.ui.selected;
if (layerGroups.length > 1) {
return layerGroups[0].get('group') === activeString
? layerGroups[0]
- : layerGroups[1].get('group') === activeString
- ? layerGroups[1]
- : map.ui.selected;
+ : selectedLayerGroup;
}
}
return map.ui.selected;
diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.js
index 8be4fbd41..d9e284937 100644
--- a/web/js/modules/layers/util.js
+++ b/web/js/modules/layers/util.js
@@ -630,11 +630,13 @@ const getSubdailyDateRange = ({
}
let minMinuteDate;
if (rangeLimitsProvided) {
+ const hourBeforeStartDateLimitCompare = hourBeforeStartDateLimit
+ > minMinuteDateMinusIntervalOffset
+ ? hourBeforeStartDateLimit
+ : minDate;
minMinuteDate = hourBeforeStartDateLimit < minDate
? hourBeforeStartDateLimit
- : hourBeforeStartDateLimit > minMinuteDateMinusIntervalOffset
- ? hourBeforeStartDateLimit
- : minDate;
+ : hourBeforeStartDateLimitCompare;
} else {
minMinuteDate = hourBeforeStartDateLimit < minDate
? minDate
diff --git a/web/js/modules/natural-events/util.js b/web/js/modules/natural-events/util.js
index d6e3999e6..96cc86781 100644
--- a/web/js/modules/natural-events/util.js
+++ b/web/js/modules/natural-events/util.js
@@ -28,14 +28,15 @@ export function parseEvent(eventString) {
export function serializeEvent(currentItemState) {
const eventId = lodashGet(currentItemState, 'selected.id');
const eventDate = lodashGet(currentItemState, 'selected.date');
- const eventsTabActive = currentItemState.active;
+ const eventsTabActive = currentItemState.active
+ ? 'true'
+ : undefined;
+ const eventIdAndEventsTabActive = eventId && eventsTabActive
+ ? eventId
+ : eventsTabActive;
return eventsTabActive && eventDate && eventId
? [eventId, eventDate].join(',')
- : eventId && eventsTabActive
- ? eventId
- : eventsTabActive
- ? 'true'
- : undefined;
+ : eventIdAndEventsTabActive;
}
export function parseEventFilterDates(eventFilterDatesString) {
diff --git a/web/js/modules/vector-styles/selectors.js b/web/js/modules/vector-styles/selectors.js
index 7281ce241..e91fb57ad 100644
--- a/web/js/modules/vector-styles/selectors.js
+++ b/web/js/modules/vector-styles/selectors.js
@@ -224,11 +224,12 @@ export function setStyleFunction(opts) {
// Process style of feature selected/clicked in UI
if ((glStyle.name !== 'Orbit Tracks') && selectedFeatures) {
const extentStartX = layer.getExtent()[0];
+ const fallbackExtent = extentStartX === -250
+ ? [110, -90, 180, 90]
+ : null;
const acceptableExtent = extentStartX === 180
? [-180, -90, -110, 90]
- : extentStartX === -250
- ? [110, -90, 180, 90]
- : null;
+ : fallbackExtent;
layer.setStyle((feature, resolution) => {
const data = state.config.vectorData[def.vectorData.id];
diff --git a/web/js/modules/vector-styles/util.js b/web/js/modules/vector-styles/util.js
index e58f56a35..a23571212 100644
--- a/web/js/modules/vector-styles/util.js
+++ b/web/js/modules/vector-styles/util.js
@@ -168,7 +168,8 @@ export function isFeatureInRenderableArea(lon, wrap, acceptableExtent) {
if (acceptableExtent) {
return lon > acceptableExtent[0] && lon < acceptableExtent[2];
}
- return wrap === -1 ? lon < 250 && lon > 180 : wrap === 1 ? lon > -250 && lon < -180 : false;
+ const isWrap = wrap === 1 ? lon > -250 && lon < -180 : false;
+ return wrap === -1 ? lon < 250 && lon > 180 : isWrap;
}
/**
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 0ed3a4d62..61ac66501 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -666,8 +666,9 @@ export default (function(selfObj) {
if (Math.abs(longitude) < 180) return longitude;
const isNegative = longitude < 0;
const remainder = longitude % 360;
+ const remainderGT180 = !isNegative && remainder > 180 ? remainder - 360 : remainder;
return isNegative && remainder < -180
- ? remainder + 360 : !isNegative && remainder > 180 ? remainder - 360 : remainder;
+ ? remainder + 360 : remainderGT180;
};
// Allows simple printf functionality with strings