Skip to content

Commit

Permalink
Query String(Bar) Input - cleanup (elastic#51598)
Browse files Browse the repository at this point in the history
* Moved Suggestions to NP
Renamed QueryBarInput to QueryStringInput
Changed IndexPattern to IIndexPattern

* fix import

* Update snapshot

* css import

* scss

* eslint
  • Loading branch information
Liza Katz committed Nov 27, 2019
1 parent 89250be commit 057e93b
Show file tree
Hide file tree
Showing 30 changed files with 110 additions and 126 deletions.
2 changes: 1 addition & 1 deletion src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy';
| ------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `import 'ui/apply_filters'` | `import { applyFiltersPopover } from '../data/public'` | Directive is deprecated. |
| `import 'ui/filter_bar'` | `import { FilterBar } from '../data/public'` | Directive is deprecated. |
| `import 'ui/query_bar'` | `import { QueryBarInput } from '../data/public'` | Directives are deprecated. |
| `import 'ui/query_bar'` | `import { QueryStringInput } from '../data/public'` | Directives are deprecated. |
| `import 'ui/search_bar'` | `import { SearchBar } from '../data/public'` | Directive is deprecated. |
| `import 'ui/kbn_top_nav'` | `import { TopNavMenu } from '../navigation/public'` | Directive is still available in `ui/kbn_top_nav`. |
| `ui/saved_objects/components/saved_object_finder` | `import { SavedObjectFinder } from '../kibana_react/public'` | |
Expand Down
2 changes: 2 additions & 0 deletions src/legacy/core_plugins/data/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

@import 'src/plugins/data/public/ui/filter_bar/index';

@import 'src/plugins/data/public/ui/typeahead/index';

@import './search/search_bar/index';
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export {
IndexPatterns,
StaticIndexPattern,
} from './index_patterns';
export { QueryBarInput } from './query';
export { QueryStringInput } from './query';
export { SearchBar, SearchBarProps, SavedQueryAttributes, SavedQuery } from './search';

/** @public static code */
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
@import './query_bar';
@import './typeahead/index';
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
* under the License.
*/

import { mockPersistedLogFactory } from './query_bar_input.test.mocks';
import { mockPersistedLogFactory } from './query_string_input.test.mocks';

import React from 'react';
import { mount } from 'enzyme';
import { QueryBarTopRow } from './query_bar_top_row';
import { IndexPattern } from '../../../index';

/* eslint-disable @kbn/eslint/no-restricted-paths */

import { stubIndexPatternWithFields } from '../../../../../../../plugins/data/public/stubs';
/* eslint-enable @kbn/eslint/no-restricted-paths */

import { coreMock } from '../../../../../../../core/public/mocks';
import { KibanaContextProvider } from 'src/plugins/kibana_react/public';
Expand Down Expand Up @@ -85,21 +89,6 @@ const createMockStorage = () => ({
clear: jest.fn(),
});

const mockIndexPattern = {
id: '1234',
title: 'logstash-*',
fields: [
{
name: 'response',
type: 'number',
esTypes: ['integer'],
aggregatable: true,
filterable: true,
searchable: true,
},
],
} as IndexPattern;

function wrapQueryBarTopRowInContext(testProps: any) {
const defaultOptions = {
screenTitle: 'Another Screen',
Expand All @@ -124,7 +113,7 @@ function wrapQueryBarTopRowInContext(testProps: any) {
}

describe('QueryBarTopRowTopRow', () => {
const QUERY_INPUT_SELECTOR = 'QueryBarInputUI';
const QUERY_INPUT_SELECTOR = 'QueryStringInputUI';
const TIMEPICKER_SELECTOR = 'EuiSuperDatePicker';
const TIMEPICKER_DURATION = '[data-shared-timefilter-duration]';

Expand All @@ -138,7 +127,7 @@ describe('QueryBarTopRowTopRow', () => {
query: kqlQuery,
screenTitle: 'Another Screen',
isDirty: false,
indexPatterns: [mockIndexPattern],
indexPatterns: [stubIndexPatternWithFields],
timeHistory: mockTimeHistory,
})
);
Expand All @@ -152,7 +141,7 @@ describe('QueryBarTopRowTopRow', () => {
wrapQueryBarTopRowInContext({
query: kqlQuery,
screenTitle: 'Another Screen',
indexPatterns: [mockIndexPattern],
indexPatterns: [stubIndexPatternWithFields],
timeHistory: mockTimeHistory,
disableAutoFocus: true,
isDirty: false,
Expand Down Expand Up @@ -225,7 +214,7 @@ describe('QueryBarTopRowTopRow', () => {
const component = mount(
wrapQueryBarTopRowInContext({
query: kqlQuery,
indexPatterns: [mockIndexPattern],
indexPatterns: [stubIndexPatternWithFields],
isDirty: false,
screenTitle: 'Another Screen',
showDatePicker: false,
Expand All @@ -245,7 +234,7 @@ describe('QueryBarTopRowTopRow', () => {
query: kqlQuery,
isDirty: false,
screenTitle: 'Another Screen',
indexPatterns: [mockIndexPattern],
indexPatterns: [stubIndexPatternWithFields],
showQueryInput: false,
showDatePicker: false,
timeHistory: mockTimeHistory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import { Toast } from 'src/core/public';
import {
IDataPluginServices,
IIndexPattern,
TimeRange,
TimeHistoryContract,
Query,
Expand All @@ -42,8 +43,7 @@ import {
esKuery,
} from '../../../../../../../plugins/data/public';
import { useKibana, toMountPoint } from '../../../../../../../plugins/kibana_react/public';
import { IndexPattern } from '../../../index_patterns';
import { QueryBarInput } from './query_bar_input';
import { QueryStringInput } from './query_string_input';

interface Props {
query?: Query;
Expand All @@ -53,7 +53,7 @@ interface Props {
dataTestSubj?: string;
disableAutoFocus?: boolean;
screenTitle?: string;
indexPatterns?: Array<IndexPattern | string>;
indexPatterns?: Array<IIndexPattern | string>;
intl: InjectedIntl;
isLoading?: boolean;
prepend?: React.ReactNode;
Expand Down Expand Up @@ -178,7 +178,7 @@ function QueryBarTopRowUI(props: Props) {
if (!shouldRenderQueryInput()) return;
return (
<EuiFlexItem>
<QueryBarInput
<QueryStringInput
disableAutoFocus={props.disableAutoFocus}
indexPatterns={props.indexPatterns!}
prepend={props.prepend}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,10 @@
* under the License.
*/

const mockIndexPattern = {
id: '1234',
title: 'logstash-*',
fields: [
{
name: 'response',
type: 'number',
esTypes: ['integer'],
aggregatable: true,
filterable: true,
searchable: true,
},
],
};
/* eslint-disable @kbn/eslint/no-restricted-paths */

import { stubIndexPatternWithFields } from '../../../../../../../plugins/data/public/stubs';
/* eslint-enable @kbn/eslint/no-restricted-paths */

export const mockPersistedLog = {
add: jest.fn(),
Expand All @@ -43,7 +33,7 @@ export const mockPersistedLogFactory = jest.fn<jest.Mocked<typeof mockPersistedL

export const mockFetchIndexPatterns = jest
.fn()
.mockReturnValue(Promise.resolve([mockIndexPattern]));
.mockReturnValue(Promise.resolve([stubIndexPatternWithFields]));

jest.mock('../../../../../../../plugins/data/public/query/persisted_log', () => ({
PersistedLog: mockPersistedLogFactory,
Expand Down
Loading

0 comments on commit 057e93b

Please sign in to comment.