Skip to content

Commit f1ef326

Browse files
Merge branch '7.x' into backport/7.x/pr-70090
2 parents 1be87e8 + c0f4f1d commit f1ef326

105 files changed

Lines changed: 2508 additions & 581 deletions

File tree

Some content is hidden

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

docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<b>Signature:</b>
88

99
```typescript
10-
SearchBar: React.ComponentClass<Pick<Pick<SearchBarProps, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "intl" | "indexPatterns" | "dataTestSubj" | "customSubmitButton" | "screenTitle" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "timeHistory" | "onFiltersUpdated">, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "indexPatterns" | "dataTestSubj" | "customSubmitButton" | "screenTitle" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "timeHistory" | "onFiltersUpdated">, any> & {
11-
WrappedComponent: React.ComponentType<Pick<SearchBarProps, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "intl" | "indexPatterns" | "dataTestSubj" | "customSubmitButton" | "screenTitle" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "timeHistory" | "onFiltersUpdated"> & ReactIntl.InjectedIntlProps>;
10+
SearchBar: React.ComponentClass<Pick<Pick<SearchBarProps, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "intl" | "indexPatterns" | "dataTestSubj" | "customSubmitButton" | "screenTitle" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "indicateNoData" | "timeHistory" | "onFiltersUpdated">, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "indexPatterns" | "dataTestSubj" | "customSubmitButton" | "screenTitle" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "indicateNoData" | "timeHistory" | "onFiltersUpdated">, any> & {
11+
WrappedComponent: React.ComponentType<Pick<SearchBarProps, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "intl" | "indexPatterns" | "dataTestSubj" | "customSubmitButton" | "screenTitle" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "indicateNoData" | "timeHistory" | "onFiltersUpdated"> & ReactIntl.InjectedIntlProps>;
1212
}
1313
```

src/plugins/data/public/actions/filters/create_filters_from_range_select.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import moment from 'moment';
2222
import { esFilters, IFieldType, RangeFilterParams } from '../../../public';
2323
import { getIndexPatterns } from '../../../public/services';
2424
import { deserializeAggConfig } from '../../search/expressions/utils';
25-
import { RangeSelectTriggerContext } from '../../../../embeddable/public';
25+
import { RangeSelectContext } from '../../../../embeddable/public';
2626

27-
export async function createFiltersFromRangeSelectAction(event: RangeSelectTriggerContext['data']) {
27+
export async function createFiltersFromRangeSelectAction(event: RangeSelectContext['data']) {
2828
const column: Record<string, any> = event.table.columns[event.column];
2929

3030
if (!column || !column.meta) {

src/plugins/data/public/actions/filters/create_filters_from_value_click.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { dataPluginMock } from '../../../public/mocks';
2727
import { setIndexPatterns } from '../../../public/services';
2828
import { mockDataServices } from '../../../public/search/aggs/test_helpers';
2929
import { createFiltersFromValueClickAction } from './create_filters_from_value_click';
30-
import { ValueClickTriggerContext } from '../../../../embeddable/public';
30+
import { ValueClickContext } from '../../../../embeddable/public';
3131

3232
const mockField = {
3333
name: 'bytes',
@@ -39,7 +39,7 @@ const mockField = {
3939
};
4040

4141
describe('createFiltersFromValueClick', () => {
42-
let dataPoints: ValueClickTriggerContext['data']['data'];
42+
let dataPoints: ValueClickContext['data']['data'];
4343

4444
beforeEach(() => {
4545
dataPoints = [

src/plugins/data/public/actions/filters/create_filters_from_value_click.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { KibanaDatatable } from '../../../../../plugins/expressions/public';
2121
import { deserializeAggConfig } from '../../search/expressions';
2222
import { esFilters, Filter } from '../../../public';
2323
import { getIndexPatterns } from '../../../public/services';
24-
import { ValueClickTriggerContext } from '../../../../embeddable/public';
24+
import { ValueClickContext } from '../../../../embeddable/public';
2525

2626
/**
2727
* For terms aggregations on `__other__` buckets, this assembles a list of applicable filter
@@ -114,7 +114,7 @@ const createFilter = async (
114114
export const createFiltersFromValueClickAction = async ({
115115
data,
116116
negate,
117-
}: ValueClickTriggerContext['data']) => {
117+
}: ValueClickContext['data']) => {
118118
const filters: Filter[] = [];
119119

120120
await Promise.all(

src/plugins/data/public/actions/select_range_action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import {
2424
ActionByType,
2525
} from '../../../../plugins/ui_actions/public';
2626
import { createFiltersFromRangeSelectAction } from './filters/create_filters_from_range_select';
27-
import { RangeSelectTriggerContext } from '../../../embeddable/public';
27+
import { RangeSelectContext } from '../../../embeddable/public';
2828
import { FilterManager, TimefilterContract, esFilters } from '..';
2929

3030
export const ACTION_SELECT_RANGE = 'ACTION_SELECT_RANGE';
3131

32-
export type SelectRangeActionContext = RangeSelectTriggerContext;
32+
export type SelectRangeActionContext = RangeSelectContext;
3333

3434
async function isCompatible(context: SelectRangeActionContext) {
3535
try {

src/plugins/data/public/actions/value_click_action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ import {
2727
import { getOverlays, getIndexPatterns } from '../services';
2828
import { applyFiltersPopover } from '../ui/apply_filters';
2929
import { createFiltersFromValueClickAction } from './filters/create_filters_from_value_click';
30-
import { ValueClickTriggerContext } from '../../../embeddable/public';
30+
import { ValueClickContext } from '../../../embeddable/public';
3131
import { Filter, FilterManager, TimefilterContract, esFilters } from '..';
3232

3333
export const ACTION_VALUE_CLICK = 'ACTION_VALUE_CLICK';
3434

35-
export type ValueClickActionContext = ValueClickTriggerContext;
35+
export type ValueClickActionContext = ValueClickContext;
3636

3737
async function isCompatible(context: ValueClickActionContext) {
3838
try {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
export * from './load_index_pattern';
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 { indexPatternLoad } from './load_index_pattern';
21+
22+
jest.mock('../../services', () => ({
23+
getIndexPatterns: () => ({
24+
get: (id: string) => ({
25+
toSpec: () => ({
26+
title: 'value',
27+
}),
28+
}),
29+
}),
30+
}));
31+
32+
describe('indexPattern expression function', () => {
33+
test('returns serialized index pattern', async () => {
34+
const indexPatternDefinition = indexPatternLoad();
35+
const result = await indexPatternDefinition.fn(null, { id: '1' }, {} as any);
36+
expect(result.type).toEqual('index_pattern');
37+
expect(result.value.title).toEqual('value');
38+
});
39+
});
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 { i18n } from '@kbn/i18n';
21+
import { ExpressionFunctionDefinition } from '../../../../../plugins/expressions/public';
22+
import { getIndexPatterns } from '../../services';
23+
import { IndexPatternSpec } from '../../../common/index_patterns';
24+
25+
const name = 'indexPatternLoad';
26+
27+
type Input = null;
28+
type Output = Promise<{ type: 'index_pattern'; value: IndexPatternSpec }>;
29+
30+
interface Arguments {
31+
id: string;
32+
}
33+
34+
export const indexPatternLoad = (): ExpressionFunctionDefinition<
35+
typeof name,
36+
Input,
37+
Arguments,
38+
Output
39+
> => ({
40+
name,
41+
type: 'index_pattern',
42+
inputTypes: ['null'],
43+
help: i18n.translate('data.functions.indexPatternLoad.help', {
44+
defaultMessage: 'Loads an index pattern',
45+
}),
46+
args: {
47+
id: {
48+
types: ['string'],
49+
required: true,
50+
help: i18n.translate('data.functions.indexPatternLoad.id.help', {
51+
defaultMessage: 'index pattern id to load',
52+
}),
53+
},
54+
},
55+
async fn(input, args) {
56+
const indexPatterns = getIndexPatterns();
57+
58+
const indexPattern = await indexPatterns.get(args.id);
59+
60+
return { type: 'index_pattern', value: indexPattern.toSpec() };
61+
},
62+
});

src/plugins/data/public/plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import {
8383
ValueClickActionContext,
8484
} from './actions/value_click_action';
8585
import { SavedObjectsClientPublicToCommon } from './index_patterns';
86+
import { indexPatternLoad } from './index_patterns/expressions/load_index_pattern';
8687

8788
declare module '../../ui_actions/public' {
8889
export interface ActionContextMapping {
@@ -127,6 +128,7 @@ export class DataPublicPlugin implements Plugin<DataPublicPluginSetup, DataPubli
127128
};
128129

129130
expressions.registerFunction(esaggs);
131+
expressions.registerFunction(indexPatternLoad);
130132

131133
const queryService = this.queryService.setup({
132134
uiSettings: core.uiSettings,

0 commit comments

Comments
 (0)