Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

measurements tab for polar projections

Jason Kent6de4c7cc691a
diff --git a/web/css/layers.css b/web/css/layers.css
index e4f56f791..ba9445ad3 100644
--- a/web/css/layers.css
+++ b/web/css/layers.css
@@ -564,8 +564,8 @@
}
@media (min-width: 768px) {
- .category-width .search-layers-container {
- height: calc(var(--vh, 1vh) * 100 - 172px);
+ .search-layers-container {
+ height: calc(var(--vh, 1vh) * 100 - 195px);
}
.browse-search-width .search-layers-container.recent-layers {
height: calc(var(--vh, 1vh) * 100 - 235px);
diff --git a/web/js/components/layer/product-picker/browse/browse-layers-list.js b/web/js/components/layer/product-picker/browse/browse-layers-list.js
index ef0493bf8..b54e13913 100644
--- a/web/js/components/layer/product-picker/browse/browse-layers-list.js
+++ b/web/js/components/layer/product-picker/browse/browse-layers-list.js
@@ -7,6 +7,7 @@ import {
hasMeasurementSource as hasSourceSelector,
} from '../../../../modules/layers/selectors';
import getSelectedDate from '../../../../modules/date/selectors';
+import { getCategoryConfig } from '../../../../modules/product-picker/selectors';
function BrowseLayerList (props) {
const {
@@ -14,15 +15,13 @@ function BrowseLayerList (props) {
selectedMeasurement,
hasMeasurementSource,
category,
- categoryConfig,
} = props;
- const categoryToUse = category || categoryConfig.All;
return (
<div className="layer-picker-list-case layers-all">
- <div id={`${categoryToUse.id}-list`}>
+ <div id={`${category.id}-list`}>
{
// eslint-disable-next-line array-callback-return
- categoryToUse.measurements.map((measurement, index) => {
+ category.measurements.map((measurement, index) => {
const current = measurementConfig[measurement];
const isSelected = selectedMeasurement === current.id;
if (hasMeasurementSource(current)) {
@@ -31,7 +30,7 @@ function BrowseLayerList (props) {
key={current.id}
id={current.id}
index={index}
- category={categoryToUse}
+ category={category}
measurement={current}
isSelected={isSelected}
/>
@@ -46,7 +45,6 @@ function BrowseLayerList (props) {
BrowseLayerList.propTypes = {
category: PropTypes.object,
- categoryConfig: PropTypes.object,
hasMeasurementSource: PropTypes.func,
measurementConfig: PropTypes.object,
selectedMeasurement: PropTypes.string,
@@ -60,15 +58,15 @@ const mapStateToProps = (state, ownProps) => {
} = state;
const {
category,
- categoryType,
selectedMeasurement,
selectedMeasurementSourceIndex,
} = productPicker;
+ const categoryConfig = getCategoryConfig(state);
+
return {
- categoryConfig: config.categories[categoryType],
measurementConfig: config.measurements,
layerConfig: config.layers,
- category,
+ category: category || categoryConfig.All,
selectedProjection: proj.id,
selectedMeasurement,
selectedMeasurementSourceIndex,
diff --git a/web/js/components/layer/product-picker/browse/browse-layers.js b/web/js/components/layer/product-picker/browse/browse-layers.js
index bd8777f2b..e06ef0008 100644
--- a/web/js/components/layer/product-picker/browse/browse-layers.js
+++ b/web/js/components/layer/product-picker/browse/browse-layers.js
@@ -18,7 +18,8 @@ import BrowseLayerList from './browse-layers-list';
import CategoryGrid from './category-grid';
import MeasurementMetadataDetail from './measurement-metadata-detail';
import {
- selectCategory as selectCategoryAction,
+ selectCategoryType as selectCategoryAction,
+ toggleMeasurementsTab as toggleMeasurementsTabAction,
toggleFeatureTab as toggleFeatureTabAction,
toggleRecentLayersTab as toggleRecentLayersTabAction,
clearRecentLayers as clearRecentLayersAction,
@@ -28,10 +29,17 @@ import {
} from '../../../../modules/product-picker/util';
import RecentLayersList from './recent-layers';
-const CATEGORY_KEYS = [
+const CATEGORIES = [
'hazards and disasters',
'scientific',
'featured',
+];
+const GEOGRAPHIC_TAB_KEYS = [
+ ...CATEGORIES,
+ 'recent',
+];
+const POLAR_TAB_KEYS = [
+ 'measurements',
'recent',
];
@@ -40,10 +48,11 @@ function BrowseLayers (props) {
browser,
categoryType,
mode,
- selectedProjection,
width,
recentLayers,
- selectCategory,
+ selectCategoryType,
+ selectedProjection,
+ toggleMeasurementsTab,
toggleFeatureTab,
toggleRecentLayersTab,
clearRecentLayers,
@@ -51,62 +60,69 @@ function BrowseLayers (props) {
const [dropdownOpen, setDropdownOpen] = useState(false);
const [tooltipVisible, toggleTooltip] = useState(false);
+ const categoryKeys = selectedProjection === 'geographic'
+ ? GEOGRAPHIC_TAB_KEYS
+ : POLAR_TAB_KEYS;
+
+ const isCategoryDisplay = mode === 'category'
+ && selectedProjection === 'geographic'
+ && categoryType !== 'recent';
/**
* Update category type in which to show
* e.g. Hazards and disasters or science disciplines
* @param {String} key | categoryType identifier
*/
- const selectCategoryType = (key) => {
+ const selectTab = (key) => {
if (key === 'featured') {
toggleFeatureTab();
} else if (key === 'recent') {
toggleRecentLayersTab();
- } else {
- selectCategory(key);
+ } else if (key === 'measurements') {
+ toggleMeasurementsTab();
+ } else if (CATEGORIES.includes(key)) {
+ selectCategoryType(key);
}
};
- const renderContent = () => (categoryType === 'recent'
- ? (
- <RecentLayersList />
- )
- : (
- <div className="search-layers-container browse">
- <div className="layer-list-container browse">
- <div className="product-outter-list-case">
- <BrowseLayerList />
+ function renderContent () {
+ return categoryType === 'recent'
+ ? (<RecentLayersList />)
+ : (
+ <div className="search-layers-container browse">
+ <div className="layer-list-container browse">
+ <div className="product-outter-list-case">
+ <BrowseLayerList />
+ </div>
</div>
- </div>
- { !browser.lessThan.medium && (
+ { !browser.lessThan.medium && (
<div className="layer-detail-container layers-all browse">
<MeasurementMetadataDetail />
</div>
- )}
- </div>
- ));
+ )}
+ </div>
+ );
+ }
- const renderDesktopTabs = () => {
+ function renderDesktopTabs () {
const tabClass = (sortKey) => (sortKey === 'recent'
? 'recent-tab layer-category-navigation'
: 'layer-category-navigation');
-
const recentTab = (sortKey) => (
- <NavLink onClick={() => selectCategoryType(sortKey)}>
+ <NavLink onClick={() => selectTab(sortKey)}>
<FontAwesomeIcon icon={faClock} />
Recent
</NavLink>
);
-
const tab = (sortKey) => (
- <NavLink onClick={() => selectCategoryType(sortKey)}>
+ <NavLink onClick={() => selectTab(sortKey)}>
{sortKey === 'scientific' ? 'Science Disciplines' : sortKey}
</NavLink>
);
return (
<Nav id="categories-nav" className="categories-nav">
- {CATEGORY_KEYS.map((sortKey) => (
+ {categoryKeys.map((sortKey) => (
<NavItem
key={sortKey}
className={tabClass(sortKey)}
@@ -117,91 +133,82 @@ function BrowseLayers (props) {
))}
</Nav>
);
- };
+ }
- const recentLayersHeader = () => (recentLayers.length && categoryType === 'recent'
- ? (
- <div className="recent-layers-mobile-header">
- <Tooltip
- className="facet-tooltip-content"
- isOpen={tooltipVisible}
- target="recent-tooltip-target"
- placement="bottom"
- toggle={() => toggleTooltip(!tooltipVisible)}
- delay={{ show: 0, hide: 300 }}
- >
- <p>{recentLayerInfo}</p>
- <p>&nbsp;</p>
- <p>Swipe to remove layers from the list.</p>
- </Tooltip>
- <FontAwesomeIcon
- id="recent-tooltip-target"
- className="recent-tooltip-icon"
- icon={faQuestionCircle}
- />
- <Button
- size="sm"
- onClick={clearRecentLayers}
- title="Remove all layers from the recent list"
+ function recentLayersHeader() {
+ return !(recentLayers.length && categoryType === 'recent')
+ ? null
+ : (
+ <div className="recent-layers-mobile-header">
+ <Tooltip
+ className="facet-tooltip-content"
+ isOpen={tooltipVisible}
+ target="recent-tooltip-target"
+ placement="bottom"
+ toggle={() => toggleTooltip(!tooltipVisible)}
+ delay={{ show: 0, hide: 300 }}
+ >
+ <p>{recentLayerInfo}</p>
+ <p>&nbsp;</p>
+ <p>Swipe to remove layers from the list.</p>
+ </Tooltip>
+ <FontAwesomeIcon
+ id="recent-tooltip-target"
+ className="recent-tooltip-icon"
+ icon={faQuestionCircle}
+ />
+ <Button
+ size="sm"
+ onClick={clearRecentLayers}
+ title="Remove all layers from the recent list"
+ >
+ Clear List
+ </Button>
+ </div>
+ );
+ }
+
+ function renderMobileDropdown() {
+ return (
+ <div className="categories-dropdown-header">
+ <Dropdown
+ isOpen={dropdownOpen}
+ toggle={() => setDropdownOpen((prevState) => !prevState)}
+ className="categories-dropdown"
>
- Clear List
- </Button>
+ <DropdownToggle caret>
+ {categoryType === 'recent' && (<FontAwesomeIcon icon={faClock} />)}
+ {categoryType}
+ </DropdownToggle>
+ <DropdownMenu className="categories-dropdown-menu">
+ {categoryKeys.map((sortKey) => (
+ <DropdownItem
+ key={sortKey}
+ className="categories-dropdown-item"
+ onClick={() => selectTab(sortKey)}
+ >
+ {sortKey}
+ </DropdownItem>
+ ))}
+ </DropdownMenu>
+ </Dropdown>
+ {recentLayersHeader()}
</div>
- )
- : null);
-
- const renderMobileDropdown = () => (
- <div className="categories-dropdown-header">
- <Dropdown
- isOpen={dropdownOpen}
- toggle={() => setDropdownOpen((prevState) => !prevState)}
- className="categories-dropdown"
- >
- <DropdownToggle caret>
- {categoryType === 'recent' && (<FontAwesomeIcon icon={faClock} />)}
- {categoryType}
- </DropdownToggle>
- <DropdownMenu className="categories-dropdown-menu">
- {CATEGORY_KEYS.map((sortKey) => (
- <DropdownItem
- key={sortKey}
- className="categories-dropdown-item"
- onClick={() => selectCategoryType(sortKey)}
- >
- {sortKey}
- </DropdownItem>
- ))}
- </DropdownMenu>
- </Dropdown>
- {recentLayersHeader()}
- </div>
- );
-
- const isCategoryDisplay = mode === 'category'
- && selectedProjection === 'geographic'
- && categoryType !== 'recent';
- const showCategoryTabs = isCategoryDisplay
- || categoryType === 'featured'
- || categoryType === 'recent';
+ );
+ }
return (
- showCategoryTabs
- ? (
- <>
- {
- browser.lessThan.medium ? renderMobileDropdown() : renderDesktopTabs()
- }
- {
- isCategoryDisplay
- ? (
- <div className="product-outter-list-case">
- <CategoryGrid width={width} />
- </div>
- ) : renderContent()
- }
- </>
- )
- : renderContent()
+ <>
+ { browser.lessThan.medium ? renderMobileDropdown() : renderDesktopTabs() }
+ {
+ isCategoryDisplay
+ ? (
+ <div className="product-outter-list-case">
+ <CategoryGrid width={width} />
+ </div>
+ ) : renderContent()
+ }
+ </>
);
}
@@ -211,17 +218,21 @@ BrowseLayers.propTypes = {
clearRecentLayers: PropTypes.func,
mode: PropTypes.string,
recentLayers: PropTypes.array,
- selectCategory: PropTypes.func,
+ selectCategoryType: PropTypes.func,
selectedProjection: PropTypes.string,
+ toggleMeasurementsTab: PropTypes.func,
toggleFeatureTab: PropTypes.func,
toggleRecentLayersTab: PropTypes.func,
width: PropTypes.number,
};
const mapDispatchToProps = (dispatch) => ({
- selectCategory: (key) => {
+ selectCategoryType: (key) => {
dispatch(selectCategoryAction(key));
},
+ toggleMeasurementsTab: () => {
+ dispatch(toggleMeasurementsTabAction());
+ },
toggleFeatureTab: () => {
dispatch(toggleFeatureTabAction());
},
@@ -249,12 +260,10 @@ function mapStateToProps(state, ownProps) {
selectedMeasurementSourceIndex,
recentLayers,
} = productPicker;
-
return {
browser,
mode,
categoryType,
- categoryConfig: config.categories,
measurementConfig: config.measurements,
layerConfig: layers.layerConfig,
listScrollTop,
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 f15d6d802..2eb3fea83 100644
--- a/web/js/components/layer/product-picker/browse/category-grid.js
+++ b/web/js/components/layer/product-picker/browse/category-grid.js
@@ -7,6 +7,7 @@ import CategoryCell from './category-cell';
import {
showMeasurements as showMeasurementsAction,
} from '../../../../modules/product-picker/actions';
+import { getCategoryConfig } from '../../../../modules/product-picker/selectors';
import {
hasMeasurementSource as hasSourceSelector,
} from '../../../../modules/layers/selectors';
@@ -71,10 +72,10 @@ function mapStateToProps(state, ownProps) {
selectedMeasurement,
selectedMeasurementSourceIndex,
} = productPicker;
- const categoryConfig = config.categories;
+ const categoryConfig = getCategoryConfig(state);
return {
- categories: Object.values(categoryConfig[categoryType]),
+ categories: Object.values(categoryConfig),
categoryType,
category,
measurementConfig: config.measurements,
diff --git a/web/js/components/layer/product-picker/product-picker.js b/web/js/components/layer/product-picker/product-picker.js
index 1414f8f9c..ead79ccb5 100644
--- a/web/js/components/layer/product-picker/product-picker.js
+++ b/web/js/components/layer/product-picker/product-picker.js
@@ -52,10 +52,15 @@ class ProductPicker extends React.Component {
setModalClass() {
const { modalElement } = this.state;
const { mode, categoryType } = this.props;
- if ((mode === 'category' && categoryType !== 'recent') || categoryType === 'featured') {
+ if (mode === 'category' && categoryType !== 'recent') {
modalElement.classList.remove('browse-search-width');
modalElement.classList.add('category-width');
- } else if (mode === 'search' || mode === 'measurements' || categoryType === 'recent') {
+ } else if (
+ mode === 'search'
+ || mode === 'measurements'
+ || categoryType === 'recent'
+ || categoryType === 'featured'
+ ) {
modalElement.classList.remove('category-width');
modalElement.classList.add('browse-search-width');
}
diff --git a/web/js/components/layer/product-picker/search-ui-provider.js b/web/js/components/layer/product-picker/search-ui-provider.js
index 3635bcf97..51d0664cf 100644
--- a/web/js/components/layer/product-picker/search-ui-provider.js
+++ b/web/js/components/layer/product-picker/search-ui-provider.js
@@ -5,7 +5,7 @@ import {
SearchProvider,
} from '@elastic/react-search-ui';
import {
- initSearchState as initStateAction,
+ initState as initStateAction,
} from '../../../modules/product-picker/actions';
import ProductPicker from './product-picker';
diff --git a/web/js/modules/product-picker/actions.js b/web/js/modules/product-picker/actions.js
index 80cd636c7..222fa57a7 100644
--- a/web/js/modules/product-picker/actions.js
+++ b/web/js/modules/product-picker/actions.js
@@ -7,15 +7,16 @@ import {
import {
SAVE_SEARCH_STATE,
- INIT_SEARCH_STATE,
+ INIT_STATE,
COLLAPSE_FACET,
- SELECT_CATEGORY,
+ SELECT_CATEGORY_TYPE,
SELECT_MEASUREMENT,
SELECT_SOURCE,
SELECT_LAYER,
SHOW_MEASUREMENTS,
TOGGLE_FEATURED_TAB,
- TOGGLE_RECENT_LAYERS,
+ TOGGLE_MEASUREMENTS_TAB,
+ TOGGLE_RECENT_LAYERS_TAB,
TOGGLE_SEARCH_MODE,
TOGGLE_CATEGORY_MODE,
TOGGLE_MOBILE_FACETS,
@@ -24,14 +25,18 @@ import {
RESET_STATE,
} from './constants';
-export function initSearchState() {
+export function initState() {
return (dispatch, getState) => {
+ const state = getState();
+ const projection = state.proj.id;
dispatch({
- type: INIT_SEARCH_STATE,
- searchConfig: initSearch(getState()),
+ type: INIT_STATE,
+ searchConfig: initSearch(state),
+ projection,
});
};
}
+
export function saveSearchState(filters, searchTerm) {
return {
type: SAVE_SEARCH_STATE,
@@ -39,24 +44,28 @@ export function saveSearchState(filters, searchTerm) {
searchTerm,
};
}
+
export function collapseFacet(field) {
return {
type: COLLAPSE_FACET,
field,
};
}
-export function selectCategory(value) {
+
+export function selectCategoryType(value) {
return {
- type: SELECT_CATEGORY,
+ type: SELECT_CATEGORY_TYPE,
value,
};
}
+
export function selectMeasurement(value) {
return {
type: SELECT_MEASUREMENT,
value,
};
}
+
export function selectSource(value) {
return {
type: SELECT_SOURCE,
@@ -69,12 +78,14 @@ export function selectLayer(value) {
value,
};
}
+
export function showMeasurements(value) {
return {
type: SHOW_MEASUREMENTS,
value,
};
}
+
export function toggleFeatureTab() {
return (dispatch, getState) => {
dispatch({
@@ -83,38 +94,50 @@ export function toggleFeatureTab() {
});
};
}
+
+export function toggleMeasurementsTab() {
+ return {
+ type: TOGGLE_MEASUREMENTS_TAB,
+ };
+}
+
export function toggleRecentLayersTab() {
return (dispatch, getState) => {
const { layers, proj } = getState();
const { layerConfig } = layers;
dispatch({
- type: TOGGLE_RECENT_LAYERS,
+ type: TOGGLE_RECENT_LAYERS_TAB,
recentLayers: getRecentLayers(layerConfig, proj.id),
});
};
}
+
export function toggleSearchMode() {
return {
type: TOGGLE_SEARCH_MODE,
};
}
+
export function toggleCategoryMode() {
return {
type: TOGGLE_CATEGORY_MODE,
};
}
+
export function toggleMobileFacets() {
return {
type: TOGGLE_MOBILE_FACETS,
};
}
+
export function clearRecentLayers() {
clearRecentFromLocalStorage();
return {
type: CLEAR_RECENT_LAYERS,
};
}
+
export function clearSingleRecentLayer(layer) {
clearSingleRecentLayerFromLocalStorage(layer);
return (dispatch, getState) => {
@@ -127,6 +150,7 @@ export function clearSingleRecentLayer(layer) {
});
};
}
+
export function resetProductPickerState(projection) {
return {
type: RESET_STATE,
diff --git a/web/js/modules/product-picker/constants.js b/web/js/modules/product-picker/constants.js
index 5b5b9d1d1..b04a1cfbe 100644
--- a/web/js/modules/product-picker/constants.js
+++ b/web/js/modules/product-picker/constants.js
@@ -1,7 +1,7 @@
-export const INIT_SEARCH_STATE = 'PRODUCT_PICKER/INIT_SEARCH_STATE';
+export const INIT_STATE = 'PRODUCT_PICKER/INIT_STATE';
export const SAVE_SEARCH_STATE = 'PRODUCT_PICKER/SAVE_SEARCH_STATE';
export const COLLAPSE_FACET = 'PRODUCT_PICKER/COLLAPSE_FACET';
-export const SELECT_CATEGORY = 'PRODUCT_PICKER/SELECT_CATEGORY';
+export const SELECT_CATEGORY_TYPE = 'PRODUCT_PICKER/SELECT_CATEGORY_TYPE';
export const SELECT_MEASUREMENT = 'PRODUCT_PICKER/SELECT_MEASUREMENT';
export const SELECT_SOURCE = 'PRODUCT_PICKER/SELECT_SOURCE';
export const SELECT_LAYER = 'PRODUCT_PICKER/SELECT_LAYER';
@@ -9,7 +9,8 @@ export const SHOW_MEASUREMENTS = 'PRODUCT_PICKER/SHOW_MEASUREMENTS';
export const TOGGLE_SEARCH_MODE = 'PRODUCT_PICKER/TOGGLE_SEARCH_MODE';
export const TOGGLE_CATEGORY_MODE = 'PRODUCT_PICKER/TOGGLE_CATEGORY_MODE';
export const TOGGLE_FEATURED_TAB = 'PRODUCT_PICKER/TOGGLE_FEATURED_TAB';
-export const TOGGLE_RECENT_LAYERS = 'PRODUCT_PICKER/TOGGLE_RECENT_LAYERS';
+export const TOGGLE_MEASUREMENTS_TAB = 'PRODUCT_PICKER/TOGGLE_MEASUREMENTS_TAB';
+export const TOGGLE_RECENT_LAYERS_TAB = 'PRODUCT_PICKER/TOGGLE_RECENT_LAYERS';
export const TOGGLE_MOBILE_FACETS = 'PRODUCT_PICKER/TOGGLE_MOBILE_FACETS';
export const CLEAR_RECENT_LAYERS = 'PRODUCT_PICKER/CLEAR_RECENT_LAYERS';
export const CLEAR_SINGLE_RECENT_LAYER = 'PRODUCT_PICKER/CLEAR_SINGLE_RECENT_LAYER';
diff --git a/web/js/modules/product-picker/reducers.js b/web/js/modules/product-picker/reducers.js
index 18ca40882..3b9a72c2a 100644
--- a/web/js/modules/product-picker/reducers.js
+++ b/web/js/modules/product-picker/reducers.js
@@ -3,15 +3,16 @@ import { get as lodashGet } from 'lodash';
import {
SAVE_SEARCH_STATE,
- INIT_SEARCH_STATE,
+ INIT_STATE,
COLLAPSE_FACET,
- SELECT_CATEGORY,
+ SELECT_CATEGORY_TYPE,
SELECT_MEASUREMENT,
SELECT_SOURCE,
SELECT_LAYER,
SHOW_MEASUREMENTS,
TOGGLE_FEATURED_TAB,
- TOGGLE_RECENT_LAYERS,
+ TOGGLE_MEASUREMENTS_TAB,
+ TOGGLE_RECENT_LAYERS_TAB,
TOGGLE_SEARCH_MODE,
TOGGLE_CATEGORY_MODE,
TOGGLE_MOBILE_FACETS,
@@ -41,11 +42,12 @@ export function getInitialState(config) {
export function productPickerReducer(state = productPickerState, action) {
switch (action.type) {
- case INIT_SEARCH_STATE: {
- const { searchConfig } = action;
+ case INIT_STATE: {
+ const { searchConfig, projection } = action;
return {
...state,
searchConfig,
+ mode: projection === 'geographic' ? 'category' : 'measurements',
};
}
@@ -70,7 +72,7 @@ export function productPickerReducer(state = productPickerState, action) {
};
}
- case SELECT_CATEGORY: {
+ case SELECT_CATEGORY_TYPE: {
googleTagManager.pushEvent({
event: 'layers_meta_category',
layers: {
@@ -81,8 +83,10 @@ export function productPickerReducer(state = productPickerState, action) {
...state,
mode: 'category',
categoryType: action.value,
- selectedMeasurement: null,
+ category: null,
selectedLayer: null,
+ selectedMeasurement: null,
+ selectedMeasurementSourceIndex: 0,
};
}
@@ -113,7 +117,7 @@ export function productPickerReducer(state = productPickerState, action) {
googleTagManager.pushEvent({
event: 'layers_category',
layers: {
- category: category.title,
+ category: category && category.title,
},
});
return {
@@ -146,17 +150,29 @@ export function productPickerReducer(state = productPickerState, action) {
categoryType: 'featured',
category,
mode: 'measurements',
- selectedMeasurement: selectedMeasurementId,
selectedLayer: null,
+ selectedMeasurement: selectedMeasurementId,
+ selectedMeasurementSourceIndex: 0,
};
}
- case TOGGLE_RECENT_LAYERS: {
+ case TOGGLE_MEASUREMENTS_TAB: {
+ return {
+ ...state,
+ mode: 'measurements',
+ categoryType: 'measurements',
+ };
+ }
+
+ case TOGGLE_RECENT_LAYERS_TAB: {
const { recentLayers } = action;
return {
...state,
+ category: null,
categoryType: 'recent',
recentLayers,
+ selectedMeasurement: null,
+ selectedMeasurementSourceIndex: 0,
};
}
@@ -165,6 +181,8 @@ export function productPickerReducer(state = productPickerState, action) {
...state,
mode: 'category',
selectedLayer: null,
+ selectedMeasurement: null,
+ selectedMeasurementSourceIndex: 0,
};
}
@@ -208,10 +226,14 @@ export function productPickerReducer(state = productPickerState, action) {
searchTerm: '',
selectedLayer: null,
category: null,
+ categoryType: action.projection === 'geographic' ? 'hazards and disasters' : 'measurements',
selectedMeasurement: null,
selectedMeasurementSourceIndex: 0,
};
- return { ...state, ...newState };
+ return {
+ ...state,
+ ...newState,
+ };
}
default:
return state;
diff --git a/web/js/modules/product-picker/selectors.js b/web/js/modules/product-picker/selectors.js
index c70064218..c3c033706 100644
--- a/web/js/modules/product-picker/selectors.js
+++ b/web/js/modules/product-picker/selectors.js
@@ -16,6 +16,7 @@ const decodeHtml = (html) => {
const getConfig = ({ config }) => config;
const getProjection = ({ proj }) => proj && proj.id;
const getProductPicker = ({ productPicker }) => productPicker;
+const getCategoryType = ({ productPicker }) => productPicker.categoryType;
export const getLayersForProjection = createSelector(
[getConfig, getProjection, getSelectedDate],
@@ -48,3 +49,10 @@ export const getMeasurementSource = createSelector(
return sortedSources && sortedSources[selectedMeasurementSourceIndex];
},
);
+
+export const getCategoryConfig = createSelector(
+ [getConfig, getCategoryType],
+ ({ categories }, categoryType) => (categoryType === 'measurements'
+ ? categories['hazards and disasters']
+ : categories[categoryType]),
+);