diff --git a/docs/user/ml/index.asciidoc b/docs/user/ml/index.asciidoc index b7bf459c39d984..a2c23aad98d5be 100644 --- a/docs/user/ml/index.asciidoc +++ b/docs/user/ml/index.asciidoc @@ -24,7 +24,7 @@ can then optionally import that data into an {es} index. You need the following permissions to use the Data Visualizer with file upload: -* cluster privileges: `monitor`, `manage_index_pipelines` +* cluster privileges: `monitor`, `manage_ingest_pipelines` * index privileges: `read`, `manage`, `index` For more information, see {ref}/security-privileges.html[Security privileges] diff --git a/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field_search.test.tsx b/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field_search.test.tsx index c207585499483f..badfbb4b14a4c1 100644 --- a/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field_search.test.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field_search.test.tsx @@ -16,13 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -import React from 'react'; +import React, { EventHandler, MouseEvent as ReactMouseEvent } from 'react'; import { act } from 'react-dom/test-utils'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; // @ts-ignore import { findTestSubject } from '@elastic/eui/lib/test'; import { DiscoverFieldSearch, Props } from './discover_field_search'; -import { EuiButtonGroupProps } from '@elastic/eui'; +import { EuiButtonGroupProps, EuiPopover } from '@elastic/eui'; import { ReactWrapper } from 'enzyme'; describe('DiscoverFieldSearch', () => { @@ -136,4 +136,44 @@ describe('DiscoverFieldSearch', () => { typeSelector.simulate('change', { target: { value: 'any' } }); expect(onChange).toBeCalledWith('type', 'any'); }); + + test('click on filter button should open and close popover', () => { + const component = mountComponent(); + const btn = findTestSubject(component, 'toggleFieldFilterButton'); + btn.simulate('click'); + let popover = component.find(EuiPopover); + expect(popover.prop('isOpen')).toBe(true); + btn.simulate('click'); + popover = component.find(EuiPopover); + expect(popover.prop('isOpen')).toBe(false); + }); + + test('click outside popover should close popover', () => { + const triggerDocumentMouseDown: EventHandler = (e: ReactMouseEvent) => { + const event = new Event('mousedown'); + // @ts-ignore + event.euiGeneratedBy = e.nativeEvent.euiGeneratedBy; + document.dispatchEvent(event); + }; + const triggerDocumentMouseUp: EventHandler = (e: ReactMouseEvent) => { + const event = new Event('mouseup'); + // @ts-ignore + event.euiGeneratedBy = e.nativeEvent.euiGeneratedBy; + document.dispatchEvent(event); + }; + const component = mountWithIntl( +
+ +
+ ); + const btn = findTestSubject(component, 'toggleFieldFilterButton'); + btn.simulate('click'); + let popover = component.find(EuiPopover); + expect(popover.length).toBe(1); + expect(popover.prop('isOpen')).toBe(true); + component.find('#wrapperId').simulate('mousedown'); + component.find('#wrapperId').simulate('mouseup'); + popover = component.find(EuiPopover); + expect(popover.prop('isOpen')).toBe(false); + }); }); diff --git a/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field_search.tsx b/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field_search.tsx index f0685c4357c5af..3d93487d9e6ccd 100644 --- a/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field_search.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field_search.tsx @@ -32,6 +32,7 @@ import { EuiForm, EuiFormRow, EuiButtonGroup, + EuiOutsideClickDetector, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; @@ -244,6 +245,7 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) { ); + return ( @@ -260,33 +262,37 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) {
- {}} - button={buttonContent} - > - - {i18n.translate('kbn.discover.fieldChooser.filter.filterByTypeLabel', { - defaultMessage: 'Filter by type', - })} - - {selectionPanel} - - {}} isDisabled={!isPopoverOpen}> + { + setPopoverOpen(false); + }} + button={buttonContent} + > + + {i18n.translate('kbn.discover.fieldChooser.filter.filterByTypeLabel', { + defaultMessage: 'Filter by type', })} - checked={values.missing} - onChange={handleMissingChange} - data-test-subj="missingSwitch" - /> - - + + {selectionPanel} + + + + +
);