[data.ui.query] Write filters to query log from default editor. (#74474)

This commit is contained in:
Luke Elmers 2020-08-11 09:55:09 -06:00 committed by GitHub
parent d84777f053
commit 910c883607
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 1 deletions

View file

@ -186,6 +186,44 @@ describe('QueryStringInput', () => {
expect(mockCallback).toHaveBeenCalledWith({ query: 'response:200', language: 'kuery' });
});
it('Should fire onBlur callback on input blur', () => {
const mockCallback = jest.fn();
const component = mount(
wrapQueryStringInputInContext({
query: kqlQuery,
onBlur: mockCallback,
indexPatterns: [stubIndexPatternWithFields],
disableAutoFocus: true,
})
);
const inputWrapper = component.find(EuiTextArea).find('textarea');
inputWrapper.simulate('blur');
expect(mockCallback).toHaveBeenCalledTimes(1);
expect(mockCallback).toHaveBeenCalledWith();
});
it('Should fire onChangeQueryInputFocus callback on input blur', () => {
const mockCallback = jest.fn();
const component = mount(
wrapQueryStringInputInContext({
query: kqlQuery,
onChangeQueryInputFocus: mockCallback,
indexPatterns: [stubIndexPatternWithFields],
disableAutoFocus: true,
})
);
const inputWrapper = component.find(EuiTextArea).find('textarea');
inputWrapper.simulate('blur');
expect(mockCallback).toHaveBeenCalledTimes(1);
expect(mockCallback).toHaveBeenCalledWith(false);
});
it('Should use PersistedLog for recent search suggestions', async () => {
const component = mount(
wrapQueryStringInputInContext({

View file

@ -33,7 +33,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { debounce, compact, isEqual } from 'lodash';
import { debounce, compact, isEqual, isFunction } from 'lodash';
import { Toast } from 'src/core/public';
import { IDataPluginServices, IIndexPattern, Query } from '../..';
import { QuerySuggestion, QuerySuggestionTypes } from '../../autocomplete';
@ -460,6 +460,9 @@ export class QueryStringInputUI extends Component<Props, State> {
if (this.props.onChangeQueryInputFocus) {
this.props.onChangeQueryInputFocus(false);
}
if (isFunction(this.props.onBlur)) {
this.props.onBlur();
}
};
private onClickSuggestion = (suggestion: QuerySuggestion) => {