Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Fix sidebar collapsing #1623

Benjamin Kinge87828648ae7
diff --git a/web/js/components/sidebar/provider.js b/web/js/components/sidebar/provider.js
deleted file mode 100644
index cc2ae2592..000000000
--- a/web/js/components/sidebar/provider.js
+++ /dev/null
@@ -1,59 +0,0 @@
-import React from 'react';
-import lodashIsEqual from 'lodash/isEqual';
-import PropTypes from 'prop-types';
-
-export const SidebarContext = React.createContext();
-export class SidebarProvider extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- updateLayer: props.updateLayer,
- checkerBoardPattern: props.checkerBoardPattern,
- getAvailability: props.getAvailability,
- getNames: props.getNames,
- palettePromise: props.palettePromise,
- getPalette: props.getPalette,
- runningLayers: props.runningLayers,
- getLegend: props.getLegend,
- zotsObject: props.zotsObject,
- replaceSubGroup: props.replaceSubGroup,
- isMobile: props.isMobile,
- projection: props.projection
- };
- }
- componentWillReceiveProps(props) {
- if (this.state.runningLayers !== props.runningLayers) {
- this.setState({ runningLayers: props.runningLayers });
- }
- if (!lodashIsEqual(this.state.zotsObject, props.zotsObject)) {
- this.setState({ zotsObject: props.zotsObject });
- }
- if (this.state.isMobile !== props.isMobile) {
- this.setState({ isMobile: props.isMobile });
- }
- if (this.state.projection !== props.projection) {
- this.setState({ projection: props.projection });
- }
- }
- render() {
- return (
- <SidebarContext.Provider value={this.state}>
- {this.props.children};
- </SidebarContext.Provider>
- );
- }
-}
-SidebarProvider.propTypes = {
- children: PropTypes.array,
- isMobile: PropTypes.bool,
- replaceSubGroup: PropTypes.func,
- updateLayer: PropTypes.func,
- checkerBoardPattern: PropTypes.object,
- getAvailability: PropTypes.func,
- getNames: PropTypes.func,
- palettePromise: PropTypes.func,
- runningLayers: PropTypes.object,
- getLegend: PropTypes.func,
- zotsObject: PropTypes.object,
- projection: PropTypes.string
-};
diff --git a/web/js/containers/sidebar.js b/web/js/containers/sidebar.js
index 7890bd774..a0f8d04df 100644
--- a/web/js/containers/sidebar.js
+++ b/web/js/containers/sidebar.js
@@ -165,6 +165,7 @@ class Sidebar extends React.Component {
activeTab={activeTab}
onTabClick={onTabClick}
tabTypes={tabTypes}
+ toggleSidebar={this.toggleSidebar.bind(this)}
/>
<TabContent activeTab={activeTab}>
<TabPane tabId="layers">
@@ -195,9 +196,10 @@ class Sidebar extends React.Component {
function mapStateToProps(state) {
const { browser, sidebar, compare, layers, config } = state;
const { screenHeight } = browser;
- const { activeTab } = sidebar;
+ const { activeTab, isCollapsed } = sidebar;
const { activeString } = layers;
- const numberOfLayers = getLayers(layers[activeString], {}, state).length;
+ const numberOfLayers = getLayers(layers['layers' + activeString], {}, state)
+ .length;
const tabTypes = getActiveTabs(config);
return {
@@ -207,6 +209,7 @@ function mapStateToProps(state) {
screenHeight: screenHeight,
isCompareMode: compare.active,
numberOfLayers,
+ isCollapsed,
tabTypes
};
}