mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Unified Search] Cleanup the deprecated esFilters (#132785)
* feat: move methods to es-query * feat: replace imports for extractTimeRange * feat: change test for change time filter test * refact: rename file change_time_filter -> convert_range_filter * feat: add dynamic import * feat: added TimeRange deprecated * feat: add dynamic import * fix: test jest
This commit is contained in:
parent
4a989f7148
commit
0dc6028d0e
25 changed files with 101 additions and 132 deletions
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import moment from 'moment';
|
||||
import { convertRangeFilterToTimeRange } from './convert_range_filter';
|
||||
|
||||
describe('convertRangeFilterToTimeRange', () => {
|
||||
const gt = 1388559600000;
|
||||
const lt = 1388646000000;
|
||||
|
||||
it('should return converted range', () => {
|
||||
const filter: any = { query: { range: { '@timestamp': { gte: gt, lte: lt } } } };
|
||||
const filterAfterConvertedRangeFilter = {
|
||||
from: moment(gt),
|
||||
to: moment(lt),
|
||||
};
|
||||
const convertedRangeFilter = convertRangeFilterToTimeRange(filter);
|
||||
|
||||
expect(convertedRangeFilter).toEqual(filterAfterConvertedRangeFilter);
|
||||
});
|
||||
});
|
|
@ -8,9 +8,8 @@
|
|||
|
||||
import moment from 'moment';
|
||||
import { keys } from 'lodash';
|
||||
import { RangeFilter } from '@kbn/es-query';
|
||||
import { TimefilterContract } from '..';
|
||||
import { TimeRange } from '../../../../common';
|
||||
import type { RangeFilter } from '../build_filters';
|
||||
import type { TimeRange } from './types';
|
||||
|
||||
export function convertRangeFilterToTimeRange(filter: RangeFilter) {
|
||||
const key = keys(filter.query.range)[0];
|
||||
|
@ -29,7 +28,3 @@ export function convertRangeFilterToTimeRangeString(filter: RangeFilter): TimeRa
|
|||
to: to?.toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
export function changeTimeFilter(timeFilter: TimefilterContract, filter: RangeFilter) {
|
||||
timeFilter.setTime(convertRangeFilterToTimeRange(filter));
|
||||
}
|
|
@ -7,22 +7,16 @@
|
|||
*/
|
||||
|
||||
import { extractTimeFilter } from './extract_time_filter';
|
||||
import {
|
||||
Filter,
|
||||
IIndexPattern,
|
||||
IFieldType,
|
||||
buildQueryFilter,
|
||||
buildRangeFilter,
|
||||
buildPhraseFilter,
|
||||
} from '../../../../common';
|
||||
import { Filter, buildQueryFilter, buildRangeFilter, buildPhraseFilter } from '../build_filters';
|
||||
import { DataViewBase, DataViewFieldBase } from '../../es_query';
|
||||
|
||||
describe('filter manager utilities', () => {
|
||||
let indexPattern: IIndexPattern;
|
||||
let indexPattern: DataViewBase;
|
||||
|
||||
beforeEach(() => {
|
||||
indexPattern = {
|
||||
id: 'logstash-*',
|
||||
} as IIndexPattern;
|
||||
} as DataViewBase;
|
||||
});
|
||||
|
||||
describe('extractTimeFilter()', () => {
|
||||
|
@ -30,7 +24,7 @@ describe('filter manager utilities', () => {
|
|||
const filters: Filter[] = [
|
||||
buildQueryFilter({ query_string: { query: 'apache' } }, 'logstash-*', ''),
|
||||
buildRangeFilter(
|
||||
{ name: 'time' } as IFieldType,
|
||||
{ name: 'time' } as DataViewFieldBase,
|
||||
{ gt: 1388559600000, lt: 1388646000000 },
|
||||
indexPattern
|
||||
),
|
||||
|
@ -45,7 +39,7 @@ describe('filter manager utilities', () => {
|
|||
const filters: Filter[] = [
|
||||
buildQueryFilter({ query_string: { query: 'apache' } }, 'logstash-*', ''),
|
||||
buildRangeFilter(
|
||||
{ name: '@timestamp' } as IFieldType,
|
||||
{ name: '@timestamp' } as DataViewFieldBase,
|
||||
{ from: 1, to: 2 },
|
||||
indexPattern,
|
||||
''
|
||||
|
@ -60,7 +54,7 @@ describe('filter manager utilities', () => {
|
|||
test('should not return a non range filter, even when names match', async () => {
|
||||
const filters: Filter[] = [
|
||||
buildQueryFilter({ query_string: { query: 'apache' } }, 'logstash-*', ''),
|
||||
buildPhraseFilter({ name: 'time' } as IFieldType, 'banana', indexPattern),
|
||||
buildPhraseFilter({ name: 'time' } as DataViewFieldBase, 'banana', indexPattern),
|
||||
];
|
||||
const result = await extractTimeFilter('time', filters);
|
||||
|
|
@ -6,10 +6,10 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { Filter, isRangeFilter, RangeFilter } from '@kbn/es-query';
|
||||
import { keys, partition } from 'lodash';
|
||||
import { TimeRange } from '../../../../common';
|
||||
import { convertRangeFilterToTimeRangeString } from './change_time_filter';
|
||||
import { Filter, isRangeFilter, RangeFilter } from '../build_filters';
|
||||
import { TimeRange } from './types';
|
||||
import { convertRangeFilterToTimeRangeString } from './convert_range_filter';
|
||||
|
||||
export function extractTimeFilter(timeFieldName: string, filters: Filter[]) {
|
||||
const [timeRangeFilter, restOfFilters] = partition(filters, (obj: Filter) => {
|
|
@ -11,3 +11,6 @@ export * from './dedup_filters';
|
|||
export * from './uniq_filters';
|
||||
export * from './meta_filter';
|
||||
export * from './only_disabled';
|
||||
export * from './extract_time_filter';
|
||||
export * from './convert_range_filter';
|
||||
export * from './types';
|
||||
|
|
14
packages/kbn-es-query/src/filters/helpers/types.ts
Normal file
14
packages/kbn-es-query/src/filters/helpers/types.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
export type TimeRange = {
|
||||
from: string;
|
||||
to: string;
|
||||
mode?: 'absolute' | 'relative';
|
||||
};
|
|
@ -6,7 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export type { FilterCompareOptions } from './helpers';
|
||||
export type { FilterCompareOptions, TimeRange } from './helpers';
|
||||
|
||||
export {
|
||||
dedupFilters,
|
||||
uniqFilters,
|
||||
|
@ -25,6 +26,9 @@ export {
|
|||
toggleFilterDisabled,
|
||||
toggleFilterPinned,
|
||||
unpinFilter,
|
||||
extractTimeFilter,
|
||||
extractTimeRange,
|
||||
convertRangeFilterToTimeRange,
|
||||
} from './helpers';
|
||||
|
||||
export {
|
||||
|
|
|
@ -34,6 +34,7 @@ export type {
|
|||
RangeFilterParams,
|
||||
ScriptedPhraseFilter,
|
||||
ScriptedRangeFilter,
|
||||
TimeRange,
|
||||
} from './filters';
|
||||
|
||||
export type {
|
||||
|
@ -96,6 +97,9 @@ export {
|
|||
toggleFilterPinned,
|
||||
uniqFilters,
|
||||
unpinFilter,
|
||||
extractTimeFilter,
|
||||
extractTimeRange,
|
||||
convertRangeFilterToTimeRange,
|
||||
} from './filters';
|
||||
|
||||
export {
|
||||
|
|
|
@ -49,6 +49,7 @@ import {
|
|||
MatchAllFilter as oldMatchAllFilter,
|
||||
RangeFilter as oldRangeFilter,
|
||||
KueryNode as oldKueryNode,
|
||||
TimeRange as oldTimeRange,
|
||||
FilterMeta as oldFilterMeta,
|
||||
FILTERS as oldFILTERS,
|
||||
EsQueryConfig as oldEsQueryConfig,
|
||||
|
@ -339,6 +340,12 @@ type EsQueryConfig = oldEsQueryConfig;
|
|||
* @removeBy 8.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Import from the "@kbn/es-query" package directly instead.
|
||||
* @removeBy 8.3
|
||||
*/
|
||||
type TimeRange = oldTimeRange;
|
||||
|
||||
export type {
|
||||
Filter,
|
||||
RangeFilterParams,
|
||||
|
@ -349,6 +356,7 @@ export type {
|
|||
KueryNode,
|
||||
FilterMeta,
|
||||
EsQueryConfig,
|
||||
TimeRange,
|
||||
};
|
||||
export {
|
||||
COMPARE_ALL_OPTIONS,
|
||||
|
|
|
@ -64,6 +64,7 @@ export type {
|
|||
RangeFilterParams,
|
||||
KueryNode,
|
||||
EsQueryConfig,
|
||||
TimeRange,
|
||||
} from './es_query';
|
||||
export { KbnFieldType } from './kbn_field_types';
|
||||
export {
|
||||
|
@ -79,7 +80,6 @@ export type { QueryState } from './query';
|
|||
export * from './search';
|
||||
export type {
|
||||
RefreshInterval,
|
||||
TimeRange,
|
||||
TimeRangeBounds,
|
||||
GetConfigFn,
|
||||
SavedQuery,
|
||||
|
|
|
@ -49,38 +49,20 @@ import {
|
|||
COMPARE_ALL_OPTIONS,
|
||||
onlyDisabledFiltersChanged,
|
||||
getEsQueryConfig,
|
||||
TimeRange,
|
||||
} from '../common';
|
||||
|
||||
import {
|
||||
getDisplayValueFromFilter,
|
||||
generateFilters,
|
||||
extractTimeRange,
|
||||
changeTimeFilter as oldChangeTimeFilter,
|
||||
mapAndFlattenFilters as oldMapAndFlattenFilters,
|
||||
extractTimeFilter as oldExtractTimeFilter,
|
||||
convertRangeFilterToTimeRangeString as oldConvertRangeFilterToTimeRangeString,
|
||||
} from './query';
|
||||
|
||||
/**
|
||||
* @deprecated This import will be removed.
|
||||
* @removeBy 8.1
|
||||
*/
|
||||
const changeTimeFilter = oldChangeTimeFilter;
|
||||
/**
|
||||
* @deprecated This import will be removed.
|
||||
* @removeBy 8.1
|
||||
*/
|
||||
const mapAndFlattenFilters = oldMapAndFlattenFilters;
|
||||
/**
|
||||
* @deprecated This import will be removed.
|
||||
* @removeBy 8.1
|
||||
*/
|
||||
const extractTimeFilter = oldExtractTimeFilter;
|
||||
/**
|
||||
* @deprecated This import will be removed.
|
||||
* @removeBy 8.1
|
||||
*/
|
||||
const convertRangeFilterToTimeRangeString = oldConvertRangeFilterToTimeRangeString;
|
||||
|
||||
/**
|
||||
* Filter helpers namespace:
|
||||
|
@ -117,11 +99,7 @@ export const esFilters = {
|
|||
generateFilters,
|
||||
onlyDisabledFiltersChanged,
|
||||
|
||||
changeTimeFilter,
|
||||
convertRangeFilterToTimeRangeString,
|
||||
mapAndFlattenFilters,
|
||||
extractTimeFilter,
|
||||
extractTimeRange,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -135,6 +113,7 @@ export type {
|
|||
PhraseFilter,
|
||||
MatchAllFilter,
|
||||
EsQueryConfig,
|
||||
TimeRange,
|
||||
};
|
||||
export { isFilters };
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ export {
|
|||
getDisplayValueFromFilter,
|
||||
getFieldDisplayValueFromFilter,
|
||||
generateFilters,
|
||||
extractTimeRange,
|
||||
getIndexPatternFromFilter,
|
||||
} from './query';
|
||||
|
||||
|
|
|
@ -14,6 +14,4 @@ export type { TimefilterContract, AutoRefreshDoneFn } from './timefilter';
|
|||
export { Timefilter } from './timefilter';
|
||||
export type { TimeHistoryContract } from './time_history';
|
||||
export { TimeHistory } from './time_history';
|
||||
export { changeTimeFilter, convertRangeFilterToTimeRangeString } from './lib/change_time_filter';
|
||||
export { extractTimeFilter, extractTimeRange } from './lib/extract_time_filter';
|
||||
export { validateTimeRange } from './lib/validate_timerange';
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { changeTimeFilter } from './change_time_filter';
|
||||
import { timefilterServiceMock } from '../timefilter_service.mock';
|
||||
import { TimeRange, RangeFilter } from '../../../../common';
|
||||
|
||||
const timefilterMock = timefilterServiceMock.createSetupContract();
|
||||
const timefilter = timefilterMock.timefilter;
|
||||
|
||||
let _time: TimeRange | undefined;
|
||||
|
||||
timefilter.setTime.mockImplementation((time: any) => {
|
||||
_time = {
|
||||
from: time.from.toISOString(),
|
||||
to: time.to.toISOString(),
|
||||
};
|
||||
});
|
||||
timefilter.getTime.mockImplementation(() => {
|
||||
return _time!;
|
||||
});
|
||||
|
||||
describe('changeTimeFilter()', () => {
|
||||
const gt = 1388559600000;
|
||||
const lt = 1388646000000;
|
||||
|
||||
test('should change the timefilter to match the range gt/lt', () => {
|
||||
const filter: any = { query: { range: { '@timestamp': { gt, lt } } } };
|
||||
changeTimeFilter(timefilter, filter as RangeFilter);
|
||||
|
||||
const { to, from } = timefilter.getTime();
|
||||
|
||||
expect(to).toBe(new Date(lt).toISOString());
|
||||
expect(from).toBe(new Date(gt).toISOString());
|
||||
});
|
||||
|
||||
test('should change the timefilter to match the range gte/lte', () => {
|
||||
const filter: any = { query: { range: { '@timestamp': { gte: gt, lte: lt } } } };
|
||||
changeTimeFilter(timefilter, filter as RangeFilter);
|
||||
|
||||
const { to, from } = timefilter.getTime();
|
||||
|
||||
expect(to).toBe(new Date(lt).toISOString());
|
||||
expect(from).toBe(new Date(gt).toISOString());
|
||||
});
|
||||
});
|
|
@ -11,8 +11,8 @@ import { ThemeServiceSetup } from '@kbn/core/public';
|
|||
import { toMountPoint } from '@kbn/kibana-react-plugin/public';
|
||||
import { Action, createAction, IncompatibleActionError } from '@kbn/ui-actions-plugin/public';
|
||||
// for cleanup esFilters need to fix the issue https://github.com/elastic/kibana/issues/131292
|
||||
import { FilterManager, TimefilterContract, esFilters } from '@kbn/data-plugin/public';
|
||||
import type { Filter } from '@kbn/es-query';
|
||||
import { FilterManager, TimefilterContract } from '@kbn/data-plugin/public';
|
||||
import type { Filter, RangeFilter } from '@kbn/es-query';
|
||||
import { getOverlays, getIndexPatterns } from '../services';
|
||||
import { applyFiltersPopover } from '../apply_filters';
|
||||
|
||||
|
@ -103,13 +103,14 @@ export function createFilterAction(
|
|||
}
|
||||
|
||||
if (timeFieldName) {
|
||||
const { timeRangeFilter, restOfFilters } = esFilters.extractTimeFilter(
|
||||
const { extractTimeFilter } = await import('@kbn/es-query');
|
||||
const { timeRangeFilter, restOfFilters } = extractTimeFilter(
|
||||
timeFieldName,
|
||||
selectedFilters
|
||||
);
|
||||
filterManager.addFilters(restOfFilters);
|
||||
if (timeRangeFilter) {
|
||||
esFilters.changeTimeFilter(timeFilter, timeRangeFilter);
|
||||
changeTimeFilter(timeFilter, timeRangeFilter);
|
||||
}
|
||||
} else {
|
||||
filterManager.addFilters(selectedFilters);
|
||||
|
@ -117,3 +118,8 @@ export function createFilterAction(
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function changeTimeFilter(timeFilter: TimefilterContract, filter: RangeFilter) {
|
||||
const { convertRangeFilterToTimeRange } = await import('@kbn/es-query');
|
||||
timeFilter.setTime(convertRangeFilterToTimeRange(filter));
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ import {
|
|||
EuiToolTip,
|
||||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { Filter, Query } from '@kbn/es-query';
|
||||
import type { Filter, Query, TimeRange } from '@kbn/es-query';
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
import type { TimeRange, SavedQueryService, SavedQuery } from '@kbn/data-plugin/public';
|
||||
import type { SavedQueryService, SavedQuery } from '@kbn/data-plugin/public';
|
||||
import { QueryBarMenuPanels, QueryBarMenuPanelsProps } from './query_bar_menu_panels';
|
||||
import { FilterEditorWrapper } from './filter_editor_wrapper';
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
import {
|
||||
Filter,
|
||||
Query,
|
||||
TimeRange,
|
||||
enableFilter,
|
||||
disableFilter,
|
||||
toggleFilterNegated,
|
||||
|
@ -28,12 +29,7 @@ import {
|
|||
import { METRIC_TYPE } from '@kbn/analytics';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { KIBANA_USER_QUERY_LANGUAGE_KEY, UI_SETTINGS } from '@kbn/data-plugin/common';
|
||||
import type {
|
||||
IDataPluginServices,
|
||||
TimeRange,
|
||||
SavedQueryService,
|
||||
SavedQuery,
|
||||
} from '@kbn/data-plugin/public';
|
||||
import type { IDataPluginServices, SavedQueryService, SavedQuery } from '@kbn/data-plugin/public';
|
||||
import { fromUser } from './from_user';
|
||||
import { QueryLanguageSwitcher } from './language_switcher';
|
||||
import { FilterPanelOption } from '../types';
|
||||
|
|
|
@ -11,7 +11,7 @@ import classNames from 'classnames';
|
|||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import deepEqual from 'fast-deep-equal';
|
||||
import useObservable from 'react-use/lib/useObservable';
|
||||
import type { Filter } from '@kbn/es-query';
|
||||
import type { Filter, TimeRange } from '@kbn/es-query';
|
||||
import { EMPTY } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import {
|
||||
|
@ -27,7 +27,6 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import {
|
||||
IDataPluginServices,
|
||||
TimeRange,
|
||||
TimeHistoryContract,
|
||||
Query,
|
||||
getQueryLog,
|
||||
|
|
|
@ -12,8 +12,8 @@ import { CoreStart } from '@kbn/core/public';
|
|||
import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
|
||||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
|
||||
import { QueryStart, SavedQuery, DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||
import { Query, TimeRange } from '@kbn/data-plugin/common';
|
||||
import type { Filter } from '@kbn/es-query';
|
||||
import { Query } from '@kbn/data-plugin/common';
|
||||
import type { Filter, TimeRange } from '@kbn/es-query';
|
||||
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
|
||||
import { SearchBar } from '.';
|
||||
import type { SearchBarOwnProps } from '.';
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { DataPublicPluginStart, TimeRange, RefreshInterval } from '@kbn/data-plugin/public';
|
||||
import { DataPublicPluginStart, RefreshInterval } from '@kbn/data-plugin/public';
|
||||
import type { TimeRange } from '@kbn/es-query';
|
||||
|
||||
interface UseTimefilterProps {
|
||||
dateRangeFrom?: string;
|
||||
|
|
|
@ -15,12 +15,11 @@ import { get, isEqual } from 'lodash';
|
|||
import memoizeOne from 'memoize-one';
|
||||
|
||||
import { METRIC_TYPE } from '@kbn/analytics';
|
||||
import { Query, Filter } from '@kbn/es-query';
|
||||
import { Query, Filter, TimeRange } from '@kbn/es-query';
|
||||
import { withKibana, KibanaReactContextValue } from '@kbn/kibana-react-plugin/public';
|
||||
import type { TimeHistoryContract, SavedQuery } from '@kbn/data-plugin/public';
|
||||
import type { SavedQueryAttributes } from '@kbn/data-plugin/common';
|
||||
import { IDataPluginServices } from '@kbn/data-plugin/public';
|
||||
import { TimeRange } from '@kbn/data-plugin/common';
|
||||
import { DataView } from '@kbn/data-views-plugin/public';
|
||||
|
||||
import { SavedQueryMeta, SaveQueryForm } from '../saved_query_form';
|
||||
|
|
|
@ -14,8 +14,8 @@ import {
|
|||
isTimeRange,
|
||||
Query,
|
||||
TimeRange,
|
||||
extractTimeRange,
|
||||
} from '@kbn/data-plugin/public';
|
||||
import { extractTimeRange } from '@kbn/es-query';
|
||||
import { ApplyGlobalFilterActionContext } from '@kbn/unified-search-plugin/public';
|
||||
import { IEmbeddable, EmbeddableInput } from '@kbn/embeddable-plugin/public';
|
||||
import { EnhancedEmbeddableContext } from '@kbn/embeddable-enhanced-plugin/public';
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import { Action } from '@kbn/ui-actions-plugin/public';
|
||||
import { DiscoverAppLocatorParams, SearchInput } from '@kbn/discover-plugin/public';
|
||||
import { ApplyGlobalFilterActionContext } from '@kbn/unified-search-plugin/public';
|
||||
import { extractTimeRange } from '@kbn/data-plugin/public';
|
||||
import { IEmbeddable } from '@kbn/embeddable-plugin/public';
|
||||
import { KibanaLocation } from '@kbn/share-plugin/public';
|
||||
import * as shared from './shared';
|
||||
|
@ -50,6 +49,7 @@ export class ExploreDataChartAction
|
|||
}
|
||||
|
||||
const { embeddable } = context;
|
||||
const { extractTimeRange } = await import('@kbn/es-query');
|
||||
const { restOfFilters: filters, timeRange } = extractTimeRange(
|
||||
context.filters,
|
||||
context.timeFieldName
|
||||
|
|
|
@ -52,9 +52,9 @@ describe('open in discover drilldown', () => {
|
|||
);
|
||||
expect(isCompatible).toHaveBeenCalledWith(expect.objectContaining({ filters }));
|
||||
});
|
||||
it('calls through to execute helper', () => {
|
||||
it('calls through to execute helper', async () => {
|
||||
const filters: Filter[] = [{ meta: { disabled: false } }];
|
||||
drilldown.execute(
|
||||
await drilldown.execute(
|
||||
{ openInNewTab: true },
|
||||
{ embeddable: { type: 'lens' } as IEmbeddable<EmbeddableInput>, filters }
|
||||
);
|
||||
|
|
|
@ -7,13 +7,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { IEmbeddable, EmbeddableInput } from '@kbn/embeddable-plugin/public';
|
||||
import {
|
||||
Query,
|
||||
Filter,
|
||||
TimeRange,
|
||||
extractTimeRange,
|
||||
APPLY_FILTER_TRIGGER,
|
||||
} from '@kbn/data-plugin/public';
|
||||
import { Query, Filter, TimeRange, APPLY_FILTER_TRIGGER } from '@kbn/data-plugin/public';
|
||||
import { CollectConfigProps as CollectConfigPropsBase } from '@kbn/kibana-utils-plugin/public';
|
||||
import { reactToUiComponent } from '@kbn/kibana-react-plugin/public';
|
||||
import {
|
||||
|
@ -122,6 +116,7 @@ export class OpenInDiscoverDrilldown
|
|||
};
|
||||
|
||||
public readonly execute = async (config: Config, context: ActionContext) => {
|
||||
const { extractTimeRange } = await import('@kbn/es-query');
|
||||
const { restOfFilters: filters, timeRange: timeRange } = extractTimeRange(
|
||||
context.filters,
|
||||
context.timeFieldName
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue