Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

use oncheck instead of onclick

Jason Kenta7615c5a7799
diff --git a/web/js/components/layer/product-picker/browse/measurement-layer-row.js b/web/js/components/layer/product-picker/browse/measurement-layer-row.js
index 13084e82c..d030b2db2 100644
--- a/web/js/components/layer/product-picker/browse/measurement-layer-row.js
+++ b/web/js/components/layer/product-picker/browse/measurement-layer-row.js
@@ -36,7 +36,7 @@ function MeasurementLayerRow (props) {
const itemElementId = `checkbox-case-${layer.id.split('.').join('-')}`;
const checkboxId = `${layer.id.split('.').join('-')}-checkbox`;
- function onClick() {
+ function onCheck() {
if (isEnabled) {
removeLayer(layer.id);
} else {
@@ -53,7 +53,7 @@ function MeasurementLayerRow (props) {
<Checkbox
id={checkboxId}
name={title}
- onClick={onClick}
+ onCheck={onCheck}
checked={isEnabled}
label={title}
classNames="settings-check"
diff --git a/web/js/components/layer/settings/palette-threshold.js b/web/js/components/layer/settings/palette-threshold.js
index c38181ba7..e81e0fcb7 100644
--- a/web/js/components/layer/settings/palette-threshold.js
+++ b/web/js/components/layer/settings/palette-threshold.js
@@ -18,11 +18,7 @@ class ThresholdSelect extends React.Component {
this.updateThreshold = this.updateThreshold.bind(this);
}
- /**
- * Apply squash
- * @param {Boolean} boo
- */
- updateSquash(boo) {
+ updateSquash() {
const {
setRange, layerId, index, groupName, palette, legend,
} = this.props;
diff --git a/web/js/components/smart-handoffs/smart-handoff-modal.js b/web/js/components/smart-handoffs/smart-handoff-modal.js
index 7aa97d40b..fce8aff0c 100644
--- a/web/js/components/smart-handoffs/smart-handoff-modal.js
+++ b/web/js/components/smart-handoffs/smart-handoff-modal.js
@@ -21,12 +21,26 @@ function SmartHandoffModal({
}) {
// Hides Earthdata Search information by default
const [showMoreInfo, toggleInfo] = useState(false);
+ const { HIDE_EDS_WARNING } = safeLocalStorage.keys;
+ const [hideModal, setHideModal] = useState(safeLocalStorage.getItem(HIDE_EDS_WARNING) || false);
const {
value, title, type, version,
} = selectedCollection;
const { dateRanges } = selectedLayer;
const cmrSearchDetailURL = `https://cmr.earthdata.nasa.gov/search/concepts/${value}.html`;
+ const onCheck = () => {
+ if (!hideModal) {
+ safeLocalStorage.setItem(HIDE_EDS_WARNING, true);
+ googleTagManager.pushEvent({
+ event: 'smart_handoffs_toggle_true_hide_warning',
+ });
+ } else {
+ safeLocalStorage.removeItem(HIDE_EDS_WARNING);
+ }
+ setHideModal(!hideModal);
+ };
+
return (
<div>
@@ -127,8 +141,8 @@ function SmartHandoffModal({
<Checkbox
id="hide-eds-checkbox"
name="hide-eds"
- onCheck={() => hideModal()}
- checked={false}
+ onCheck={onCheck}
+ checked={hideModal}
color="gray"
aria-label="Do not show the Earthdata Search message again."
label="Do not show this message again."
@@ -141,18 +155,6 @@ function SmartHandoffModal({
);
}
-const hideModal = () => {
- const { HIDE_EDS_WARNING } = safeLocalStorage.keys;
- const shouldHideWarning = safeLocalStorage.getItem(HIDE_EDS_WARNING);
- if (!shouldHideWarning) {
- safeLocalStorage.setItem(HIDE_EDS_WARNING, true);
- googleTagManager.pushEvent({
- event: 'smart_handoffs_toggle_true_hide_warning',
- });
- } else {
- safeLocalStorage.removeItem(HIDE_EDS_WARNING);
- }
-};
/**
* Handle type-checking of defined properties
diff --git a/web/js/components/util/checkbox.js b/web/js/components/util/checkbox.js
index 0fe479b8b..6603e0976 100644
--- a/web/js/components/util/checkbox.js
+++ b/web/js/components/util/checkbox.js
@@ -6,71 +6,33 @@ import PropTypes from 'prop-types';
* @class Checkbox
* @extends React.Component
*/
-export default class Checkbox extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- checked: props.checked,
- };
- this.handleChange = this.handleChange.bind(this);
- this.handleClick = this.handleClick.bind(this);
- }
+export default function Checkbox (props) {
+ const {
+ onCheck, checked, isRound, color, classNames, id, name, title, label, children,
+ } = props;
- UNSAFE_componentWillReceiveProps(nextProps) {
- const { checked } = this.state;
- if (checked !== nextProps.checked) {
- this.setState({
- checked: nextProps.checked,
- });
- }
- }
+ const roundClassName = isRound ? 'wv-checkbox-round ' : '';
+ const defaultClassName = 'wv-checkbox ';
+ const checkedClassName = checked ? 'checked ' : '';
+ const caseClassName = defaultClassName + roundClassName + checkedClassName + color;
- handleClick(e) {
- const { onClick } = this.props;
- if (onClick) {
- e.stopPropagation();
- onClick(e);
- }
- }
-
- handleChange(e) {
- const { checked } = this.state;
- const { onCheck } = this.props;
- onCheck(!checked);
- this.setState({ checked: !checked });
- }
-
- render() {
- const { checked } = this.state;
- const {
- isRound, color, classNames, id, name, title, label, children,
- } = this.props;
- const roundClassName = isRound ? 'wv-checkbox-round ' : '';
- const defaultClassName = 'wv-checkbox ';
- const checkedClassName = checked ? 'checked ' : '';
- const caseClassName = defaultClassName + roundClassName + checkedClassName + color;
-
- return (
- <div
- className={caseClassName}
- onClick={this.handleClick}
- >
- <input
- type="checkbox"
- id={id}
- title={title}
- name={name}
- checked={checked}
- className={classNames}
- onChange={this.handleChange}
- />
- {children}
- <label htmlFor={id}>
- <span>{label}</span>
- </label>
- </div>
- );
- }
+ return (
+ <div className={caseClassName}>
+ <input
+ type="checkbox"
+ id={id}
+ title={title}
+ name={name}
+ checked={checked}
+ className={classNames}
+ onChange={onCheck}
+ />
+ {children}
+ <label htmlFor={id}>
+ <span>{label}</span>
+ </label>
+ </div>
+ );
}
Checkbox.defaultProps = {
checked: true,
@@ -89,6 +51,5 @@ Checkbox.propTypes = {
label: PropTypes.string,
name: PropTypes.string,
onCheck: PropTypes.func,
- onClick: PropTypes.func,
title: PropTypes.string,
};