diff --git a/package.json b/package.json index adc34d19005b..09fa30bb9d02 100644 --- a/package.json +++ b/package.json @@ -178,7 +178,6 @@ "react-markdown": "^3.1.4", "react-redux": "^5.0.6", "react-router-dom": "4.2.2", - "react-select": "^1.2.0", "react-sizeme": "^2.3.6", "react-toggle": "4.0.2", "reactcss": "1.2.3", diff --git a/src/core_plugins/kibana/public/dashboard/styles/index.less b/src/core_plugins/kibana/public/dashboard/styles/index.less index 34697ed6e998..6815a423a13d 100644 --- a/src/core_plugins/kibana/public/dashboard/styles/index.less +++ b/src/core_plugins/kibana/public/dashboard/styles/index.less @@ -247,7 +247,6 @@ dashboard-viewport-provider { /** * 1. Fix Firefox bug where a value of overflow: hidden will prevent scrolling in a panel where the spy panel does * not have enough room. - * 2. react-select used in input control vis needs `visible` overflow to avoid clipping selection list */ .dashboard-panel { z-index: auto; @@ -259,7 +258,7 @@ dashboard-viewport-provider { background: @dashboard-panel-bg; color: @dashboard-panel-color; padding: 0; - overflow: visible; /* 1, 2 */ + overflow: visible; /* 1 */ position: relative; diff --git a/src/core_plugins/metrics/public/components/aggs/agg_select.js b/src/core_plugins/metrics/public/components/aggs/agg_select.js index 595bed2e0dd3..91e3c9478b15 100644 --- a/src/core_plugins/metrics/public/components/aggs/agg_select.js +++ b/src/core_plugins/metrics/public/components/aggs/agg_select.js @@ -18,8 +18,10 @@ */ import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import Select from 'react-select'; +import React from 'react'; +import { + EuiComboBox, +} from '@elastic/eui'; const metricAggs = [ { label: 'Average', value: 'avg' }, @@ -63,89 +65,12 @@ const specialAggs = [ { label: 'Math', value: 'math' }, ]; -class AggSelectOption extends Component { - constructor(props) { - super(props); - this.handleMouseMove = this.handleMouseMove.bind(this); - this.handleMouseEnter = this.handleMouseEnter.bind(this); - this.handleMouseDown = this.handleMouseDown.bind(this); - } - - handleMouseDown(event) { - event.preventDefault(); - event.stopPropagation(); - this.props.onSelect(this.props.option, event); - } - - handleMouseEnter(event) { - this.props.onFocus(this.props.option, event); - } - - handleMouseMove(event) { - if (this.props.isFocused) return; - this.props.onFocus(this.props.option, event); - } - - render() { - const { label, heading, pipeline } = this.props.option; - const style = { - paddingLeft: heading ? 0 : 10, - }; - // We can ignore that the
does not have keyboard handlers even though - // it has mouse handlers, since react-select still takes care, that this works - // well with keyboard. - /* eslint-disable jsx-a11y/no-static-element-interactions */ - if (heading) { - let note; - if (pipeline) { - note = ( - - (requires child aggregation) - - ); - } - return ( -
- - {label} - {note} - -
- ); - } - return ( -
- - {this.props.children} - -
- ); - /* eslint-enable jsx-a11y/no-static-element-interactions */ - } -} - -AggSelectOption.props = { - children: PropTypes.node, - className: PropTypes.string, - isDisabled: PropTypes.bool, - isFocused: PropTypes.bool, - isSelected: PropTypes.bool, - onFocus: PropTypes.func, - onSelect: PropTypes.func, - option: PropTypes.object.isRequired, -}; +const allAggOptions = [ + ...metricAggs, + ...pipelineAggs, + ...siblingAggs, + ...specialAggs +]; function filterByPanelType(panelType) { return agg => { @@ -155,7 +80,12 @@ function filterByPanelType(panelType) { } function AggSelect(props) { - const { siblings, panelType } = props; + const { siblings, panelType, value } = props; + + const selectedOption = allAggOptions.find(option => { + return value === option.value; + }); + const selectedOptions = selectedOption ? [selectedOption] : []; let enablePipelines = siblings.some( s => !!metricAggs.find(m => m.value === s.type) @@ -169,55 +99,39 @@ function AggSelect(props) { options = [ { label: 'Metric Aggregations', - value: null, - heading: true, - disabled: true, + options: metricAggs, }, - ...metricAggs, { label: 'Parent Pipeline Aggregations', - value: null, - pipeline: true, - heading: true, - disabled: true, + options: pipelineAggs + .filter(filterByPanelType(panelType)) + .map(agg => ({ ...agg, disabled: !enablePipelines })) }, - ...pipelineAggs - .filter(filterByPanelType(panelType)) - .map(agg => ({ ...agg, disabled: !enablePipelines })), { label: 'Sibling Pipeline Aggregations', - value: null, - pipeline: true, - heading: true, - disabled: true, + options: siblingAggs.map(agg => ({ ...agg, disabled: !enablePipelines })), }, - ...siblingAggs.map(agg => ({ ...agg, disabled: !enablePipelines })), { label: 'Special Aggregations', - value: null, - pipeline: true, - heading: true, - disabled: true, + options: specialAggs.map(agg => ({ ...agg, disabled: !enablePipelines })), }, - ...specialAggs.map(agg => ({ ...agg, disabled: !enablePipelines })), ]; } - const handleChange = value => { - if (!value) return; - if (value.disabled) return; - if (value.value) props.onChange(value); + const handleChange = selectedOptions => { + if (!selectedOptions || selectedOptions.length <= 0) return; + props.onChange(selectedOptions); }; return (
- ); } diff --git a/src/core_plugins/metrics/public/components/aggs/metric_select.js b/src/core_plugins/metrics/public/components/aggs/metric_select.js index 8247a12b96a8..fb12f085a625 100644 --- a/src/core_plugins/metrics/public/components/aggs/metric_select.js +++ b/src/core_plugins/metrics/public/components/aggs/metric_select.js @@ -20,7 +20,9 @@ import PropTypes from 'prop-types'; import React from 'react'; import _ from 'lodash'; -import Select from 'react-select'; +import { + EuiComboBox, +} from '@elastic/eui'; import calculateSiblings from '../lib/calculate_siblings'; import calculateLabel from '../../../common/calculate_label'; import basicAggs from '../../../common/basic_aggs'; @@ -86,14 +88,20 @@ function MetricSelect(props) { const label = calculateLabel(row, metrics); return { value: row.id, label }; }); + const allOptions = [...options, ...props.additionalOptions, ...percentileOptions]; + + const selectedOption = allOptions.find(option => { + return value === option.value; + }); + const selectedOptions = selectedOption ? [selectedOption] : []; return ( -
@@ -109,12 +119,13 @@ export const MovingAverageAgg = props => {
-
-
diff --git a/src/core_plugins/metrics/public/components/aggs/std_sibling.js b/src/core_plugins/metrics/public/components/aggs/std_sibling.js index 69fdaeb49a0e..4e4fe2e9e940 100644 --- a/src/core_plugins/metrics/public/components/aggs/std_sibling.js +++ b/src/core_plugins/metrics/public/components/aggs/std_sibling.js @@ -22,11 +22,13 @@ import React from 'react'; import AggRow from './agg_row'; import MetricSelect from './metric_select'; import AggSelect from './agg_select'; -import Select from 'react-select'; import createChangeHandler from '../lib/create_change_handler'; import createSelectHandler from '../lib/create_select_handler'; import createTextHandler from '../lib/create_text_handler'; -import { htmlIdGenerator } from '@elastic/eui'; +import { + htmlIdGenerator, + EuiComboBox, +} from '@elastic/eui'; export const StandardSiblingAgg = props => { const { siblings } = props; @@ -58,15 +60,19 @@ export const StandardSiblingAgg = props => { { label: 'Lower Bound', value: 'lower' }, { label: 'Bounds Band', value: 'band' } ]; + const selectedModeOption = modeOptions.find(option => { + return model.mode === option.value; + }); stdDev.mode = (
-
@@ -132,13 +141,14 @@ export const TopHitAgg = props => { -
{ - if (name === 'decimals') { - value = this.decimals; + return (selectedOptions) => { + if (selectedOptions.length < 1) { + return; } + + let newValue; + if (name === 'decimals') { + newValue = this.decimals.value; + } else { + newValue = selectedOptions[0].value; + } + this.setState({ - [name]: value.value + [name]: newValue }, () => { const { from, to, decimals } = this.state; - this.props.onChange({ + this.props.onChange([{ value: `${from},${to},${decimals}` - }); + }]); }); }; } @@ -92,39 +106,51 @@ class DataFormatPicker extends Component { { label: 'Duration', value: 'duration' }, { label: 'Custom', value: 'custom' } ]; + const selectedOption = options.find(option => { + return defaultValue === option.value; + }); let custom; if (defaultValue === 'duration') { const [from, to, decimals] = value.split(','); + const selectedFrom = durationInputOptions.find(option => { + return from === option.value; + }); + const selectedTo = durationOutputOptions.find(option => { + return to === option.value; + }); return (
{this.props.label}
-
To
-
{custom} diff --git a/src/core_plugins/metrics/public/components/icon_select.js b/src/core_plugins/metrics/public/components/icon_select.js index f10504a67c88..d56657dba682 100644 --- a/src/core_plugins/metrics/public/components/icon_select.js +++ b/src/core_plugins/metrics/public/components/icon_select.js @@ -18,79 +18,14 @@ */ import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import Select from 'react-select'; +import React from 'react'; +import { + EuiComboBox, +} from '@elastic/eui'; -class IconOption extends Component { - - constructor(props) { - super(props); - this.handleMouseMove = this.handleMouseMove.bind(this); - this.handleMouseEnter = this.handleMouseEnter.bind(this); - this.handleMouseDown = this.handleMouseDown.bind(this); - } - - handleMouseDown(event) { - event.preventDefault(); - event.stopPropagation(); - this.props.onSelect(this.props.option, event); - } - - handleMouseEnter(event) { - this.props.onFocus(this.props.option, event); - } - - handleMouseMove(event) { - if (this.props.isFocused) return; - this.props.onFocus(this.props.option, event); - } - - render() { - const icon = this.props.option.value; - const label = this.props.option.label; - // We can ignore that the
does not have keyboard handlers even though - // it has mouse handlers, since react-select still takes care, that this works - // well with keyboard. - /* eslint-disable jsx-a11y/no-static-element-interactions */ - return ( -
- - -
- ); - /* eslint-enable jsx-a11y/no-static-element-interactions */ - } - -} - -IconOption.propTypes = { - children: PropTypes.node, - className: PropTypes.string, - isDisabled: PropTypes.bool, - isFocused: PropTypes.bool, - isSelected: PropTypes.bool, - onFocus: PropTypes.func, - onSelect: PropTypes.func, - option: PropTypes.object.isRequired, -}; - - -function IconValue(props) { - const icon = props.value && props.value.value; - const label = props.value && props.value.label; +function renderOption(option) { + const icon = option.value; + const label = option.label; return (
- { props.children } + { label }
); } -IconValue.propTypes = { - children: PropTypes.node, - placeholder: PropTypes.string, - value: PropTypes.object.isRequired -}; - function IconSelect(props) { + const selectedIcon = props.icons.find(option => { + return props.value === option.value; + }); return ( -
diff --git a/src/core_plugins/metrics/public/components/panel_config/markdown.js b/src/core_plugins/metrics/public/components/panel_config/markdown.js index 995f54a2c68e..29d419b59669 100644 --- a/src/core_plugins/metrics/public/components/panel_config/markdown.js +++ b/src/core_plugins/metrics/public/components/panel_config/markdown.js @@ -22,7 +22,6 @@ import React, { Component } from 'react'; import SeriesEditor from '../series_editor'; import { IndexPattern } from '../index_pattern'; import 'brace/mode/less'; -import Select from 'react-select'; import createSelectHandler from '../lib/create_select_handler'; import createTextHandler from '../lib/create_text_handler'; import ColorPicker from '../color_picker'; @@ -30,7 +29,10 @@ import YesNo from '../yes_no'; import MarkdownEditor from '../markdown_editor'; import less from 'less/lib/less-browser'; import { KuiCodeEditor } from '@kbn/ui-framework/components'; -import { htmlIdGenerator } from '@elastic/eui'; +import { + htmlIdGenerator, + EuiComboBox, +} from '@elastic/eui'; const lessC = less(window, { env: 'production' }); class MarkdownPanelConfig extends Component { @@ -73,6 +75,9 @@ class MarkdownPanelConfig extends Component { { label: 'Middle', value: 'middle' }, { label: 'Bottom', value: 'bottom' } ]; + const selectedAlignOption = alignOptions.find(option => { + return model.markdown_vertical_align === option.value; + }); let view; if (selectedTab === 'markdown') { view = (); @@ -129,13 +134,13 @@ class MarkdownPanelConfig extends Component { Vertical Alignment
-
-
Display Grid
diff --git a/src/core_plugins/metrics/public/components/splits/group_by_select.js b/src/core_plugins/metrics/public/components/splits/group_by_select.js index b21c7c6c4f6a..8f377f03fe82 100644 --- a/src/core_plugins/metrics/public/components/splits/group_by_select.js +++ b/src/core_plugins/metrics/public/components/splits/group_by_select.js @@ -19,7 +19,9 @@ import PropTypes from 'prop-types'; import React from 'react'; -import Select from 'react-select'; +import { + EuiComboBox, +} from '@elastic/eui'; function GroupBySelect(props) { const modeOptions = [ { label: 'Everything', value: 'everything' }, @@ -27,12 +29,17 @@ function GroupBySelect(props) { { label: 'Filters', value: 'filters' }, { label: 'Terms', value: 'terms' } ]; + const selectedValue = props.value || 'everything'; + const selectedOption = modeOptions.find(option => { + return selectedValue === option.value; + }); return ( -
diff --git a/src/core_plugins/metrics/public/components/vis_types/table/config.js b/src/core_plugins/metrics/public/components/vis_types/table/config.js index a44bf35a2501..c3e3646754e5 100644 --- a/src/core_plugins/metrics/public/components/vis_types/table/config.js +++ b/src/core_plugins/metrics/public/components/vis_types/table/config.js @@ -24,10 +24,12 @@ import DataFormatPicker from '../../data_format_picker'; import createSelectHandler from '../../lib/create_select_handler'; import createTextHandler from '../../lib/create_text_handler'; import FieldSelect from '../../aggs/field_select'; -import Select from 'react-select'; import YesNo from '../../yes_no'; import ColorRules from '../../color_rules'; -import { htmlIdGenerator } from '@elastic/eui'; +import { + htmlIdGenerator, + EuiComboBox, +} from '@elastic/eui'; class TableSeriesConfig extends Component { @@ -58,6 +60,9 @@ class TableSeriesConfig extends Component { { label: 'Overall Avg', value: 'overall_avg' }, { label: 'Cumlative Sum', value: 'cumlative_sum' }, ]; + const selectedAggFuncOption = functionOptions.find(option => { + return model.aggregate_function === option.value; + }); return (
@@ -101,11 +106,12 @@ class TableSeriesConfig extends Component {
-
-
-
@@ -272,13 +291,14 @@ function TimeseriesConfig(props) { Axis Position
-