Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

define category group order in configs

Jason Kent3da01ef5ef42
diff --git a/config/default/common/config/wv.json/categoryGroupOrder.json b/config/default/common/config/wv.json/categoryGroupOrder.json
new file mode 100644
index 000000000..ae60eba9f
--- /dev/null
+++ b/config/default/common/config/wv.json/categoryGroupOrder.json
@@ -0,0 +1,7 @@
+{
+ "categoryGroupOrder": [
+ "hazards and disasters",
+ "science disciplines",
+ "featured"
+ ]
+}
\ No newline at end of file
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 4012e4f78..385fe323e 100644
--- a/web/js/components/layer/product-picker/browse/browse-layers.js
+++ b/web/js/components/layer/product-picker/browse/browse-layers.js
@@ -255,7 +255,6 @@ function mapStateToProps(state, ownProps) {
} = state;
const {
mode,
- categoryTabNames,
categoryType,
listScrollTop,
selectedMeasurement,
@@ -266,7 +265,7 @@ function mapStateToProps(state, ownProps) {
browser,
mode,
categoryType,
- categoryTabNames,
+ categoryTabNames: config.categoryGroupOrder,
measurementConfig: config.measurements,
layerConfig: layers.layerConfig,
listScrollTop,
diff --git a/web/js/modules/product-picker/reducers.js b/web/js/modules/product-picker/reducers.js
index 0660c04e9..b62b18ffc 100644
--- a/web/js/modules/product-picker/reducers.js
+++ b/web/js/modules/product-picker/reducers.js
@@ -21,16 +21,11 @@ import {
RESET_STATE,
} from './constants';
-const CATEGORY_NAMES_ORDER = [
- 'hazards and disasters',
- 'science disciplines',
- 'featured',
-];
+let CATEGORY_GROUP_ORDER = [];
export const productPickerState = {
mode: 'category',
category: undefined,
- categoryTabNames: undefined,
categoryType: undefined,
filters: [],
showMobileFacets: true,
@@ -44,17 +39,19 @@ export const productPickerState = {
};
-export function getInitialState({ categories }) {
- Object.keys(categories).forEach((name) => {
- if (!CATEGORY_NAMES_ORDER.includes(name)) {
- CATEGORY_NAMES_ORDER.push(name);
- }
- });
+export function getInitialState({ categories, categoryGroupOrder }) {
+ if (Object.keys(categories).length !== categoryGroupOrder.length) {
+ throw new Error(
+ 'Number of category groups did not match defined category group order. '
+ + '\nCheck categoryGroupOrder.json',
+ );
+ }
+
+ CATEGORY_GROUP_ORDER = categoryGroupOrder;
return {
...productPickerState,
- categoryType: CATEGORY_NAMES_ORDER[0],
- categoryTabNames: CATEGORY_NAMES_ORDER,
+ categoryType: CATEGORY_GROUP_ORDER[0],
};
}
@@ -155,7 +152,7 @@ export function productPickerReducer(state = productPickerState, action) {
selectedLayer: null,
showMobileFacets: true,
category: null,
- categoryType: CATEGORY_NAMES_ORDER[0],
+ categoryType: CATEGORY_GROUP_ORDER[0],
selectedMeasurementSourceIndex: 0,
};
}
@@ -246,7 +243,7 @@ export function productPickerReducer(state = productPickerState, action) {
searchTerm: '',
selectedLayer: null,
category: null,
- categoryType: action.projection === 'geographic' ? CATEGORY_NAMES_ORDER[0] : 'measurements',
+ categoryType: action.projection === 'geographic' ? CATEGORY_GROUP_ORDER[0] : 'measurements',
selectedMeasurement: null,
selectedMeasurementSourceIndex: 0,
};