Skip to content

Commit b99c516

Browse files
authored
Euify and Reactify Query Bar Component (#23704)
Implements query bar portion of https://elastic.github.io/eui/#/layout/header. Filter bar will come in another PR. Fixes #14086 Re-implements our query bar component in React using some EUI components. Existing typeahead and suggestion styles were copied over 1:1 for now after talking with Dave about it. In this PR I focused on reaching feature parity with the existing query bar. Some additional work would be needed before we could move this into EUI as a generic component that could be consumed by other plugins. Still needs some new tests and I suspect some old tests will need to be updated, but other than that this PR is functionally complete and ready for reviews.
1 parent 836b1a1 commit b99c516

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2700
-1416
lines changed

src/core_plugins/kibana/public/dashboard/dashboard_app.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@
2828
<query-bar
2929
query="model.query"
3030
app-name="'dashboard'"
31-
on-submit="updateQueryAndFetch($query)"
31+
on-submit="updateQueryAndFetch"
3232
index-patterns="indexPatterns"
33-
>
34-
</query-bar>
33+
></query-bar>
3534
</div>
3635
</div>
3736
</kbn-top-nav>

src/core_plugins/kibana/public/dashboard/dashboard_app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const app = uiModules.get('app/dashboard', [
6363
'react',
6464
'kibana/courier',
6565
'kibana/config',
66-
'kibana/typeahead',
6766
]);
6867

6968
app.directive('dashboardViewportProvider', function (reactDirective) {

src/core_plugins/kibana/public/discover/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ <h1 tabindex="0" id="kui_local_breadcrumb" class="kuiLocalBreadcrumb">
2626
<div data-transclude-slot="bottomRow" class="fullWidth">
2727
<query-bar
2828
query="state.query"
29+
on-submit="updateQueryAndFetch"
2930
app-name="'discover'"
30-
on-submit="updateQueryAndFetch($query)"
3131
index-patterns="[indexPattern]"
32-
>
33-
</query-bar>
32+
></query-bar>
3433
</div>
3534
</div>
3635
</kbn-top-nav>

src/core_plugins/kibana/public/index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@import 'ui/public/styles/styling_constants';
22

3+
@import 'ui/public/query_bar/index';
4+
35
// Context styles
46
@import './context/index';
57

src/core_plugins/kibana/public/visualize/editor/editor.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@
4040
<query-bar
4141
query="state.query"
4242
app-name="'visualize'"
43-
on-submit="updateQueryAndFetch($query)"
43+
on-submit="updateQueryAndFetch"
4444
disable-auto-focus="true"
4545
index-patterns="[indexPattern]"
46-
>
47-
</query-bar>
46+
></query-bar>
4847
</div>
4948
</div>
5049
</div>

src/ui/public/autocomplete_providers/index.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type AutocompleteProvider = (
2828
get(configKey: string): any;
2929
};
3030
indexPatterns: StaticIndexPattern[];
31-
boolFilter: any;
31+
boolFilter?: any;
3232
}
3333
) => GetSuggestions;
3434

@@ -40,10 +40,15 @@ export type GetSuggestions = (
4040
}
4141
) => Promise<AutocompleteSuggestion[]>;
4242

43-
export type AutocompleteSuggestionType = 'field' | 'value' | 'operator' | 'conjunction';
43+
export type AutocompleteSuggestionType =
44+
| 'field'
45+
| 'value'
46+
| 'operator'
47+
| 'conjunction'
48+
| 'recentSearch';
4449

4550
export interface AutocompleteSuggestion {
46-
description: string;
51+
description?: string;
4752
end: number;
4853
start: number;
4954
text: string;

src/ui/public/autoload/modules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ import '../style_compile';
4747
import '../timefilter';
4848
import '../timepicker';
4949
import '../tooltip';
50-
import '../typeahead';
5150
import '../url';
5251
import '../validate_date_interval';
5352
import '../watch_multi';
5453
import '../courier/saved_object/ui/saved_object_save_as_checkbox';
5554
import '../react_components';
5655
import '../i18n';
56+
import '../query_bar/directive';

src/ui/public/directives/__tests__/parse_query.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,23 @@ import ngMock from 'ng_mock';
2525

2626
let $rootScope;
2727
let $compile;
28-
let Private;
2928
let config;
3029
let $elemScope;
3130
let $elem;
3231

3332
let cycleIndex = 0;
3433
const markup = '<input ng-model="mockModel" parse-query input-focus type="text">';
35-
let fromUser;
3634
import { toUser } from '../../parse_query/lib/to_user';
37-
import '../../parse_query';
38-
import { ParseQueryLibFromUserProvider } from '../../parse_query/lib/from_user';
35+
import '../../parse_query/index';
36+
import { fromUser } from '../../parse_query/lib/from_user';
3937

4038
const init = function () {
4139
// Load the application
4240
ngMock.module('kibana');
4341

4442
// Create the scope
45-
ngMock.inject(function ($injector, _$rootScope_, _$compile_, _$timeout_, _Private_, _config_) {
43+
ngMock.inject(function ($injector, _$rootScope_, _$compile_, _$timeout_, _config_) {
4644
$compile = _$compile_;
47-
Private = _Private_;
4845
config = _config_;
4946

5047
// Give us a scope
@@ -77,7 +74,6 @@ describe('parse-query directive', function () {
7774
describe('user input parser', function () {
7875

7976
beforeEach(function () {
80-
fromUser = Private(ParseQueryLibFromUserProvider);
8177
config.set('query:queryString:options', {});
8278
});
8379

src/ui/public/documentation_links/documentation_links.js renamed to src/ui/public/documentation_links/documentation_links.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ export const documentationLinks = {
2929
installation: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`,
3030
configuration: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-configuration.html`,
3131
elasticsearchOutput: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/elasticsearch-output.html`,
32-
elasticsearchOutputAnchorParameters:
33-
`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/elasticsearch-output.html#_parameters`,
32+
elasticsearchOutputAnchorParameters: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/elasticsearch-output.html#_parameters`,
3433
startup: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-starting.html`,
35-
exportedFields: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/exported-fields.html`
34+
exportedFields: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/exported-fields.html`,
3635
},
3736
metricbeat: {
38-
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}`
37+
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}`,
3938
},
4039
logstash: {
41-
base: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}`
40+
base: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}`,
4241
},
4342
aggs: {
4443
date_histogram: `${ELASTIC_DOCS}search-aggregations-bucket-datehistogram-aggregation.html`,
@@ -78,19 +77,18 @@ export const documentationLinks = {
7877
painless: `${ELASTIC_DOCS}modules-scripting-painless.html`,
7978
painlessApi: `${ELASTIC_DOCS}modules-scripting-painless.html#painless-api`,
8079
painlessSyntax: `${ELASTIC_DOCS}modules-scripting-painless-syntax.html`,
81-
luceneExpressions: `${ELASTIC_DOCS}modules-scripting-expression.html`
80+
luceneExpressions: `${ELASTIC_DOCS}modules-scripting-expression.html`,
8281
},
8382
indexPatterns: {
8483
loadingData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/tutorial-load-dataset.html`,
8584
introduction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index-patterns.html`,
8685
},
8786
query: {
88-
luceneQuerySyntax:
89-
`${ELASTIC_DOCS}query-dsl-query-string-query.html#query-string-syntax`,
87+
luceneQuerySyntax: `${ELASTIC_DOCS}query-dsl-query-string-query.html#query-string-syntax`,
9088
queryDsl: `${ELASTIC_DOCS}query-dsl.html`,
9189
kueryQuerySyntax: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/kuery-query.html`,
9290
},
9391
date: {
94-
dateMath: `${ELASTIC_DOCS}common-options.html#date-math`
92+
dateMath: `${ELASTIC_DOCS}common-options.html#date-math`,
9593
},
9694
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { StaticIndexPattern } from 'ui/index_patterns';
21+
22+
interface SavedObject {
23+
attributes: {
24+
fields: string;
25+
title: string;
26+
};
27+
}
28+
29+
export function getFromLegacyIndexPattern(indexPatterns: any[]): StaticIndexPattern[];

0 commit comments

Comments
 (0)