Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Only show palette options when should -- redux

Benjamin Kingdabbf39650c8
diff --git a/web/js/components/layer/settings/settings.js b/web/js/components/layer/settings/settings.js
index 634b41137..7e444f105 100644
--- a/web/js/components/layer/settings/settings.js
+++ b/web/js/components/layer/settings/settings.js
@@ -15,7 +15,8 @@ import {
getCustomPalette,
getLegends,
getPalette,
- getLegend
+ getLegend,
+ isPaletteAllowed
} from '../../../modules/palettes/selectors';
import {
setRangeAndSquash,
@@ -223,7 +224,7 @@ class LayerSettings extends React.Component {
}
}
-function mapStateToProps(state) {
+function mapStateToProps(state, ownProps) {
const { config, palettes, compare } = state;
const { supported, custom } = palettes;
const groupName = compare.activeString;
@@ -232,7 +233,7 @@ function mapStateToProps(state) {
paletteOrder: config.paletteOrder,
groupName,
customPalettesIsActive: !!config.features.customPalettes,
- palettedAllowed: supported,
+ palettedAllowed: isPaletteAllowed(ownProps.layer.id, config),
palettesTranslate,
getDefaultLegend: (layerId, index) => {
return getDefaultLegend(layerId, index, state);
diff --git a/web/js/modules/palettes/selectors.js b/web/js/modules/palettes/selectors.js
index a2fe9d6d0..0544b6a09 100644
--- a/web/js/modules/palettes/selectors.js
+++ b/web/js/modules/palettes/selectors.js
@@ -5,7 +5,7 @@ import {
parseInt as lodashParseInt,
cloneDeep as lodashCloneDeep
} from 'lodash';
-import { getMinValue, getMaxValue } from './util';
+import { getMinValue, getMaxValue, isSupported } from './util';
import update from 'immutability-helper';
/**
@@ -340,3 +340,13 @@ var prepare = function(layerId, palettesObj, state) {
});
return newPalettes;
};
+export function isPaletteAllowed(layerId, config) {
+ if (!isSupported()) {
+ return false;
+ }
+ let palette = config.layers[layerId].palette;
+ if (!palette || palette.immutable) {
+ return false;
+ }
+ return Boolean(config.layers[layerId].palette);
+}