From b6c8ea9104ac2037a8ca2cf96b5c4511a2b41426 Mon Sep 17 00:00:00 2001 From: Sebastien Corbin Date: Thu, 12 Sep 2019 17:39:50 +0200 Subject: [PATCH 1/3] Fix connect HOC on FilterPanelContent --- .../LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js b/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js index d6e07708..dccc5002 100644 --- a/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js +++ b/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js @@ -2,7 +2,9 @@ import FiltersPanelContent from './FiltersPanelContent'; import { connectLayersTree } from '../../../LayersTreeProvider/context'; -export default connectLayersTree('translate', ({ getLayerState }, { layer, layer: { exclusive, layers } }) => { +export default connectLayersTree((context, props) => { + const { getLayerState, translate } = context; + const { layer, layer: { exclusive, layers } } = props; const activeLayer = exclusive ? layers.find(l => getLayerState({ layer: l }).active) || layer : layer; @@ -10,5 +12,6 @@ export default connectLayersTree('translate', ({ getLayerState }, { layer, layer return { filtersValues: getLayerState({ layer: activeLayer }).filters || {}, activeLayer, + translate, }; })(FiltersPanelContent); From 4f923ba79804c402b368cbcb289d8669fd6c3784 Mon Sep 17 00:00:00 2001 From: Sebastien Corbin Date: Thu, 12 Sep 2019 19:12:08 +0200 Subject: [PATCH 2/3] Allow typing minus in range numeric --- src/modules/Forms/Controls/RangeNumeric.js | 1 + src/modules/Forms/Controls/RangeNumeric.test.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/Forms/Controls/RangeNumeric.js b/src/modules/Forms/Controls/RangeNumeric.js index 1aed4237..7dd85f06 100644 --- a/src/modules/Forms/Controls/RangeNumeric.js +++ b/src/modules/Forms/Controls/RangeNumeric.js @@ -12,6 +12,7 @@ class RangeNumeric extends RangeComponent { onNumericInputChange = pos => bound => { const { onChange, min, max } = this.props; const { range } = this.state; + if (Number.isNaN(+bound)) return; // Sanity check that allows typing '-' range[pos] = bound; this.setState({ range }); diff --git a/src/modules/Forms/Controls/RangeNumeric.test.js b/src/modules/Forms/Controls/RangeNumeric.test.js index c495f80b..91b75efa 100644 --- a/src/modules/Forms/Controls/RangeNumeric.test.js +++ b/src/modules/Forms/Controls/RangeNumeric.test.js @@ -8,7 +8,7 @@ jest.mock('@blueprintjs/core', () => ({ Intent: { DANGER: 'danger' }, })); -it('should handle numeric change', async () => { +it('should handle numeric change', () => { const onChange = jest.fn(); const wrapper = mount(); expect(wrapper.find('NumericInput').last().prop('value')).toBe(100); @@ -18,6 +18,13 @@ it('should handle numeric change', async () => { expect(onChange).toHaveBeenCalled(); }); +it('should allow typing minus', () => { + const instance = new RangeNumeric({}); + instance.setState = jest.fn(); + instance.onNumericInputChange(0)('-'); + expect(instance.setState).not.toHaveBeenCalled(); +}); + it('should update range numeric if props are changed', () => { const wrapper = mount(); expect(wrapper.state().range).toEqual([0, 1000]); From 937a85cfa9cafa298622259e563c1fe467158ed5 Mon Sep 17 00:00:00 2001 From: Sebastien Corbin Date: Mon, 16 Sep 2019 09:53:23 +0200 Subject: [PATCH 3/3] DX: document parameters --- .../FiltersPanel/FiltersPanelContent/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js b/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js index dccc5002..45ebcf49 100644 --- a/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js +++ b/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js @@ -2,9 +2,10 @@ import FiltersPanelContent from './FiltersPanelContent'; import { connectLayersTree } from '../../../LayersTreeProvider/context'; -export default connectLayersTree((context, props) => { - const { getLayerState, translate } = context; - const { layer, layer: { exclusive, layers } } = props; +export default connectLayersTree(( + { getLayerState, translate }, // context + { layer, layer: { exclusive, layers } }, // props +) => { const activeLayer = exclusive ? layers.find(l => getLayerState({ layer: l }).active) || layer : layer;