Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

derive category names from config

Jason Kente13d46e88356
diff --git a/config/default/common/config/wv.json/categories/scientific/All.json b/config/default/common/config/wv.json/categories/scientific/All.json
index d34ee7bac..37a67ef0e 100644
--- a/config/default/common/config/wv.json/categories/scientific/All.json
+++ b/config/default/common/config/wv.json/categories/scientific/All.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"All": {
"title": "All",
"id": "scientific-all",
diff --git a/config/default/common/config/wv.json/categories/scientific/Atmosphere.json b/config/default/common/config/wv.json/categories/scientific/Atmosphere.json
index 45eb6840c..240a379f8 100644
--- a/config/default/common/config/wv.json/categories/scientific/Atmosphere.json
+++ b/config/default/common/config/wv.json/categories/scientific/Atmosphere.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"Atmosphere": {
"title": "Atmosphere",
"id": "atmosphere",
diff --git a/config/default/common/config/wv.json/categories/scientific/Biosphere.json b/config/default/common/config/wv.json/categories/scientific/Biosphere.json
index b89490399..3d75e239a 100644
--- a/config/default/common/config/wv.json/categories/scientific/Biosphere.json
+++ b/config/default/common/config/wv.json/categories/scientific/Biosphere.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"Biosphere": {
"title": "Biosphere",
"id": "biosphere",
diff --git a/config/default/common/config/wv.json/categories/scientific/Cryosphere.json b/config/default/common/config/wv.json/categories/scientific/Cryosphere.json
index 74797c515..41b9742c8 100644
--- a/config/default/common/config/wv.json/categories/scientific/Cryosphere.json
+++ b/config/default/common/config/wv.json/categories/scientific/Cryosphere.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"Cryosphere": {
"title": "Cryosphere",
"id": "cryosphere",
diff --git a/config/default/common/config/wv.json/categories/scientific/Human Dimensions.json b/config/default/common/config/wv.json/categories/scientific/Human Dimensions.json
index acfcab57a..a09151856 100644
--- a/config/default/common/config/wv.json/categories/scientific/Human Dimensions.json
+++ b/config/default/common/config/wv.json/categories/scientific/Human Dimensions.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"Human Dimensions": {
"title": "Human Dimensions",
"id": "human-dimensions",
diff --git a/config/default/common/config/wv.json/categories/scientific/Land Surface.json b/config/default/common/config/wv.json/categories/scientific/Land Surface.json
index 9f02f3e12..f6eba6517 100644
--- a/config/default/common/config/wv.json/categories/scientific/Land Surface.json
+++ b/config/default/common/config/wv.json/categories/scientific/Land Surface.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"Land Surface": {
"title": "Land Surface",
"id": "land-surface",
diff --git a/config/default/common/config/wv.json/categories/scientific/Oceans.json b/config/default/common/config/wv.json/categories/scientific/Oceans.json
index 2730d5027..ec958d903 100644
--- a/config/default/common/config/wv.json/categories/scientific/Oceans.json
+++ b/config/default/common/config/wv.json/categories/scientific/Oceans.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"Oceans": {
"title": "Oceans",
"id": "oceans",
diff --git a/config/default/common/config/wv.json/categories/scientific/Other.json b/config/default/common/config/wv.json/categories/scientific/Other.json
index e25014e5b..c919dae9a 100644
--- a/config/default/common/config/wv.json/categories/scientific/Other.json
+++ b/config/default/common/config/wv.json/categories/scientific/Other.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"Other": {
"title": "Other",
"id": "scientific-other",
diff --git a/config/default/common/config/wv.json/categories/scientific/Spectral Engineering.json b/config/default/common/config/wv.json/categories/scientific/Spectral Engineering.json
index 3e33573b4..24843c22f 100644
--- a/config/default/common/config/wv.json/categories/scientific/Spectral Engineering.json
+++ b/config/default/common/config/wv.json/categories/scientific/Spectral Engineering.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"Spectral/Engineering": {
"title": "Spectral/Engineering",
"id": "spectral-engineering",
diff --git a/config/default/common/config/wv.json/categories/scientific/Terrestrial Hydrosphere.json b/config/default/common/config/wv.json/categories/scientific/Terrestrial Hydrosphere.json
index 0a9e946bf..1ab50bbe4 100644
--- a/config/default/common/config/wv.json/categories/scientific/Terrestrial Hydrosphere.json
+++ b/config/default/common/config/wv.json/categories/scientific/Terrestrial Hydrosphere.json
@@ -1,6 +1,6 @@
{
"categories": {
- "scientific": {
+ "science disciplines": {
"Terrestrial Hydrosphere": {
"title": "Terrestrial Hydrosphere",
"id": "terrestrial-hydrosphere",
diff --git a/e2e/features/layers/layer-picker-mobile-test.js b/e2e/features/layers/layer-picker-mobile-test.js
index c51c094b0..9e066f636 100644
--- a/e2e/features/layers/layer-picker-mobile-test.js
+++ b/e2e/features/layers/layer-picker-mobile-test.js
@@ -66,7 +66,7 @@ module.exports = {
},
'Clicking a measurement': (c) => {
c.click(aodAllMeasurement);
- c.waitForElementVisible(aodAllMeasurementContents, TIME_LIMIT, (e) => {
+ c.waitForElementVisible(aodAllMeasurementContents, 5000000000, (e) => {
c.expect.element(sourceMetadataCollapsed).to.be.present;
// Checkboxes for two layers are visible
c.expect.element(aodCheckboxMODIS).to.be.present;
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 995c51e51..4012e4f78 100644
--- a/web/js/components/layer/product-picker/browse/browse-layers.js
+++ b/web/js/components/layer/product-picker/browse/browse-layers.js
@@ -30,25 +30,10 @@ import {
import RecentLayersList from './recent-layers';
import safeLocalStorage from '../../../../util/local-storage';
-const CATEGORIES = [
- 'hazards and disasters',
- 'scientific',
- 'featured',
-];
-const GEOGRAPHIC_TAB_KEYS = [
- ...CATEGORIES,
-];
-const POLAR_TAB_KEYS = [
- 'measurements',
-];
-if (safeLocalStorage.enabled) {
- GEOGRAPHIC_TAB_KEYS.push('recent');
- POLAR_TAB_KEYS.push('recent');
-}
-
function BrowseLayers (props) {
const {
browser,
+ categoryTabNames,
categoryType,
mode,
width,
@@ -61,6 +46,17 @@ function BrowseLayers (props) {
clearRecentLayers,
} = props;
+ const GEOGRAPHIC_TAB_KEYS = [
+ ...categoryTabNames,
+ ];
+ const POLAR_TAB_KEYS = [
+ 'measurements',
+ ];
+ if (safeLocalStorage.enabled) {
+ GEOGRAPHIC_TAB_KEYS.push('recent');
+ POLAR_TAB_KEYS.push('recent');
+ }
+
const [dropdownOpen, setDropdownOpen] = useState(false);
const [tooltipVisible, toggleTooltip] = useState(false);
const categoryKeys = selectedProjection === 'geographic'
@@ -83,7 +79,7 @@ function BrowseLayers (props) {
toggleRecentLayersTab();
} else if (key === 'measurements') {
toggleMeasurementsTab();
- } else if (CATEGORIES.includes(key)) {
+ } else if (categoryTabNames.includes(key)) {
selectCategoryType(key);
}
};
@@ -119,7 +115,7 @@ function BrowseLayers (props) {
);
const tab = (sortKey) => (
<NavLink onClick={() => selectTab(sortKey)}>
- {sortKey === 'scientific' ? 'Science Disciplines' : sortKey}
+ {sortKey}
</NavLink>
);
@@ -218,6 +214,7 @@ function BrowseLayers (props) {
BrowseLayers.propTypes = {
browser: PropTypes.object,
+ categoryTabNames: PropTypes.array,
categoryType: PropTypes.string,
clearRecentLayers: PropTypes.func,
mode: PropTypes.string,
@@ -258,6 +255,7 @@ function mapStateToProps(state, ownProps) {
} = state;
const {
mode,
+ categoryTabNames,
categoryType,
listScrollTop,
selectedMeasurement,
@@ -268,6 +266,7 @@ function mapStateToProps(state, ownProps) {
browser,
mode,
categoryType,
+ categoryTabNames,
measurementConfig: config.measurements,
layerConfig: layers.layerConfig,
listScrollTop,
diff --git a/web/js/components/layer/product-picker/browse/category-cell.js b/web/js/components/layer/product-picker/browse/category-cell.js
index f80b3490e..aa3861866 100644
--- a/web/js/components/layer/product-picker/browse/category-cell.js
+++ b/web/js/components/layer/product-picker/browse/category-cell.js
@@ -7,7 +7,6 @@ const CategoryCell = (props) => {
measurementConfig,
drawMeasurements,
hasMeasurementSource,
- categoryType,
} = props;
const bgImage = category.image
? `images/layers/categories/${category.image}`
@@ -21,9 +20,7 @@ const CategoryCell = (props) => {
return (
<div
key={category.id}
- className={
- `layer-category layer-category${interestCssName(categoryType)}`
- }
+ className="layer-category layer-category"
id={category.id}
>
<div className="category-background-cover" style={categoryBgImage}>
@@ -98,15 +95,9 @@ const CategoryCell = (props) => {
</div>
);
};
-const interestCssName = function(name) {
- if (name === 'hazards and disasters') {
- return 'legacy';
- }
- return name;
-};
+
CategoryCell.propTypes = {
category: PropTypes.object,
- categoryType: PropTypes.string,
drawMeasurements: PropTypes.func,
hasMeasurementSource: PropTypes.func,
measurementConfig: PropTypes.object,
diff --git a/web/js/modules/product-picker/reducers.js b/web/js/modules/product-picker/reducers.js
index 13a00e70a..0660c04e9 100644
--- a/web/js/modules/product-picker/reducers.js
+++ b/web/js/modules/product-picker/reducers.js
@@ -21,10 +21,17 @@ import {
RESET_STATE,
} from './constants';
+const CATEGORY_NAMES_ORDER = [
+ 'hazards and disasters',
+ 'science disciplines',
+ 'featured',
+];
+
export const productPickerState = {
mode: 'category',
category: undefined,
- categoryType: 'hazards and disasters',
+ categoryTabNames: undefined,
+ categoryType: undefined,
filters: [],
showMobileFacets: true,
searchTerm: '',
@@ -36,8 +43,19 @@ export const productPickerState = {
recentLayers: [],
};
-export function getInitialState(config) {
- return productPickerState;
+
+export function getInitialState({ categories }) {
+ Object.keys(categories).forEach((name) => {
+ if (!CATEGORY_NAMES_ORDER.includes(name)) {
+ CATEGORY_NAMES_ORDER.push(name);
+ }
+ });
+
+ return {
+ ...productPickerState,
+ categoryType: CATEGORY_NAMES_ORDER[0],
+ categoryTabNames: CATEGORY_NAMES_ORDER,
+ };
}
export function productPickerReducer(state = productPickerState, action) {
@@ -137,7 +155,7 @@ export function productPickerReducer(state = productPickerState, action) {
selectedLayer: null,
showMobileFacets: true,
category: null,
- categoryType: 'hazards and disasters',
+ categoryType: CATEGORY_NAMES_ORDER[0],
selectedMeasurementSourceIndex: 0,
};
}
@@ -228,7 +246,7 @@ export function productPickerReducer(state = productPickerState, action) {
searchTerm: '',
selectedLayer: null,
category: null,
- categoryType: action.projection === 'geographic' ? 'hazards and disasters' : 'measurements',
+ categoryType: action.projection === 'geographic' ? CATEGORY_NAMES_ORDER[0] : 'measurements',
selectedMeasurement: null,
selectedMeasurementSourceIndex: 0,
};
diff --git a/web/js/modules/product-picker/selectors.js b/web/js/modules/product-picker/selectors.js
index c3c033706..49a78a1fe 100644
--- a/web/js/modules/product-picker/selectors.js
+++ b/web/js/modules/product-picker/selectors.js
@@ -52,7 +52,10 @@ export const getMeasurementSource = createSelector(
export const getCategoryConfig = createSelector(
[getConfig, getCategoryType],
- ({ categories }, categoryType) => (categoryType === 'measurements'
- ? categories['hazards and disasters']
- : categories[categoryType]),
+ ({ categories }, categoryType, categoryNames) => {
+ const CATEGORY_NAMES = Object.keys(categories);
+ return categoryType === 'measurements'
+ ? categories[CATEGORY_NAMES[0]]
+ : categories[categoryType];
+ },
);