Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Bug] Hide BottomWidgetContainer nothing to render (#1213)
Shan He0145069f3d96
diff --git a/examples/webpack.config.local.js b/examples/webpack.config.local.jsindex 28807ce80..dc81e5917 100644--- a/examples/webpack.config.local.js+++ b/examples/webpack.config.local.js@@ -259,7 +259,7 @@ module.exports = (exampleConfig, exampleDir) => env => {'probe.gl': results[3]})).then(externals => {- let config = addLocalDevSettings(env, exampleConfig, exampleDir, externals);+ const config = addLocalDevSettings(env, exampleConfig, exampleDir, externals);return addBabelSettings(env, config, exampleDir, externals);});};diff --git a/src/components/bottom-widget.js b/src/components/bottom-widget.jsindex 4a4361212..1b15d30fc 100644--- a/src/components/bottom-widget.js+++ b/src/components/bottom-widget.js@@ -84,19 +84,25 @@ export default function BottomWidgetFactory(TimeWidget, AnimationControl) {const readToAnimation = Array.isArray(animationConfig.domain) && animationConfig.currentTime;// if animation control is showing, hide time display in time sliderconst showFloatingTimeDisplay = !animatedLayer.length;+ const showAnimationControl = animatedLayer.length && readToAnimation;+ const showTimeWidget = enlargedFilterIdx > -1 && Object.keys(datasets).length > 0;+ // The bottom widget can hide clickable elements so do not render it if not needed+ if (!showAnimationControl && !showTimeWidget) {+ return null;+ }return (<BottomWidgetContainerwidth={Math.min(maxWidth, enlargedFilterWidth)}className="bottom-widget--container">- {animatedLayer.length && readToAnimation ? (+ {showAnimationControl ? (<AnimationControlanimationConfig={animationConfig}updateAnimationTime={visStateActions.updateAnimationTime}updateAnimationSpeed={visStateActions.updateLayerAnimationSpeed}/>) : null}- {enlargedFilterIdx > -1 && Object.keys(datasets).length > 0 ? (+ {showTimeWidget ? (<TimeWidgetfilter={filters[enlargedFilterIdx]}index={enlargedFilterIdx}diff --git a/test/browser/components/bottom-widget-test.js b/test/browser/components/bottom-widget-test.jsnew file mode 100644index 000000000..b2ce78c8f--- /dev/null+++ b/test/browser/components/bottom-widget-test.js@@ -0,0 +1,62 @@+// Copyright (c) 2020 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++import React from 'react';+import test from 'tape';+import {IntlWrapper, mountWithTheme} from 'test/helpers/component-utils';+import BottomWidgetFactory from 'components/bottom-widget';+import {appInjector} from 'components/container';++const BottomWidget = appInjector.get(BottomWidgetFactory);++import * as VisStateActions from 'actions/vis-state-actions';++// mock state+import {InitialState} from 'test/helpers/mock-state';++// default props from initial state+const defaultProps = {+ datasets: InitialState.visState.datasets,+ filters: InitialState.visState.filters,+ layers: InitialState.visState.layers,+ animationConfig: InitialState.visState.animationConfig,+ uiState: InitialState.uiState,+ containerW: 900,+ sidePanelWidth: 300,+ visStateActions: VisStateActions+};++test('Components -> BottomWidget.mount -> initial state', t => {+ let wrapper;++ t.doesNotThrow(() => {+ wrapper = mountWithTheme(+ <IntlWrapper>+ <BottomWidget {...defaultProps} />+ </IntlWrapper>+ );+ }, 'BottomWidget should not fail without props');+ t.equal(+ wrapper.find('div').length,+ 0,+ 'should not render anything when layers and filters are empty'+ );+ t.end();+});diff --git a/test/browser/components/index.js b/test/browser/components/index.jsindex e24ca3ae3..7412f6cd7 100644--- a/test/browser/components/index.js+++ b/test/browser/components/index.js@@ -32,3 +32,4 @@ import './editor';import './map-container-test';import './geocoder-panel-test';import './tooltip-config-test';+import './bottom-widget-test';