Skip to content

Commit 057e93b

Browse files
author
Liza Katz
committed
Query String(Bar) Input - cleanup (#51598)
* Moved Suggestions to NP Renamed QueryBarInput to QueryStringInput Changed IndexPattern to IIndexPattern * fix import * Update snapshot * css import * scss * eslint
1 parent 89250be commit 057e93b

File tree

30 files changed

+110
-126
lines changed

30 files changed

+110
-126
lines changed

src/core/MIGRATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy';
11711171
| ------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
11721172
| `import 'ui/apply_filters'` | `import { applyFiltersPopover } from '../data/public'` | Directive is deprecated. |
11731173
| `import 'ui/filter_bar'` | `import { FilterBar } from '../data/public'` | Directive is deprecated. |
1174-
| `import 'ui/query_bar'` | `import { QueryBarInput } from '../data/public'` | Directives are deprecated. |
1174+
| `import 'ui/query_bar'` | `import { QueryStringInput } from '../data/public'` | Directives are deprecated. |
11751175
| `import 'ui/search_bar'` | `import { SearchBar } from '../data/public'` | Directive is deprecated. |
11761176
| `import 'ui/kbn_top_nav'` | `import { TopNavMenu } from '../navigation/public'` | Directive is still available in `ui/kbn_top_nav`. |
11771177
| `ui/saved_objects/components/saved_object_finder` | `import { SavedObjectFinder } from '../kibana_react/public'` | |

src/legacy/core_plugins/data/public/index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44

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

7+
@import 'src/plugins/data/public/ui/typeahead/index';
8+
79
@import './search/search_bar/index';

src/legacy/core_plugins/data/public/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export {
3737
IndexPatterns,
3838
StaticIndexPattern,
3939
} from './index_patterns';
40-
export { QueryBarInput } from './query';
40+
export { QueryStringInput } from './query';
4141
export { SearchBar, SearchBarProps, SavedQueryAttributes, SavedQuery } from './search';
4242

4343
/** @public static code */
Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
@import './query_bar';
2-
@import './typeahead/index';

src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.test.tsx

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717
* under the License.
1818
*/
1919

20-
import { mockPersistedLogFactory } from './query_bar_input.test.mocks';
20+
import { mockPersistedLogFactory } from './query_string_input.test.mocks';
2121

2222
import React from 'react';
2323
import { mount } from 'enzyme';
2424
import { QueryBarTopRow } from './query_bar_top_row';
25-
import { IndexPattern } from '../../../index';
25+
26+
/* eslint-disable @kbn/eslint/no-restricted-paths */
27+
28+
import { stubIndexPatternWithFields } from '../../../../../../../plugins/data/public/stubs';
29+
/* eslint-enable @kbn/eslint/no-restricted-paths */
2630

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

88-
const mockIndexPattern = {
89-
id: '1234',
90-
title: 'logstash-*',
91-
fields: [
92-
{
93-
name: 'response',
94-
type: 'number',
95-
esTypes: ['integer'],
96-
aggregatable: true,
97-
filterable: true,
98-
searchable: true,
99-
},
100-
],
101-
} as IndexPattern;
102-
10392
function wrapQueryBarTopRowInContext(testProps: any) {
10493
const defaultOptions = {
10594
screenTitle: 'Another Screen',
@@ -124,7 +113,7 @@ function wrapQueryBarTopRowInContext(testProps: any) {
124113
}
125114

126115
describe('QueryBarTopRowTopRow', () => {
127-
const QUERY_INPUT_SELECTOR = 'QueryBarInputUI';
116+
const QUERY_INPUT_SELECTOR = 'QueryStringInputUI';
128117
const TIMEPICKER_SELECTOR = 'EuiSuperDatePicker';
129118
const TIMEPICKER_DURATION = '[data-shared-timefilter-duration]';
130119

@@ -138,7 +127,7 @@ describe('QueryBarTopRowTopRow', () => {
138127
query: kqlQuery,
139128
screenTitle: 'Another Screen',
140129
isDirty: false,
141-
indexPatterns: [mockIndexPattern],
130+
indexPatterns: [stubIndexPatternWithFields],
142131
timeHistory: mockTimeHistory,
143132
})
144133
);
@@ -152,7 +141,7 @@ describe('QueryBarTopRowTopRow', () => {
152141
wrapQueryBarTopRowInContext({
153142
query: kqlQuery,
154143
screenTitle: 'Another Screen',
155-
indexPatterns: [mockIndexPattern],
144+
indexPatterns: [stubIndexPatternWithFields],
156145
timeHistory: mockTimeHistory,
157146
disableAutoFocus: true,
158147
isDirty: false,
@@ -225,7 +214,7 @@ describe('QueryBarTopRowTopRow', () => {
225214
const component = mount(
226215
wrapQueryBarTopRowInContext({
227216
query: kqlQuery,
228-
indexPatterns: [mockIndexPattern],
217+
indexPatterns: [stubIndexPatternWithFields],
229218
isDirty: false,
230219
screenTitle: 'Another Screen',
231220
showDatePicker: false,
@@ -245,7 +234,7 @@ describe('QueryBarTopRowTopRow', () => {
245234
query: kqlQuery,
246235
isDirty: false,
247236
screenTitle: 'Another Screen',
248-
indexPatterns: [mockIndexPattern],
237+
indexPatterns: [stubIndexPatternWithFields],
249238
showQueryInput: false,
250239
showDatePicker: false,
251240
timeHistory: mockTimeHistory,

src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
3434
import { Toast } from 'src/core/public';
3535
import {
3636
IDataPluginServices,
37+
IIndexPattern,
3738
TimeRange,
3839
TimeHistoryContract,
3940
Query,
@@ -42,8 +43,7 @@ import {
4243
esKuery,
4344
} from '../../../../../../../plugins/data/public';
4445
import { useKibana, toMountPoint } from '../../../../../../../plugins/kibana_react/public';
45-
import { IndexPattern } from '../../../index_patterns';
46-
import { QueryBarInput } from './query_bar_input';
46+
import { QueryStringInput } from './query_string_input';
4747

4848
interface Props {
4949
query?: Query;
@@ -53,7 +53,7 @@ interface Props {
5353
dataTestSubj?: string;
5454
disableAutoFocus?: boolean;
5555
screenTitle?: string;
56-
indexPatterns?: Array<IndexPattern | string>;
56+
indexPatterns?: Array<IIndexPattern | string>;
5757
intl: InjectedIntl;
5858
isLoading?: boolean;
5959
prepend?: React.ReactNode;
@@ -178,7 +178,7 @@ function QueryBarTopRowUI(props: Props) {
178178
if (!shouldRenderQueryInput()) return;
179179
return (
180180
<EuiFlexItem>
181-
<QueryBarInput
181+
<QueryStringInput
182182
disableAutoFocus={props.disableAutoFocus}
183183
indexPatterns={props.indexPatterns!}
184184
prepend={props.prepend}
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,10 @@
1717
* under the License.
1818
*/
1919

20-
const mockIndexPattern = {
21-
id: '1234',
22-
title: 'logstash-*',
23-
fields: [
24-
{
25-
name: 'response',
26-
type: 'number',
27-
esTypes: ['integer'],
28-
aggregatable: true,
29-
filterable: true,
30-
searchable: true,
31-
},
32-
],
33-
};
20+
/* eslint-disable @kbn/eslint/no-restricted-paths */
21+
22+
import { stubIndexPatternWithFields } from '../../../../../../../plugins/data/public/stubs';
23+
/* eslint-enable @kbn/eslint/no-restricted-paths */
3424

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

4434
export const mockFetchIndexPatterns = jest
4535
.fn()
46-
.mockReturnValue(Promise.resolve([mockIndexPattern]));
36+
.mockReturnValue(Promise.resolve([stubIndexPatternWithFields]));
4737

4838
jest.mock('../../../../../../../plugins/data/public/query/persisted_log', () => ({
4939
PersistedLog: mockPersistedLogFactory,

0 commit comments

Comments
 (0)