Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate filter bar to React, EUI, and Typescript #25563

Merged
merged 104 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
a61269e
basic groundwork for filter bar euification
Bargs Nov 6, 2018
9c293bf
filter item placeholder
Bargs Nov 6, 2018
812407a
filter item placeholder file I missed
Bargs Nov 6, 2018
7255785
create initial filter class
Bargs Nov 6, 2018
fceda5f
refine usage of Filter class in FilterBar
Bargs Nov 7, 2018
648081e
wire up the callbacks for the FilterItem
Bargs Nov 8, 2018
95a8d09
forgot filter deletion
Bargs Nov 8, 2018
0dce26d
clean up filter refactorings
Bargs Nov 12, 2018
cebe76e
hook up delete button
Bargs Nov 12, 2018
79ed162
fix callbacks, try Object.create
Bargs Nov 13, 2018
f76a0ee
move filter_bar_filter.js up a directory
Bargs Nov 13, 2018
f302424
enable easy changes to the underlying metafilter filter
Bargs Nov 13, 2018
fe3c0ad
establishing pattern for creating views of filters
Bargs Nov 13, 2018
6baeb40
further filter view refinements
Bargs Nov 13, 2018
a7abc70
use interface to ensure a filter type supports all required views
Bargs Nov 13, 2018
fcd2d6e
add some style 😎
Bargs Nov 14, 2018
6e15773
create search bar component to wrap query bar and filter bar together
Bargs Nov 15, 2018
0ca4911
add filter total and visibility toggle button to the search bar
Bargs Nov 15, 2018
4dad850
add "all filters" actions
Bargs Nov 15, 2018
9436a01
foundation for filter editor
Bargs Nov 16, 2018
967f97f
recreated filter editor mockup in TS as a starting point
Bargs Nov 16, 2018
cc68d0e
Fix import path
lukasolson Dec 4, 2018
e360cce
Fix unresolved merge conflict
lukasolson Dec 5, 2018
ebbde92
Fix injecting i18n provider
lukasolson Dec 6, 2018
692604d
Hook up search bar to actual filters
lukasolson Dec 19, 2018
5ea40de
Watch by reference so pin/unpin triggers changes
lukasolson Dec 19, 2018
bd0f10c
Add phrase filter editor
lukasolson Jan 2, 2019
f0e2525
Update index pattern type def
lukasolson Jan 2, 2019
80732b7
Add filter dialog
lukasolson Jan 4, 2019
31a2988
Add phrases editor
lukasolson Jan 4, 2019
e6f0604
Partially implemented the type specific input component. Still need to
Bargs Jan 5, 2019
71a4975
Add query DSL editor
lukasolson Jan 5, 2019
6eb75a1
Merge remote-tracking branch 'Bargs/euifyFilterBar' into euifyFilterBar
lukasolson Jan 7, 2019
190ec9e
Adds in value suggestions for phrase and phrases filter editors
lukasolson Jan 7, 2019
9def223
Add new filter bar to visualize/dashboard
lukasolson Jan 7, 2019
4991692
Account for fields that are mapped as numbers but have string values in
Bargs Jan 8, 2019
ecd0b85
validate date math expressions
Bargs Jan 8, 2019
25910b5
validate IP inputs
Bargs Jan 9, 2019
63e2e6d
make user pick the value they want. This is more in line with how the…
Bargs Jan 9, 2019
92a9402
Add apply filter popover
lukasolson Jan 10, 2019
1893e75
Remove old filter bar from dashboard
lukasolson Jan 10, 2019
969c08c
range filter editor
Bargs Jan 11, 2019
3b77a29
better form validation for filter params input
Bargs Jan 11, 2019
7268bd7
fix date validation
Bargs Jan 11, 2019
1de48fe
add index pattern input
Bargs Jan 11, 2019
9e5cb18
Internationalize all of the text
lukasolson Jan 14, 2019
518e103
Fix angular digest stuff
lukasolson Jan 14, 2019
703f664
auto tab in filter editor
Bargs Jan 14, 2019
aa842f4
Fix empty index patterns list
lukasolson Jan 14, 2019
84c7e18
Hide index pattern selection when there is only one, clean up filter …
lukasolson Jan 15, 2019
4c55087
Merge branch 'master' into euifyFilterBar
Bargs Jan 15, 2019
685f3bf
Use new filter bar in context view
lukasolson Jan 15, 2019
03c7177
Remove old filter bar and move filters to kbn-es-query package
lukasolson Jan 16, 2019
7eb1539
Better validation that doesn't rely on state
lukasolson Jan 16, 2019
90fc2d3
Use default index pattern if there are no panels with index patterns
Bargs Jan 17, 2019
ba1fd31
Remove autofocus and create generic combobox
lukasolson Jan 17, 2019
9901aa1
Remove implemented todo
lukasolson Jan 17, 2019
e238034
Add date formats link and clean up
lukasolson Jan 17, 2019
9694b10
Design Edits (#6)
cchaos Jan 17, 2019
e59523f
Fix bug with creating phrase filters on boolean scripted fields
lukasolson Jan 17, 2019
a7067e9
Fix spacing in phrases filter view
lukasolson Jan 18, 2019
fdf6605
update autocomplete_provider tests
Bargs Jan 18, 2019
4b267c0
Add ownFocus to popover so the focus starts inside the popover when it
Bargs Jan 18, 2019
120fb38
fix TS error
Bargs Jan 18, 2019
05b9d1a
Rename MetaFilter to Filter and add readme to kbn-es-query
lukasolson Jan 18, 2019
61ea52d
Merge branch 'master' into euifyFilterBar
lukasolson Jan 18, 2019
6ffb4d6
fix type errors
Bargs Jan 18, 2019
52aa91f
Merge remote-tracking branch 'origin/euifyFilterBar' into euifyFilterBar
Bargs Jan 18, 2019
abe90c4
fix type errors
Bargs Jan 18, 2019
5c77e6b
fix incorrect formatMessage usage
Bargs Jan 18, 2019
85fc1ab
update phrases filter view to use new internationalized message on the
Bargs Jan 18, 2019
d255901
update jest snapshots for query bar tests
Bargs Jan 22, 2019
330b722
try adding a specific target to TS build
Bargs Jan 22, 2019
a1a0e62
try the default target instead, since 'esnext' is already the value in
Bargs Jan 22, 2019
0b58100
extend tsconfig.browser.json instead of setting our own target
Bargs Jan 22, 2019
99c04e3
Add filter editor tests and fix issue with field autocomplete
lukasolson Jan 23, 2019
5e63f7e
Remove ID from filter operators
lukasolson Jan 23, 2019
964b447
Fixes some of the context tests
Bargs Jan 23, 2019
fd6058b
Fixes all context functional tests
Bargs Jan 23, 2019
459f52b
Merge remote-tracking branch 'origin/euifyFilterBar' into euifyFilterBar
Bargs Jan 23, 2019
483edbd
fixes combobox input focus issue
Bargs Jan 23, 2019
51b17b5
Update removeAllFilters service method and move it to the filterbar s…
Bargs Jan 23, 2019
aa51593
Fixes some dashboard tests that weren't using the filterBar service
Bargs Jan 23, 2019
f1fb66a
fix filter toggle by using service
Bargs Jan 24, 2019
dd7a9d4
Fix discover filter tests
Bargs Jan 24, 2019
c19bdba
Add tests for value suggestions and fix operator suggestions
lukasolson Jan 24, 2019
42a11ef
Put filter editor in a form and fix actions popup position
lukasolson Jan 24, 2019
4fdc79c
Fix ML filter bar
lukasolson Jan 24, 2019
8b85a06
Add filter bar back to embed mode, fixes some vis tests
Bargs Jan 25, 2019
4c5f303
Merge branch 'master' into euifyFilterBar
Bargs Jan 25, 2019
eb2ae32
fix isFilterable method
Bargs Jan 25, 2019
2d171b5
check for undefined which can occur in ng-mock environment
Bargs Jan 25, 2019
e444f16
filter bar should not respect `vis.type.requiresSearch`, only
Bargs Jan 25, 2019
84138ed
Update isFilterable tests
Bargs Jan 25, 2019
65b44c9
localize string we missed
Bargs Jan 25, 2019
5421f92
export all Operators for ease of use and update exists filter view to
Bargs Jan 28, 2019
1cb9e90
Update filter editor tests
lukasolson Jan 28, 2019
bc31a95
Merge branch 'master' into euifyFilterBar
Bargs Jan 29, 2019
26ffc5c
Add title attribute to filter badges
Bargs Jan 30, 2019
58505d6
Merge remote-tracking branch 'origin/euifyFilterBar' into euifyFilterBar
Bargs Jan 30, 2019
312a98f
remove unused import
Bargs Jan 30, 2019
54a515c
add ID to EuiSwitch so that the label element can be correctly connected
Bargs Jan 30, 2019
99af617
translate string I missed
Bargs Jan 30, 2019
303060c
Switch from react components to a function that returns simple display
Bargs Jan 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions packages/kbn-es-query/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# kbn-es-query

This module is responsible for generating Elasticsearch queries for Kibana. See explanations below for each of the subdirectories.

## es_query

This folder contains the code that combines Lucene/KQL queries and filters into an Elasticsearch query.

```javascript
buildEsQuery(indexPattern, queries, filters, config)
```

Generates the Elasticsearch query DSL from combining the queries and filters provided.

```javascript
buildQueryFromFilters(filters, indexPattern)
```

Generates the Elasticsearch query DSL from the given filters.

```javascript
luceneStringToDsl(query)
```

Generates the Elasticsearch query DSL from the given Lucene query.

```javascript
migrateFilter(filter, indexPattern)
```

Migrates a filter from a previous version of Elasticsearch to the current version.

```javascript
decorateQuery(query, queryStringOptions)
```

Decorates an Elasticsearch query_string query with the given options.

## filters

This folder contains the code related to Kibana Filter objects, including their definitions, and helper functions to create them. Filters in Kibana always contain a `meta` property which describes which `index` the filter corresponds to, as well as additional data about the specific filter.

The object that is created by each of the following functions corresponds to a Filter object in the `lib` directory (e.g. `PhraseFilter`, `RangeFilter`, etc.)

```javascript
buildExistsFilter(field, indexPattern)
```

Creates a filter (`ExistsFilter`) where the given field exists.

```javascript
buildPhraseFilter(field, value, indexPattern)
```

Creates an filter (`PhraseFilter`) where the given field matches the given value.

```javascript
buildPhrasesFilter(field, params, indexPattern)
```

Creates a filter (`PhrasesFilter`) where the given field matches one or more of the given values. `params` should be an array of values.

```javascript
buildQueryFilter(query, index)
```

Creates a filter (`CustomFilter`) corresponding to a raw Elasticsearch query DSL object.

```javascript
buildRangeFilter(field, params, indexPattern)
```

Creates a filter (`RangeFilter`) where the value for the given field is in the given range. `params` should contain `lt`, `lte`, `gt`, and/or `gte`.

## kuery

This folder contains the code corresponding to generating Elasticsearch queries using the Kibana query language.

It also contains code corresponding to the original implementation of Kuery (released in 6.0) which should be removed at some point (see legacy_kuery.js, legacy_kuery.peg).

In general, you will only need to worry about the following functions from the `ast` folder:

```javascript
fromExpression(expression)
```

Generates an abstract syntax tree corresponding to the raw Kibana query `expression`.

```javascript
toElasticsearchQuery(node, indexPattern)
```

Takes an abstract syntax tree (generated from the previous method) and generates the Elasticsearch query DSL using the given `indexPattern`. Note that if no `indexPattern` is provided, then an Elasticsearch query DSL will still be generated, ignoring things like the index pattern scripted fields, field types, etc.

5 changes: 3 additions & 2 deletions packages/kbn-es-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
"license": "Apache-2.0",
"private": true,
"scripts": {
"build": "babel src --out-dir target",
"build": "tsc && babel src --out-dir target",
"kbn:bootstrap": "yarn build --quiet",
"kbn:watch": "yarn build --watch"
},
},
"dependencies": {
"lodash": "npm:@elastic/lodash@3.10.1-kibana1"
},
"devDependencies": {
"typescript": "^3.0.3",
"@kbn/babel-preset": "1.0.0",
"babel-cli": "^6.26.0",
"expect.js": "0.3.1"
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-es-query/src/filters/exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

// Creates a filter where the given field exists
export function buildExistsFilter(field, indexPattern) {
return {
meta: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,31 @@
* under the License.
*/

export function disableFilter(filter) {
return setFilterDisabled(filter, true);
}
import { Field, IndexPattern } from 'ui/index_patterns';
import { CustomFilter, ExistsFilter, PhraseFilter, PhrasesFilter, RangeFilter } from './lib';
import { RangeFilterParams } from './lib/range_filter';

export function enableFilter(filter) {
return setFilterDisabled(filter, false);
}
export * from './lib';

export function toggleFilterDisabled(filter) {
const { meta: { disabled = false } = {} } = filter;
export function buildExistsFilter(field: Field, indexPattern: IndexPattern): ExistsFilter;

return setFilterDisabled(filter, !disabled);
}
export function buildPhraseFilter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some tsdocs/jsdocs around the apis ?

field: Field,
value: string,
indexPattern: IndexPattern
): PhraseFilter;

function setFilterDisabled(filter, disabled) {
const { meta = {} } = filter;
export function buildPhrasesFilter(
field: Field,
values: string[],
indexPattern: IndexPattern
): PhrasesFilter;

return {
...filter,
meta: {
...meta,
disabled,
}
};
}
export function buildQueryFilter(query: any, index: string): CustomFilter;

export function buildRangeFilter(
field: Field,
params: RangeFilterParams,
indexPattern: IndexPattern,
formattedValue?: string
): RangeFilter;
1 change: 1 addition & 0 deletions packages/kbn-es-query/src/filters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ export * from './phrase';
export * from './phrases';
export * from './query';
export * from './range';
export * from './lib';
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
* under the License.
*/

import _ from 'lodash';

export function filterAppliedAndUnwrap(filters) {
return _.filter(filters, 'meta.apply');
}
import { Filter } from './meta_filter';

export type CustomFilter = Filter & {
query: any;
};
26 changes: 26 additions & 0 deletions packages/kbn-es-query/src/filters/lib/exists_filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { Filter, FilterMeta } from './meta_filter';

export type ExistsFilterMeta = FilterMeta;

export type ExistsFilter = Filter & {
meta: ExistsFilterMeta;
};
31 changes: 31 additions & 0 deletions packages/kbn-es-query/src/filters/lib/geo_bounding_box_filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { Filter, FilterMeta, LatLon } from './meta_filter';

export type GeoBoundingBoxFilterMeta = FilterMeta & {
params: {
bottom_right: LatLon;
top_left: LatLon;
};
};

export type GeoBoundingBoxFilter = Filter & {
meta: GeoBoundingBoxFilterMeta;
};
30 changes: 30 additions & 0 deletions packages/kbn-es-query/src/filters/lib/geo_polygon_filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { Filter, FilterMeta, LatLon } from './meta_filter';

export type GeoPolygonFilterMeta = FilterMeta & {
params: {
points: LatLon[];
};
};

export type GeoPolygonFilter = Filter & {
meta: GeoPolygonFilterMeta;
};
50 changes: 50 additions & 0 deletions packages/kbn-es-query/src/filters/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// The interface the other filters extend
export * from './meta_filter';

// The actual filter types
import { CustomFilter } from './custom_filter';
import { ExistsFilter } from './exists_filter';
import { GeoBoundingBoxFilter } from './geo_bounding_box_filter';
import { GeoPolygonFilter } from './geo_polygon_filter';
import { PhraseFilter } from './phrase_filter';
import { PhrasesFilter } from './phrases_filter';
import { QueryStringFilter } from './query_string_filter';
import { RangeFilter } from './range_filter';
export {
CustomFilter,
ExistsFilter,
GeoBoundingBoxFilter,
GeoPolygonFilter,
PhraseFilter,
PhrasesFilter,
QueryStringFilter,
RangeFilter,
};

// Any filter associated with a field (used in the filter bar/editor)
export type FieldFilter =
| ExistsFilter
| GeoBoundingBoxFilter
| GeoPolygonFilter
| PhraseFilter
| PhrasesFilter
| RangeFilter;
Loading