Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

change prop name to compareState

Jason Kent2a8e6967ee4c
diff --git a/web/js/components/sidebar/paletteLegend.js b/web/js/components/sidebar/paletteLegend.js
index e3f3b2387..db1165141 100644
--- a/web/js/components/sidebar/paletteLegend.js
+++ b/web/js/components/sidebar/paletteLegend.js
@@ -286,7 +286,7 @@ class PaletteLegend extends React.Component {
renderClasses(legend, legendIndex) {
const { isRunningData, colorHex, scrollContainerEl } = this.state;
const {
- layer, parentLayer, layerGroupName, getPalette,
+ layer, parentLayer, compareState, getPalette,
} = this.props;
const activeKeyObj = isRunningData && colorHex && getLegendObject(legend, colorHex, 5);
const legendClass = activeKeyObj
@@ -311,7 +311,7 @@ class PaletteLegend extends React.Component {
let palletteClass = isActiveKey ? 'wv-active wv-palettes-class' : 'wv-palettes-class';
const isSubLayer = !!parentLayer;
const parentLayerId = isSubLayer ? `-${parentLayer.id}` : '';
- const keyId = `${legend.id}-color${parentLayerId}-${layerGroupName}${keyIndex}`;
+ const keyId = `${legend.id}-color${parentLayerId}-${compareState}${keyIndex}`;
const keyLabel = activeKeyObj ? activeKeyObj.label : '';
const inActive = palette.disabled && palette.disabled.includes(keyIndex);
const tooltipText = singleKey
@@ -407,7 +407,7 @@ PaletteLegend.propTypes = {
isMobile: PropTypes.bool,
isRunningData: PropTypes.bool,
layer: PropTypes.object,
- layerGroupName: PropTypes.string,
+ compareState: PropTypes.string,
paletteId: PropTypes.string,
paletteLegends: PropTypes.array,
parentLayer: PropTypes.object,
diff --git a/web/js/containers/sidebar/compare.js b/web/js/containers/sidebar/compare.js
index 28b1abc94..49bd4fd75 100644
--- a/web/js/containers/sidebar/compare.js
+++ b/web/js/containers/sidebar/compare.js
@@ -62,7 +62,7 @@ const CompareCase = (props) => {
<Layers
isActive={isCompareA}
activeOverlays={layersA}
- layerGroupName="active"
+ compareState="active"
height={height - tabHeight}
/>
</TabPane>
@@ -70,7 +70,7 @@ const CompareCase = (props) => {
<Layers
isActive={!isCompareA}
activeOverlays={layersB}
- layerGroupName="activeB"
+ compareState="activeB"
height={height - tabHeight}
/>
</TabPane>
diff --git a/web/js/containers/sidebar/layer-list.js b/web/js/containers/sidebar/layer-list.js
index 024d28157..7406e171c 100644
--- a/web/js/containers/sidebar/layer-list.js
+++ b/web/js/containers/sidebar/layer-list.js
@@ -22,7 +22,7 @@ const reorder = (list, startIndex, endIndex) => {
function LayerList(props) {
const {
- layerGroupName,
+ compareState,
reorderLayers,
layerSplit,
activeLayers,
@@ -47,7 +47,7 @@ function LayerList(props) {
if (!destination || source.index === destination.index) {
return;
}
- const regex = new RegExp(`-${layerGroupName}$`);
+ const regex = new RegExp(`-${compareState}$`);
const layerId = draggableId.replace(regex, '');
const newLayerArray = reorder(layers, source.index, destination.index);
@@ -73,7 +73,7 @@ function LayerList(props) {
return (
<Layer
layer={layer}
- layerGroupName={layerGroupName}
+ compareState={compareState}
isInProjection={!!projections[projId]}
key={id}
index={index}
@@ -99,8 +99,8 @@ function LayerList(props) {
<DragDropContext onDragEnd={onDragEnd}>
{!collapsed && (
<Droppable
- droppableId={`${layerGroupName}-${groupId}`}
- type={`layerSubGroup${groupId}`}
+ droppableId={`${compareState}-${groupId}`}
+ type={`layerGroup${groupId}`}
direction="vertical"
>
{(provided, snapshot) => (
@@ -127,7 +127,7 @@ LayerList.propTypes = {
available: PropTypes.func,
getNames: PropTypes.func,
groupId: PropTypes.string,
- layerGroupName: PropTypes.string,
+ compareState: PropTypes.string,
layers: PropTypes.array,
layerSplit: PropTypes.number,
projId: PropTypes.string,
@@ -138,13 +138,13 @@ LayerList.propTypes = {
};
const mapStateToProps = (state, ownProps) => {
- const { layerGroupName } = ownProps;
+ const { compareState } = ownProps;
const {
proj, config, map,
} = state;
const { runningLayers } = state.layers;
const { id } = proj;
- const activeLayers = state.layers[layerGroupName];
+ const activeLayers = state.layers[compareState];
const zots = lodashGet(map, 'ui.selected')
? getZotsForActiveLayers(state)
: {};
diff --git a/web/js/containers/sidebar/layer.js b/web/js/containers/sidebar/layer.js
index 1f51efc8e..47cf4d71d 100644
--- a/web/js/containers/sidebar/layer.js
+++ b/web/js/containers/sidebar/layer.js
@@ -45,7 +45,7 @@ class Layer extends React.Component {
const {
compare,
layer,
- layerGroupName,
+ compareState,
runningObject,
paletteLegends,
getPalette,
@@ -59,13 +59,13 @@ class Layer extends React.Component {
} = this.props;
if (!lodashIsEmpty(renderedPalette)) {
const isRunningData = compare.active
- ? compare.activeString === layerGroupName && !!runningObject
+ ? compare.activeString === compareState && !!runningObject
: !!runningObject;
const colorHex = isRunningData ? runningObject.paletteHex : null;
return (
<PaletteLegend
layer={layer}
- layerGroupName={layerGroupName}
+ compareState={compareState}
paletteId={palette.id}
getPalette={getPalette}
width={zot ? 220 : 231}
@@ -116,7 +116,7 @@ class Layer extends React.Component {
renderControls() {
const {
layer,
- layerGroupName,
+ compareState,
names,
isMobile,
onRemoveClick,
@@ -124,7 +124,7 @@ class Layer extends React.Component {
onOptionsClick,
} = this.props;
const { title } = names;
- const removeLayerBtnId = `close${layerGroupName}${util.encodeId(layer.id)}`;
+ const removeLayerBtnId = `close${compareState}${util.encodeId(layer.id)}`;
const removeLayerBtnTitle = 'Remove Layer';
const layerOptionsBtnId = `layer-options-btn-${util.encodeId(layer.id)}`;
@@ -197,7 +197,7 @@ class Layer extends React.Component {
render() {
const {
- layerGroupName,
+ compareState,
isMobile,
toggleVisibility,
hover,
@@ -239,13 +239,13 @@ class Layer extends React.Component {
return (
<Draggable
- draggableId={`${util.encodeId(layer.id)}-${layerGroupName}`}
+ draggableId={`${util.encodeId(layer.id)}-${compareState}`}
index={index}
direction="vertical"
>
{(provided, snapshot) => (isInProjection ? (
<li
- id={`${layerGroupName}-${util.encodeId(layer.id)}`}
+ id={`${compareState}-${util.encodeId(layer.id)}`}
className={containerClass}
style={getItemStyle(
snapshot.isDragging,
@@ -316,7 +316,7 @@ function mapStateToProps(state, ownProps) {
const {
layer,
isVisible,
- layerGroupName,
+ compareState,
} = ownProps;
const {
palettes, config, map, layers, compare, proj,
@@ -325,10 +325,10 @@ function mapStateToProps(state, ownProps) {
const renderedPalettes = palettes.rendered;
const paletteName = lodashGet(config, `layers['${layer.id}'].palette.id`);
const paletteLegends = hasPalette && renderedPalettes[paletteName]
- ? getPaletteLegends(layer.id, layerGroupName, state)
+ ? getPaletteLegends(layer.id, compareState, state)
: [];
const isCustomPalette = hasPalette && palettes.custom[layer.id];
- const tracksForLayer = layers[layerGroupName].filter((activeLayer) => (layer.tracks || []).some((track) => activeLayer.id === track));
+ const tracksForLayer = layers[compareState].filter((activeLayer) => (layer.tracks || []).some((track) => activeLayer.id === track));
const selectedMap = lodashGet(map, 'ui.selected');
const isVector = layer.type === 'vector';
const mapRes = selectedMap ? selectedMap.getView().getResolution() : null;
@@ -342,12 +342,11 @@ function mapStateToProps(state, ownProps) {
isCustomPalette,
isLoading: palettes.isLoading[paletteName],
renderedPalette: renderedPalettes[paletteName],
- layerGroupName,
isVectorLayer: isVector,
hasClickableFeature: isVector && isVisible && isVectorLayerClickable(layer, mapRes, proj.id),
isMobile: state.browser.lessThan.medium,
hasPalette,
- getPalette: (layerId, i) => getPalette(layer.id, i, layerGroupName, state),
+ getPalette: (layerId, i) => getPalette(layer.id, i, compareState, state),
runningObject: map.runningDataObj[layer.id],
};
}
@@ -431,7 +430,7 @@ Layer.propTypes = {
isVisible: PropTypes.bool,
layer: PropTypes.object,
layerClasses: PropTypes.string,
- layerGroupName: PropTypes.string,
+ compareState: PropTypes.string,
names: PropTypes.object,
onInfoClick: PropTypes.func,
onOptionsClick: PropTypes.func,
diff --git a/web/js/containers/sidebar/layers.js b/web/js/containers/sidebar/layers.js
index 050b1082f..5099b0e0b 100644
--- a/web/js/containers/sidebar/layers.js
+++ b/web/js/containers/sidebar/layers.js
@@ -1,5 +1,6 @@
import React from 'react';
import { connect } from 'react-redux';
+import { Droppable, DragDropContext } from 'react-beautiful-dnd';
import PropTypes from 'prop-types';
import LayerList from './layer-list';
import { getLayers } from '../../modules/layers/selectors';
@@ -27,7 +28,7 @@ function Layers (props) {
overlays,
baselayers,
isActive,
- layerGroupName,
+ compareState,
height,
layerSplit,
} = props;
@@ -36,20 +37,38 @@ function Layers (props) {
return isActive && (
<Scrollbars style={{ maxHeight: `${height}px` }}>
<div className={outterClass}>
- {Object.keys(overlays).map((groupName) => (
- <LayerList
- key={groupName}
- title={groupName}
- groupId={groupName}
- layerGroupName={layerGroupName}
- layerSplit={layerSplit}
- layers={overlays[groupName]}
- />
- ))}
+ <DragDropContext onDragEnd={() => { console.log('dropped'); }}>
+ <Droppable
+ droppableId="layerGroup"
+ type="overlayGroups"
+ direction="vertical"
+ >
+ {(provided, snapshot) => (
+ <ul
+ id=""
+ ref={provided.innerRef}
+ // eslint-disable-next-line react/jsx-props-no-spreading
+ {...provided.droppableProps}
+ >
+ {Object.keys(overlays).map((groupName) => (
+ <LayerList
+ key={groupName}
+ title={groupName}
+ groupId={groupName}
+ compareState={compareState}
+ layerSplit={layerSplit}
+ layers={overlays[groupName]}
+ />
+ ))}
+ {provided.placeholder}
+ </ul>
+ )}
+ </Droppable>
+ </DragDropContext>
<LayerList
title="Base Layers"
groupId="baselayers"
- layerGroupName={layerGroupName}
+ compareState={compareState}
layers={baselayers}
layerSplit={layerSplit}
/>
@@ -60,8 +79,8 @@ function Layers (props) {
const mapStateToProps = (state, ownProps) => {
const { layers, proj } = state;
- const { layerGroupName } = ownProps;
- const componentLayers = layers[layerGroupName];
+ const { compareState } = ownProps;
+ const componentLayers = layers[compareState];
const layerObj = getLayers(componentLayers, { proj: proj.id, group: 'all' });
const overlays = getGroupedLayers(layerObj.overlays);
@@ -69,7 +88,6 @@ const mapStateToProps = (state, ownProps) => {
baselayers: layerObj.baselayers,
overlays,
layerSplit: layerObj.overlays.length,
- layerGroupName,
};
};
@@ -82,7 +100,7 @@ Layers.propTypes = {
baselayers: PropTypes.array,
height: PropTypes.number,
isActive: PropTypes.bool,
- layerGroupName: PropTypes.string,
+ compareState: PropTypes.string,
layerSplit: PropTypes.number,
overlays: PropTypes.object,
};
diff --git a/web/js/containers/sidebar/orbit-track.js b/web/js/containers/sidebar/orbit-track.js
index a1e87710f..dbf4679c5 100644
--- a/web/js/containers/sidebar/orbit-track.js
+++ b/web/js/containers/sidebar/orbit-track.js
@@ -70,14 +70,14 @@ OrbitTrack.propTypes = {
function mapStateToProps(state, ownProps) {
const {
trackLayer,
- layerGroupName,
+ compareState,
} = ownProps;
const { palettes, config } = state;
const renderedPalettes = palettes.rendered;
const hasPalette = !lodashIsEmpty(trackLayer.palette);
const paletteName = lodashGet(config, `layers['${trackLayer.id}'].palette.id`);
const paletteLegends = hasPalette && renderedPalettes[paletteName]
- ? getPaletteLegends(trackLayer.id, layerGroupName, state)
+ ? getPaletteLegends(trackLayer.id, compareState, state)
: [];
const isCustomPalette = hasPalette && palettes.custom[trackLayer.id];
@@ -89,7 +89,7 @@ function mapStateToProps(state, ownProps) {
renderedPalette: renderedPalettes[paletteName],
isMobile: state.browser.lessThan.medium,
hasPalette,
- getPalette: (layerId, index) => getPalette(trackLayer.id, index, layerGroupName, state),
+ getPalette: (layerId, index) => getPalette(trackLayer.id, index, compareState, state),
};
}
diff --git a/web/js/containers/sidebar/sidebar.js b/web/js/containers/sidebar/sidebar.js
index 24debb3c7..89b3afb63 100644
--- a/web/js/containers/sidebar/sidebar.js
+++ b/web/js/containers/sidebar/sidebar.js
@@ -150,7 +150,7 @@ class Sidebar extends React.Component {
<Layers
height={subComponentHeight - 20}
isActive={activeTab === 'layers'}
- layerGroupName={activeString}
+ compareState={activeString}
/>
);
}