diff --git a/src/legacy/core_plugins/data/public/filter/action/apply_filter_action.ts b/src/legacy/core_plugins/data/public/filter/action/apply_filter_action.ts index c436e1d45c6d8..a39175077d9e0 100644 --- a/src/legacy/core_plugins/data/public/filter/action/apply_filter_action.ts +++ b/src/legacy/core_plugins/data/public/filter/action/apply_filter_action.ts @@ -25,8 +25,8 @@ import { createAction, IncompatibleActionError, } from '../../../../../../plugins/ui_actions/public'; -import { changeTimeFilter, extractTimeFilter, FilterManager } from '../filter_manager'; -import { TimefilterContract } from '../../timefilter'; +import { FilterManager } from '../../../../../../plugins/data/public'; +import { TimefilterContract, changeTimeFilter, extractTimeFilter } from '../../timefilter'; import { applyFiltersPopover } from '../apply_filters/apply_filters_popover'; import { IndexPatternsStart } from '../../index_patterns'; export const GLOBAL_APPLY_FILTER_ACTION = 'GLOBAL_APPLY_FILTER_ACTION'; diff --git a/src/legacy/core_plugins/data/public/filter/apply_filters/apply_filter_popover_content.tsx b/src/legacy/core_plugins/data/public/filter/apply_filters/apply_filter_popover_content.tsx index 5f7fbc1996433..8fc6b33f3f68a 100644 --- a/src/legacy/core_plugins/data/public/filter/apply_filters/apply_filter_popover_content.tsx +++ b/src/legacy/core_plugins/data/public/filter/apply_filters/apply_filter_popover_content.tsx @@ -33,7 +33,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component } from 'react'; import { IndexPattern } from '../../index_patterns'; import { getFilterDisplayText } from '../filter_bar/filter_editor/lib/get_filter_display_text'; -import { mapAndFlattenFilters } from '../filter_manager/lib/map_and_flatten_filters'; +import { mapAndFlattenFilters } from '../../../../../../plugins/data/public'; import { getDisplayValueFromFilter } from '../filter_bar/filter_editor/lib/get_display_value'; interface Props { diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.test.ts b/src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.test.ts index d1cad9a812399..aae9c0754a8d8 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.test.ts +++ b/src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.test.ts @@ -24,7 +24,7 @@ import { FilterStateManager } from './filter_state_manager'; import { StubState } from './test_helpers/stub_state'; import { getFilter } from './test_helpers/get_stub_filter'; -import { FilterManager } from './filter_manager'; +import { FilterManager } from '../../../../../../plugins/data/public'; import { coreMock } from '../../../../../../core/public/mocks'; const setupMock = coreMock.createSetup(); @@ -101,25 +101,29 @@ describe('filter_state_manager', () => { }); test('should update filter manager global filters', done => { - const f1 = getFilter(FilterStateStore.GLOBAL_STATE, false, false, 'age', 34); - globalStateStub.filters.push(f1); - - setTimeout(() => { + const updateSubscription = filterManager.getUpdates$().subscribe(() => { expect(filterManager.getGlobalFilters()).toHaveLength(1); + if (updateSubscription) { + updateSubscription.unsubscribe(); + } done(); - }, 100); + }); + + const f1 = getFilter(FilterStateStore.GLOBAL_STATE, true, true, 'age', 34); + globalStateStub.filters.push(f1); }); - test('should update filter manager app filters', done => { - expect(filterManager.getAppFilters()).toHaveLength(0); + test('should update filter manager app filter', done => { + const updateSubscription = filterManager.getUpdates$().subscribe(() => { + expect(filterManager.getAppFilters()).toHaveLength(1); + if (updateSubscription) { + updateSubscription.unsubscribe(); + } + done(); + }); const f1 = getFilter(FilterStateStore.APP_STATE, false, false, 'age', 34); appStateStub.filters.push(f1); - - setTimeout(() => { - expect(filterManager.getAppFilters()).toHaveLength(1); - done(); - }, 100); }); test('should update URL when filter manager filters are set', () => { diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.ts b/src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.ts index 06f91e35db96e..af8722c37c703 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.ts +++ b/src/legacy/core_plugins/data/public/filter/filter_manager/filter_state_manager.ts @@ -21,7 +21,7 @@ import { FilterStateStore } from '@kbn/es-query'; import _ from 'lodash'; import { State } from 'ui/state_management/state'; -import { FilterManager } from './filter_manager'; +import { FilterManager } from '../../../../../../plugins/data/public'; type GetAppStateFunc = () => State | undefined | null; diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/index.ts b/src/legacy/core_plugins/data/public/filter/filter_manager/index.ts index ac533eaaf89ea..ebb622783c3d1 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_manager/index.ts +++ b/src/legacy/core_plugins/data/public/filter/filter_manager/index.ts @@ -17,10 +17,4 @@ * under the License. */ -export { FilterManager } from './filter_manager'; export { FilterStateManager } from './filter_state_manager'; - -export { uniqFilters } from './lib/uniq_filters'; -export { extractTimeFilter } from './lib/extract_time_filter'; -export { changeTimeFilter } from './lib/change_time_filter'; -export { onlyDisabledFiltersChanged } from './lib/only_disabled'; diff --git a/src/legacy/core_plugins/data/public/filter/index.tsx b/src/legacy/core_plugins/data/public/filter/index.tsx index cda7350ecadef..005c4904a4f39 100644 --- a/src/legacy/core_plugins/data/public/filter/index.tsx +++ b/src/legacy/core_plugins/data/public/filter/index.tsx @@ -17,8 +17,6 @@ * under the License. */ -export * from './filter_service'; - export { FilterBar } from './filter_bar'; export { ApplyFiltersPopover } from './apply_filters'; diff --git a/src/legacy/core_plugins/data/public/index.ts b/src/legacy/core_plugins/data/public/index.ts index cb3869ff57711..502ca206e8e12 100644 --- a/src/legacy/core_plugins/data/public/index.ts +++ b/src/legacy/core_plugins/data/public/index.ts @@ -43,14 +43,7 @@ export { SearchBar, SearchBarProps, SavedQueryAttributes, SavedQuery } from './s /** @public static code */ export * from '../common'; -export { - FilterManager, - FilterStateManager, - uniqFilters, - extractTimeFilter, - changeTimeFilter, - onlyDisabledFiltersChanged, -} from './filter/filter_manager'; +export { FilterStateManager } from './filter/filter_manager'; export { CONTAINS_SPACES, getFromSavedObject, @@ -69,4 +62,11 @@ export { mockIndexPattern, } from './index_patterns'; -export { TimeHistoryContract, TimefilterContract, getTime, InputTimeRange } from './timefilter'; +export { + TimeHistoryContract, + TimefilterContract, + getTime, + InputTimeRange, + extractTimeFilter, + changeTimeFilter, +} from './timefilter'; diff --git a/src/legacy/core_plugins/data/public/mocks.ts b/src/legacy/core_plugins/data/public/mocks.ts index 2a82927bb3ebf..4a7fe8efa4068 100644 --- a/src/legacy/core_plugins/data/public/mocks.ts +++ b/src/legacy/core_plugins/data/public/mocks.ts @@ -17,14 +17,12 @@ * under the License. */ -import { filterServiceMock } from './filter/filter_service.mock'; import { indexPatternsServiceMock } from './index_patterns/index_patterns_service.mock'; import { queryServiceMock } from './query/query_service.mock'; import { timefilterServiceMock } from './timefilter/timefilter_service.mock'; function createDataSetupMock() { return { - filter: filterServiceMock.createSetupContract(), indexPatterns: indexPatternsServiceMock.createSetupContract(), query: queryServiceMock.createSetupContract(), timefilter: timefilterServiceMock.createSetupContract(), diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index e82db0d191f51..597ad86d39d85 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -20,7 +20,6 @@ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; import { SearchService, SearchStart, createSearchBar, StatetfulSearchBarProps } from './search'; import { QueryService, QuerySetup } from './query'; -import { FilterService, FilterSetup, FilterStart } from './filter'; import { TimefilterService, TimefilterSetup } from './timefilter'; import { IndexPatternsService, IndexPatternsSetup, IndexPatternsStart } from './index_patterns'; import { Storage, IStorageWrapper } from '../../../../../src/plugins/kibana_utils/public'; @@ -47,7 +46,6 @@ export interface DataSetup { query: QuerySetup; timefilter: TimefilterSetup; indexPatterns: IndexPatternsSetup; - filter: FilterSetup; } /** @@ -59,7 +57,6 @@ export interface DataStart { query: QuerySetup; timefilter: TimefilterSetup; indexPatterns: IndexPatternsStart; - filter: FilterStart; search: SearchStart; ui: { SearchBar: React.ComponentType; @@ -77,9 +74,8 @@ export interface DataStart { * in the setup/start interfaces. The remaining items exported here are either types, * or static code. */ + export class DataPlugin implements Plugin { - // Exposed services, sorted alphabetically - private readonly filter: FilterService = new FilterService(); private readonly indexPatterns: IndexPatternsService = new IndexPatternsService(); private readonly query: QueryService = new QueryService(); private readonly search: SearchService = new SearchService(); @@ -97,14 +93,10 @@ export class DataPlugin implements Plugin { +const defaultFiltersUpdated = (data: DataPublicPluginStart) => { return (filters: Filter[]) => { - filterManager.setFilters(filters); + data.query.filterManager.setFilters(filters); }; }; @@ -55,16 +54,11 @@ const defaultOnRefreshChange = (timefilter: TimefilterSetup) => { }; }; -export function createSearchBar({ - core, - storage, - timefilter, - filterManager, - data, -}: StatefulSearchBarDeps) { +export function createSearchBar({ core, storage, timefilter, data }: StatefulSearchBarDeps) { // App name should come from the core application service. // Until it's available, we'll ask the user to provide it for the pre-wired component. return (props: StatetfulSearchBarProps) => { + const { filterManager } = data.query; const tfRefreshInterval = timefilter.timefilter.getRefreshInterval(); const fmFilters = filterManager.getFilters(); const [refreshInterval, setRefreshInterval] = useState(tfRefreshInterval.value); @@ -124,7 +118,7 @@ export function createSearchBar({ refreshInterval={refreshInterval} isRefreshPaused={refreshPaused} filters={filters} - onFiltersUpdated={defaultFiltersUpdated(filterManager)} + onFiltersUpdated={defaultFiltersUpdated(data)} onRefreshChange={defaultOnRefreshChange(timefilter)} {...props} /> diff --git a/src/legacy/core_plugins/data/public/shim/legacy_module.ts b/src/legacy/core_plugins/data/public/shim/legacy_module.ts index 54f513d07215d..b0ed3d43a4c8c 100644 --- a/src/legacy/core_plugins/data/public/shim/legacy_module.ts +++ b/src/legacy/core_plugins/data/public/shim/legacy_module.ts @@ -25,9 +25,6 @@ import { wrapInI18nContext } from 'ui/i18n'; import { uiModules } from 'ui/modules'; import { npStart } from 'ui/new_platform'; import { FilterBar, ApplyFiltersPopover } from '../filter'; - -// @ts-ignore -import { mapAndFlattenFilters } from '../filter/filter_manager/lib/map_and_flatten_filters'; import { IndexPatterns } from '../index_patterns/index_patterns'; /** @internal */ diff --git a/src/legacy/core_plugins/data/public/timefilter/index.ts b/src/legacy/core_plugins/data/public/timefilter/index.ts index 17564801cf148..a6260e782c12f 100644 --- a/src/legacy/core_plugins/data/public/timefilter/index.ts +++ b/src/legacy/core_plugins/data/public/timefilter/index.ts @@ -23,3 +23,5 @@ export * from './types'; export { Timefilter, TimefilterContract } from './timefilter'; export { TimeHistory, TimeHistoryContract } from './time_history'; export { getTime } from './get_time'; +export { changeTimeFilter } from './lib/change_time_filter'; +export { extractTimeFilter } from './lib/extract_time_filter'; diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/change_time_filter.test.ts b/src/legacy/core_plugins/data/public/timefilter/lib/change_time_filter.test.ts similarity index 96% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/change_time_filter.test.ts rename to src/legacy/core_plugins/data/public/timefilter/lib/change_time_filter.test.ts index 2e397ff931bb6..5e16120f3b3c2 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/change_time_filter.test.ts +++ b/src/legacy/core_plugins/data/public/timefilter/lib/change_time_filter.test.ts @@ -19,7 +19,7 @@ import { RangeFilter } from '@kbn/es-query'; import { changeTimeFilter } from './change_time_filter'; import { TimeRange } from 'src/plugins/data/public'; -import { timefilterServiceMock } from '../../../timefilter/timefilter_service.mock'; +import { timefilterServiceMock } from '../timefilter_service.mock'; const timefilterMock = timefilterServiceMock.createSetupContract(); const timefilter = timefilterMock.timefilter; diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/change_time_filter.ts b/src/legacy/core_plugins/data/public/timefilter/lib/change_time_filter.ts similarity index 95% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/change_time_filter.ts rename to src/legacy/core_plugins/data/public/timefilter/lib/change_time_filter.ts index 8cd1ce5ba6c84..4780ddb6b4b44 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/change_time_filter.ts +++ b/src/legacy/core_plugins/data/public/timefilter/lib/change_time_filter.ts @@ -20,7 +20,7 @@ import moment from 'moment'; import { keys } from 'lodash'; import { RangeFilter } from '@kbn/es-query'; -import { TimefilterContract } from '../../../timefilter'; +import { TimefilterContract } from '../timefilter'; export function convertRangeFilterToTimeRange(filter: RangeFilter) { const key = keys(filter.range)[0]; diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/extract_time_filter.test.ts b/src/legacy/core_plugins/data/public/timefilter/lib/extract_time_filter.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/extract_time_filter.test.ts rename to src/legacy/core_plugins/data/public/timefilter/lib/extract_time_filter.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/extract_time_filter.ts b/src/legacy/core_plugins/data/public/timefilter/lib/extract_time_filter.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/extract_time_filter.ts rename to src/legacy/core_plugins/data/public/timefilter/lib/extract_time_filter.ts diff --git a/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.js b/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.js index 44c68c84579c6..86fe6db9b0778 100644 --- a/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.js +++ b/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.js @@ -26,6 +26,7 @@ import { import { PhraseFilterManager } from './filter_manager/phrase_filter_manager'; import { createSearchSource } from './create_search_source'; import { i18n } from '@kbn/i18n'; +import { npStart } from 'ui/new_platform'; import chrome from 'ui/chrome'; import { start as data } from '../../../../core_plugins/data/public/legacy'; @@ -187,9 +188,10 @@ export async function listControlFactory(controlParams, useTimeFilter, SearchSou // ignore not found error and return control so it can be displayed in disabled state. } + const { filterManager } = npStart.plugins.data.query; return new ListControl( controlParams, - new PhraseFilterManager(controlParams.id, controlParams.fieldName, indexPattern, data.filter.filterManager), + new PhraseFilterManager(controlParams.id, controlParams.fieldName, indexPattern, filterManager), useTimeFilter, SearchSource, ); diff --git a/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.test.js b/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.test.js index d5c23c2c1c855..b40a9f8e6efd4 100644 --- a/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.test.js +++ b/src/legacy/core_plugins/input_control_vis/public/control/list_control_factory.test.js @@ -24,6 +24,28 @@ jest.mock('ui/timefilter', () => ({ createFilter: jest.fn(), })); +jest.mock('ui/new_platform', () => ({ + npStart: { + plugins: { + data: { + query: { + filterManager: { + fieldName: 'myNumberField', + getIndexPattern: () => ({ + fields: { getByName: name => { + const fields = { myField: { name: 'myField' } }; + return fields[name]; + } } + }), + getAppFilters: jest.fn().mockImplementation(() => ([])), + getGlobalFilters: jest.fn().mockImplementation(() => ([])), + } + } + } + }, + }, +})); + jest.mock('../../../../core_plugins/data/public/legacy', () => ({ start: { indexPatterns: { @@ -36,19 +58,6 @@ jest.mock('../../../../core_plugins/data/public/legacy', () => ({ }), } }, - filter: { - filterManager: { - fieldName: 'myNumberField', - getIndexPattern: () => ({ - fields: { getByName: name => { - const fields = { myField: { name: 'myField' } }; - return fields[name]; - } } - }), - getAppFilters: jest.fn().mockImplementation(() => ([])), - getGlobalFilters: jest.fn().mockImplementation(() => ([])), - } - } } })); diff --git a/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.js b/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.js index efb208bd80045..2a05a1224aab9 100644 --- a/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.js +++ b/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.js @@ -27,6 +27,7 @@ import { RangeFilterManager } from './filter_manager/range_filter_manager'; import { createSearchSource } from './create_search_source'; import { i18n } from '@kbn/i18n'; import { start as data } from '../../../../core_plugins/data/public/legacy'; +import { npStart } from 'ui/new_platform'; const minMaxAgg = (field) => { const aggBody = {}; @@ -106,9 +107,10 @@ export async function rangeControlFactory(controlParams, useTimeFilter, SearchSo } catch (err) { // ignore not found error and return control so it can be displayed in disabled state. } + const { filterManager } = npStart.plugins.data.query; return new RangeControl( controlParams, - new RangeFilterManager(controlParams.id, controlParams.fieldName, indexPattern, data.filter.filterManager), + new RangeFilterManager(controlParams.id, controlParams.fieldName, indexPattern, filterManager), useTimeFilter, SearchSource, ); diff --git a/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.test.js b/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.test.js index c746d116c70b2..3e6d6a49a1118 100644 --- a/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.test.js +++ b/src/legacy/core_plugins/input_control_vis/public/control/range_control_factory.test.js @@ -32,6 +32,28 @@ jest.mock('ui/timefilter', () => ({ createFilter: jest.fn(), })); +jest.mock('ui/new_platform', () => ({ + npStart: { + plugins: { + data: { + query: { + filterManager: { + fieldName: 'myNumberField', + getIndexPattern: () => ({ + fields: { getByName: name => { + const fields = { myNumberField: { name: 'myNumberField' } }; + return fields[name]; + } + } }), + getAppFilters: jest.fn().mockImplementation(() => ([])), + getGlobalFilters: jest.fn().mockImplementation(() => ([])), + } + } + } + }, + }, +})); + jest.mock('../../../../core_plugins/data/public/legacy', () => ({ start: { indexPatterns: { @@ -44,19 +66,6 @@ jest.mock('../../../../core_plugins/data/public/legacy', () => ({ } }), } }, - filter: { - filterManager: { - fieldName: 'myNumberField', - getIndexPattern: () => ({ - fields: { getByName: name => { - const fields = { myNumberField: { name: 'myNumberField' } }; - return fields[name]; - } - } }), - getAppFilters: jest.fn().mockImplementation(() => ([])), - getGlobalFilters: jest.fn().mockImplementation(() => ([])), - } - } } })); diff --git a/src/legacy/core_plugins/input_control_vis/public/vis_controller.js b/src/legacy/core_plugins/input_control_vis/public/vis_controller.js index 1edf5652a76c5..792ff3fe85479 100644 --- a/src/legacy/core_plugins/input_control_vis/public/vis_controller.js +++ b/src/legacy/core_plugins/input_control_vis/public/vis_controller.js @@ -23,7 +23,7 @@ import { I18nContext } from 'ui/i18n'; import { InputControlVis } from './components/vis/input_control_vis'; import { controlFactory } from './control/control_factory'; import { getLineageMap } from './lineage'; -import { start as data } from '../../../core_plugins/data/public/legacy'; +import { npStart } from 'ui/new_platform'; import { SearchSource } from '../../../ui/public/courier/search_source/search_source'; class VisController { @@ -34,7 +34,7 @@ class VisController { this.queryBarUpdateHandler = this.updateControlsFromKbn.bind(this); - this.filterManager = data.filter.filterManager; + this.filterManager = npStart.plugins.data.query.filterManager; this.updateSubsciption = this.filterManager.getUpdates$() .subscribe(this.queryBarUpdateHandler); } diff --git a/src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts b/src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts index 5f3ebd6d22e24..e777501d35ca0 100644 --- a/src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts +++ b/src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts @@ -22,8 +22,9 @@ import { Subscription } from 'rxjs'; import { Filter, FilterStateStore } from '@kbn/es-query'; import { i18n } from '@kbn/i18n'; import { TExecuteTriggerActions } from 'src/plugins/ui_actions/public'; +import { TimeRange, onlyDisabledFiltersChanged } from '../../../../../../plugins/data/public'; import { setup as data } from '../../../../data/public/legacy'; -import { getTime, onlyDisabledFiltersChanged, Query } from '../../../../data/public'; +import { Query, getTime } from '../../../../data/public'; import { APPLY_FILTER_TRIGGER, Container, @@ -46,7 +47,6 @@ import { RequestAdapter, SearchSource, } from '../kibana_services'; -import { TimeRange } from '../../../../../../plugins/data/public'; import { SEARCH_EMBEDDABLE_TYPE } from './constants'; interface SearchScope extends ng.IScope { diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts index b9febc3af54ea..ea0b0fe626d7d 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts @@ -30,14 +30,14 @@ import { import { Subscription } from 'rxjs'; import * as Rx from 'rxjs'; import { Filter } from '@kbn/es-query'; -import { TimeRange } from '../../../../../../plugins/data/public'; +import { TimeRange, onlyDisabledFiltersChanged } from '../../../../../../plugins/data/public'; import { EmbeddableInput, EmbeddableOutput, Embeddable, Container, } from '../../../../../../plugins/embeddable/public'; -import { Query, onlyDisabledFiltersChanged } from '../../../../data/public'; +import { Query } from '../../../../data/public'; import { VISUALIZE_EMBEDDABLE_TYPE } from './constants'; const getKeys = (o: T): Array => Object.keys(o) as Array; diff --git a/src/legacy/core_plugins/tile_map/public/tile_map_visualization.js b/src/legacy/core_plugins/tile_map/public/tile_map_visualization.js index 5b8bb07577510..ca798b6bf2470 100644 --- a/src/legacy/core_plugins/tile_map/public/tile_map_visualization.js +++ b/src/legacy/core_plugins/tile_map/public/tile_map_visualization.js @@ -21,9 +21,8 @@ import { get } from 'lodash'; import { GeohashLayer } from './geohash_layer'; import { BaseMapsVisualizationProvider } from './base_maps_visualization'; import { TileMapTooltipFormatterProvider } from './editors/_tooltip_formatter'; +import { npStart } from 'ui/new_platform'; import { getFormat } from '../../../ui/public/visualize/loader/pipeline_helpers/utilities'; -import { start as data } from '../../../core_plugins/data/public/legacy'; -const filterManager = data.filter.filterManager; export const createTileMapVisualization = ({ serviceSettings, $injector }) => { const BaseMapsVisualization = new BaseMapsVisualizationProvider(serviceSettings); @@ -189,6 +188,7 @@ export const createTileMapVisualization = ({ serviceSettings, $injector }) => { filter[filterName] = { ignore_unmapped: true }; filter[filterName][field] = filterData; + const { filterManager } = npStart.plugins.data.query; filterManager.addFilters([filter]); this.vis.updateState(); diff --git a/src/legacy/core_plugins/vis_type_vega/public/vega_visualization.js b/src/legacy/core_plugins/vis_type_vega/public/vega_visualization.js index 1dc73d6f9ff20..7aa60bb0cc469 100644 --- a/src/legacy/core_plugins/vis_type_vega/public/vega_visualization.js +++ b/src/legacy/core_plugins/vis_type_vega/public/vega_visualization.js @@ -23,6 +23,7 @@ import { VegaView } from './vega_view/vega_view'; import { VegaMapView } from './vega_view/vega_map_view'; import { timefilter } from 'ui/timefilter'; import { start as data } from '../../../core_plugins/data/public/legacy'; +import { npStart } from 'ui/new_platform'; import { findIndexPatternByTitle } from '../../data/public/index_patterns'; @@ -99,11 +100,12 @@ export const createVegaVisualization = ({ serviceSettings }) => class VegaVisual this._vegaView = null; } + const { filterManager } = npStart.plugins.data.query; const vegaViewParams = { parentEl: this._el, vegaParser, serviceSettings, - queryfilter: data.filter.filterManager, + queryfilter: filterManager, timefilter: timefilter, findIndex: this.findIndex.bind(this), }; diff --git a/src/legacy/ui/public/filter_manager/__tests__/filter_generator.js b/src/legacy/ui/public/filter_manager/__tests__/filter_generator.js index a6bf2e7aa6c4c..ed7e25704d5a5 100644 --- a/src/legacy/ui/public/filter_manager/__tests__/filter_generator.js +++ b/src/legacy/ui/public/filter_manager/__tests__/filter_generator.js @@ -24,7 +24,7 @@ import expect from '@kbn/expect'; import ngMock from 'ng_mock'; import { getFilterGenerator } from '..'; import { FilterBarQueryFilterProvider } from '../../filter_manager/query_filter'; -import { uniqFilters } from '../../../../core_plugins/data/public/filter/filter_manager/lib/uniq_filters'; +import { uniqFilters } from '../../../../../plugins/data/public'; import { getPhraseScript } from '@kbn/es-query'; let queryFilter; let filterGen; diff --git a/src/legacy/ui/public/filter_manager/query_filter.js b/src/legacy/ui/public/filter_manager/query_filter.js index 6afe52502df5d..97b3810b7f1c7 100644 --- a/src/legacy/ui/public/filter_manager/query_filter.js +++ b/src/legacy/ui/public/filter_manager/query_filter.js @@ -18,12 +18,10 @@ */ import { FilterStateManager } from 'plugins/data'; +import { npStart } from 'ui/new_platform'; export function FilterBarQueryFilterProvider(getAppState, globalState) { - // TODO: this is imported here to avoid circular imports. - // eslint-disable-next-line @typescript-eslint/no-var-requires - const { start } = require('../../../core_plugins/data/public/legacy'); - const filterManager = start.filter.filterManager; + const { filterManager } = npStart.plugins.data.query; const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager); const queryFilter = {}; diff --git a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js index 20ea9c9141aca..c74288c98d79c 100644 --- a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js +++ b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js @@ -39,6 +39,9 @@ export const npSetup = { }, }, data: { + query: { + filterManager: sinon.fake(), + }, }, inspector: { registerView: () => undefined, @@ -73,6 +76,24 @@ export const npStart = { }, data: { getSuggestions: sinon.fake(), + query: { + filterManager: { + getFetches$: sinon.fake(), + getFilters: sinon.fake(), + getAppFilters: sinon.fake(), + getGlobalFilters: sinon.fake(), + removeFilter: sinon.fake(), + addFilters: sinon.fake(), + setFilters: sinon.fake(), + removeAll: sinon.fake(), + getUpdates$: () => { + return { + subscribe: () => {} + }; + }, + + }, + }, }, inspector: { isAvailable: () => false, diff --git a/src/legacy/ui/public/vis/vis_filters/vis_filters.js b/src/legacy/ui/public/vis/vis_filters/vis_filters.js index f19e2440a21e9..9343585fa9508 100644 --- a/src/legacy/ui/public/vis/vis_filters/vis_filters.js +++ b/src/legacy/ui/public/vis/vis_filters/vis_filters.js @@ -20,7 +20,7 @@ import _ from 'lodash'; import { pushFilterBarFilters } from '../push_filters'; import { onBrushEvent } from './brush_event'; -import { uniqFilters } from '../../../../core_plugins/data/public'; +import { uniqFilters } from '../../../../../plugins/data/public'; import { toggleFilterNegated } from '@kbn/es-query'; /** * For terms aggregations on `__other__` buckets, this assembles a list of applicable filter diff --git a/src/legacy/ui/public/visualize/loader/embedded_visualize_handler.ts b/src/legacy/ui/public/visualize/loader/embedded_visualize_handler.ts index bc2152911d1ec..135260ac01b17 100644 --- a/src/legacy/ui/public/visualize/loader/embedded_visualize_handler.ts +++ b/src/legacy/ui/public/visualize/loader/embedded_visualize_handler.ts @@ -28,7 +28,8 @@ import { toastNotifications } from 'ui/notify'; import { AggConfigs } from 'ui/agg_types/agg_configs'; import { SearchSource } from 'ui/courier'; import { QueryFilter } from 'ui/filter_manager/query_filter'; -import { TimeRange } from 'src/plugins/data/public'; + +import { TimeRange, onlyDisabledFiltersChanged } from '../../../../../plugins/data/public'; import { registries } from '../../../../core_plugins/interpreter/public/registries'; import { Inspector } from '../../inspector'; import { Adapters } from '../../inspector/types'; @@ -42,7 +43,7 @@ import { Vis } from '../../vis'; import { VisFiltersProvider } from '../../vis/vis_filters'; import { PipelineDataLoader } from './pipeline_data_loader'; import { visualizationLoader } from './visualization_loader'; -import { onlyDisabledFiltersChanged, Query } from '../../../../core_plugins/data/public'; +import { Query } from '../../../../core_plugins/data/public'; import { DataAdapter, RequestAdapter } from '../../inspector/adapters'; diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index 7e1b3801b62a4..51f26a4bd7f31 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -34,3 +34,5 @@ export * from './types'; export { IRequestTypesMap, IResponseTypesMap } from './search'; export * from './search'; + +export * from './query'; diff --git a/src/plugins/data/public/mocks.ts b/src/plugins/data/public/mocks.ts index 5e60ca93378d9..2269ba3c55bce 100644 --- a/src/plugins/data/public/mocks.ts +++ b/src/plugins/data/public/mocks.ts @@ -18,6 +18,7 @@ */ import { Plugin } from '.'; import { searchSetupMock } from './search/mocks'; +import { queryServiceMock } from './query/mocks'; export type Setup = jest.Mocked>; export type Start = jest.Mocked>; @@ -29,19 +30,23 @@ const autocompleteMock: any = { }; const createSetupContract = (): Setup => { + const querySetupMock = queryServiceMock.createSetupContract(); const setupContract: Setup = { autocomplete: autocompleteMock as Setup['autocomplete'], search: searchSetupMock, + query: querySetupMock, }; return setupContract; }; const createStartContract = (): Start => { + const queryStartMock = queryServiceMock.createStartContract(); const startContract: Start = { autocomplete: autocompleteMock as Start['autocomplete'], getSuggestions: jest.fn(), search: { search: jest.fn() }, + query: queryStartMock, }; return startContract; }; diff --git a/src/plugins/data/public/plugin.ts b/src/plugins/data/public/plugin.ts index 935a3c5754503..a13e912e77846 100644 --- a/src/plugins/data/public/plugin.ts +++ b/src/plugins/data/public/plugin.ts @@ -18,23 +18,29 @@ */ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../core/public'; -import { AutocompleteProviderRegister } from './autocomplete_provider'; import { DataPublicPluginSetup, DataPublicPluginStart } from './types'; -import { SearchService } from './search/search_service'; +import { AutocompleteProviderRegister } from './autocomplete_provider'; import { getSuggestionsProvider } from './suggestions_provider'; +import { SearchService } from './search/search_service'; +import { QueryService } from './query'; export class DataPublicPlugin implements Plugin { private readonly autocomplete = new AutocompleteProviderRegister(); private readonly searchService: SearchService; + private readonly queryService: QueryService; constructor(initializerContext: PluginInitializerContext) { this.searchService = new SearchService(initializerContext); + this.queryService = new QueryService(); } public setup(core: CoreSetup): DataPublicPluginSetup { return { autocomplete: this.autocomplete, search: this.searchService.setup(core), + query: this.queryService.setup({ + uiSettings: core.uiSettings, + }), }; } @@ -43,6 +49,7 @@ export class DataPublicPlugin implements Plugin { @@ -38,9 +34,6 @@ setupMock.uiSettings.get.mockImplementation((key: string) => { }); describe('filter_manager', () => { - let appStateStub: StubState; - let globalStateStub: StubState; - let updateSubscription: Subscription | undefined; let fetchSubscription: Subscription | undefined; let updateListener: sinon.SinonSpy; @@ -50,20 +43,8 @@ describe('filter_manager', () => { beforeEach(() => { updateListener = sinon.stub(); - appStateStub = new StubState(); - globalStateStub = new StubState(); filterManager = new FilterManager(setupMock.uiSettings); readyFilters = getFiltersArray(); - - // FilterStateManager is tested indirectly. - // Therefore, we don't need it's instance. - new FilterStateManager( - globalStateStub, - () => { - return appStateStub; - }, - filterManager - ); }); afterEach(async () => { @@ -84,32 +65,6 @@ describe('filter_manager', () => { expect(updateSubscription).toBeInstanceOf(Subscription); expect(fetchSubscription).toBeInstanceOf(Subscription); }); - - test('should observe global state', done => { - updateSubscription = filterManager.getUpdates$().subscribe(() => { - expect(filterManager.getGlobalFilters()).toHaveLength(1); - if (updateSubscription) { - updateSubscription.unsubscribe(); - } - done(); - }); - - const f1 = getFilter(FilterStateStore.GLOBAL_STATE, true, true, 'age', 34); - globalStateStub.filters.push(f1); - }); - - test('should observe app state', done => { - updateSubscription = filterManager.getUpdates$().subscribe(() => { - expect(filterManager.getAppFilters()).toHaveLength(1); - if (updateSubscription) { - updateSubscription.unsubscribe(); - } - done(); - }); - - const f1 = getFilter(FilterStateStore.APP_STATE, false, false, 'age', 34); - appStateStub.filters.push(f1); - }); }); describe('get \\ set filters', () => { @@ -222,10 +177,11 @@ describe('filter_manager', () => { updateSubscription = filterManager.getUpdates$().subscribe(updateListener); const f1 = getFilter(FilterStateStore.APP_STATE, false, false, 'age', 34); filterManager.addFilters(f1); - expect(filterManager.getAppFilters()).toHaveLength(1); + const appFilters = filterManager.getAppFilters(); + expect(appFilters).toHaveLength(1); + expect(appFilters[0]).toEqual(f1); expect(filterManager.getGlobalFilters()).toHaveLength(0); expect(updateListener.callCount).toBe(1); - expect(appStateStub.filters.length).toBe(1); }); test('app state should accept array', async () => { @@ -233,9 +189,10 @@ describe('filter_manager', () => { const f2 = getFilter(FilterStateStore.APP_STATE, false, false, 'gender', 'female'); filterManager.addFilters([f1]); filterManager.addFilters([f2]); - expect(filterManager.getAppFilters()).toHaveLength(2); + const appFilters = filterManager.getAppFilters(); + expect(appFilters).toHaveLength(2); + expect(appFilters).toEqual([f2, f1]); expect(filterManager.getGlobalFilters()).toHaveLength(0); - expect(appStateStub.filters.length).toBe(2); }); test('global state should accept a single filer', async () => { @@ -243,9 +200,10 @@ describe('filter_manager', () => { const f1 = getFilter(FilterStateStore.GLOBAL_STATE, false, false, 'age', 34); filterManager.addFilters(f1); expect(filterManager.getAppFilters()).toHaveLength(0); - expect(filterManager.getGlobalFilters()).toHaveLength(1); + const globalFilters = filterManager.getGlobalFilters(); + expect(globalFilters).toHaveLength(1); + expect(globalFilters[0]).toEqual(f1); expect(updateListener.callCount).toBe(1); - expect(globalStateStub.filters.length).toBe(1); }); test('global state should be accept array', async () => { @@ -253,8 +211,9 @@ describe('filter_manager', () => { const f2 = getFilter(FilterStateStore.GLOBAL_STATE, false, false, 'gender', 'female'); filterManager.addFilters([f1, f2]); expect(filterManager.getAppFilters()).toHaveLength(0); - expect(filterManager.getGlobalFilters()).toHaveLength(2); - expect(globalStateStub.filters.length).toBe(2); + const globalFilters = filterManager.getGlobalFilters(); + expect(globalFilters).toHaveLength(2); + expect(globalFilters).toEqual([f2, f1]); }); test('add multiple filters at once', async () => { @@ -370,7 +329,6 @@ describe('filter_manager', () => { filterManager.addFilters(negatedFilter); // The negated filter should overwrite the positive one - expect(globalStateStub.filters.length).toBe(1); expect(filterManager.getFilters()).toHaveLength(1); expect(filterManager.getFilters()[0]).toEqual(negatedFilter); }); @@ -383,16 +341,16 @@ describe('filter_manager', () => { filterManager.addFilters(negatedFilter); // The negated filter should overwrite the positive one - expect(globalStateStub.filters.length).toBe(1); - expect(globalStateStub.filters[0]).toEqual(negatedFilter); + expect(filterManager.getFilters()).toHaveLength(1); + expect(filterManager.getFilters()[0]).toEqual(negatedFilter); // Add negate: false version of the filter const filter = _.cloneDeep(readyFilters[0]); filter.meta.negate = false; filterManager.addFilters(filter); - expect(globalStateStub.filters.length).toBe(1); - expect(globalStateStub.filters[0]).toEqual(filter); + expect(filterManager.getFilters()).toHaveLength(1); + expect(filterManager.getFilters()[0]).toEqual(filter); }); test('should fire the update and fetch events', async function() { @@ -409,10 +367,6 @@ describe('filter_manager', () => { filterManager.addFilters(readyFilters); - // updates should trigger state saves - expect(appStateStub.save.callCount).toBe(1); - expect(globalStateStub.save.callCount).toBe(1); - // this time, events should be emitted expect(fetchStub).toBeCalledTimes(1); expect(updateStub).toBeCalledTimes(1); @@ -420,25 +374,25 @@ describe('filter_manager', () => { }); describe('filter reconciliation', function() { - test('should de-dupe appStateStub filters being added', async function() { + test('should de-dupe app filters being added', async function() { const newFilter = _.cloneDeep(readyFilters[1]); filterManager.addFilters(readyFilters, false); - expect(appStateStub.filters.length).toBe(3); + expect(filterManager.getFilters()).toHaveLength(3); filterManager.addFilters(newFilter, false); - expect(appStateStub.filters.length).toBe(3); + expect(filterManager.getFilters()).toHaveLength(3); }); - test('should de-dupe globalStateStub filters being added', async function() { + test('should de-dupe global filters being added', async function() { const newFilter = _.cloneDeep(readyFilters[1]); filterManager.addFilters(readyFilters, true); - expect(globalStateStub.filters.length).toBe(3); + expect(filterManager.getFilters()).toHaveLength(3); filterManager.addFilters(newFilter, true); - expect(globalStateStub.filters.length).toBe(3); + expect(filterManager.getFilters()).toHaveLength(3); }); - test('should de-dupe globalStateStub filters being set', async () => { + test('should de-dupe global filters being set', async () => { const f1 = getFilter(FilterStateStore.GLOBAL_STATE, false, false, 'age', 34); const f2 = _.cloneDeep(f1); filterManager.setFilters([f1, f2]); @@ -447,7 +401,7 @@ describe('filter_manager', () => { expect(filterManager.getFilters()).toHaveLength(1); }); - test('should de-dupe appStateStub filters being set', async () => { + test('should de-dupe app filters being set', async () => { const f1 = getFilter(FilterStateStore.APP_STATE, false, false, 'age', 34); const f2 = _.cloneDeep(f1); filterManager.setFilters([f1, f2]); @@ -475,7 +429,7 @@ describe('filter_manager', () => { }); }); - test('should merge conflicting appStateStub filters', async function() { + test('should merge conflicting app filters', async function() { filterManager.addFilters(readyFilters, true); const appFilter = _.cloneDeep(readyFilters[1]); appFilter.meta.negate = true; @@ -580,16 +534,16 @@ describe('filter_manager', () => { test('should remove the filter from appStateStub', async function() { filterManager.addFilters(readyFilters, false); - expect(appStateStub.filters).toHaveLength(3); + expect(filterManager.getAppFilters()).toHaveLength(3); filterManager.removeFilter(readyFilters[0]); - expect(appStateStub.filters).toHaveLength(2); + expect(filterManager.getAppFilters()).toHaveLength(2); }); test('should remove the filter from globalStateStub', async function() { filterManager.addFilters(readyFilters, true); - expect(globalStateStub.filters).toHaveLength(3); + expect(filterManager.getGlobalFilters()).toHaveLength(3); filterManager.removeFilter(readyFilters[0]); - expect(globalStateStub.filters).toHaveLength(2); + expect(filterManager.getGlobalFilters()).toHaveLength(2); }); test('should fire the update and fetch events', async function() { @@ -619,8 +573,8 @@ describe('filter_manager', () => { filterManager.removeFilter(readyFilters[0]); - expect(globalStateStub.filters).toHaveLength(1); - expect(appStateStub.filters).toHaveLength(1); + expect(filterManager.getAppFilters()).toHaveLength(1); + expect(filterManager.getGlobalFilters()).toHaveLength(1); }); test('should remove matching filters by comparison', async function() { @@ -629,12 +583,12 @@ describe('filter_manager', () => { filterManager.removeFilter(_.cloneDeep(readyFilters[0])); - expect(globalStateStub.filters).toHaveLength(1); - expect(appStateStub.filters).toHaveLength(1); + expect(filterManager.getAppFilters()).toHaveLength(1); + expect(filterManager.getGlobalFilters()).toHaveLength(1); filterManager.removeFilter(_.cloneDeep(readyFilters[2])); - expect(globalStateStub.filters).toHaveLength(1); - expect(appStateStub.filters).toHaveLength(0); + expect(filterManager.getAppFilters()).toHaveLength(0); + expect(filterManager.getGlobalFilters()).toHaveLength(1); }); test('should do nothing with a non-matching filter', async function() { @@ -645,19 +599,19 @@ describe('filter_manager', () => { missedFilter.meta.negate = !readyFilters[0].meta.negate; filterManager.removeFilter(missedFilter); - expect(globalStateStub.filters).toHaveLength(2); - expect(appStateStub.filters).toHaveLength(1); + expect(filterManager.getAppFilters()).toHaveLength(1); + expect(filterManager.getGlobalFilters()).toHaveLength(2); }); test('should remove all the filters from both states', async function() { filterManager.addFilters([readyFilters[0], readyFilters[1]], true); filterManager.addFilters([readyFilters[2]], false); - expect(globalStateStub.filters).toHaveLength(2); - expect(appStateStub.filters).toHaveLength(1); + expect(filterManager.getAppFilters()).toHaveLength(1); + expect(filterManager.getGlobalFilters()).toHaveLength(2); filterManager.removeAll(); - expect(globalStateStub.filters).toHaveLength(0); - expect(appStateStub.filters).toHaveLength(0); + expect(filterManager.getAppFilters()).toHaveLength(0); + expect(filterManager.getGlobalFilters()).toHaveLength(0); }); }); diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts b/src/plugins/data/public/query/filter_manager/filter_manager.ts similarity index 99% rename from src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts rename to src/plugins/data/public/query/filter_manager/filter_manager.ts index b3d6bd6873f50..66b65a40926cb 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.ts +++ b/src/plugins/data/public/query/filter_manager/filter_manager.ts @@ -28,7 +28,7 @@ import { compareFilters } from './lib/compare_filters'; import { mapAndFlattenFilters } from './lib/map_and_flatten_filters'; import { uniqFilters } from './lib/uniq_filters'; import { onlyDisabledFiltersChanged } from './lib/only_disabled'; -import { PartitionedFilters } from './partitioned_filters'; +import { PartitionedFilters } from './types'; export class FilterManager { private filters: Filter[] = []; diff --git a/src/plugins/data/public/query/filter_manager/index.ts b/src/plugins/data/public/query/filter_manager/index.ts new file mode 100644 index 0000000000000..7955cdd825ee6 --- /dev/null +++ b/src/plugins/data/public/query/filter_manager/index.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +export { FilterManager } from './filter_manager'; + +export { uniqFilters } from './lib/uniq_filters'; +export { mapAndFlattenFilters } from './lib/map_and_flatten_filters'; +export { onlyDisabledFiltersChanged } from './lib/only_disabled'; diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/compare_filters.test.ts b/src/plugins/data/public/query/filter_manager/lib/compare_filters.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/compare_filters.test.ts rename to src/plugins/data/public/query/filter_manager/lib/compare_filters.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/compare_filters.ts b/src/plugins/data/public/query/filter_manager/lib/compare_filters.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/compare_filters.ts rename to src/plugins/data/public/query/filter_manager/lib/compare_filters.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/dedup_filters.test.ts b/src/plugins/data/public/query/filter_manager/lib/dedup_filters.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/dedup_filters.test.ts rename to src/plugins/data/public/query/filter_manager/lib/dedup_filters.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/dedup_filters.ts b/src/plugins/data/public/query/filter_manager/lib/dedup_filters.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/dedup_filters.ts rename to src/plugins/data/public/query/filter_manager/lib/dedup_filters.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/generate_mapping_chain.test.ts b/src/plugins/data/public/query/filter_manager/lib/generate_mapping_chain.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/generate_mapping_chain.test.ts rename to src/plugins/data/public/query/filter_manager/lib/generate_mapping_chain.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/generate_mapping_chain.ts b/src/plugins/data/public/query/filter_manager/lib/generate_mapping_chain.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/generate_mapping_chain.ts rename to src/plugins/data/public/query/filter_manager/lib/generate_mapping_chain.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_and_flatten_filters.test.ts b/src/plugins/data/public/query/filter_manager/lib/map_and_flatten_filters.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_and_flatten_filters.test.ts rename to src/plugins/data/public/query/filter_manager/lib/map_and_flatten_filters.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_and_flatten_filters.ts b/src/plugins/data/public/query/filter_manager/lib/map_and_flatten_filters.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_and_flatten_filters.ts rename to src/plugins/data/public/query/filter_manager/lib/map_and_flatten_filters.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_filter.test.ts b/src/plugins/data/public/query/filter_manager/lib/map_filter.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_filter.test.ts rename to src/plugins/data/public/query/filter_manager/lib/map_filter.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_filter.ts b/src/plugins/data/public/query/filter_manager/lib/map_filter.ts similarity index 84% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_filter.ts rename to src/plugins/data/public/query/filter_manager/lib/map_filter.ts index c0d251e647fd1..cda9591e40b33 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_filter.ts +++ b/src/plugins/data/public/query/filter_manager/lib/map_filter.ts @@ -20,16 +20,16 @@ import { Filter } from '@kbn/es-query'; import { reduceRight } from 'lodash'; -import { mapMatchAll } from './map_match_all'; -import { mapPhrase } from './map_phrase'; -import { mapPhrases } from './map_phrases'; -import { mapRange } from './map_range'; -import { mapExists } from './map_exists'; -import { mapMissing } from './map_missing'; -import { mapQueryString } from './map_query_string'; -import { mapGeoBoundingBox } from './map_geo_bounding_box'; -import { mapGeoPolygon } from './map_geo_polygon'; -import { mapDefault } from './map_default'; +import { mapMatchAll } from './mappers/map_match_all'; +import { mapPhrase } from './mappers/map_phrase'; +import { mapPhrases } from './mappers/map_phrases'; +import { mapRange } from './mappers/map_range'; +import { mapExists } from './mappers/map_exists'; +import { mapMissing } from './mappers/map_missing'; +import { mapQueryString } from './mappers/map_query_string'; +import { mapGeoBoundingBox } from './mappers/map_geo_bounding_box'; +import { mapGeoPolygon } from './mappers/map_geo_polygon'; +import { mapDefault } from './mappers/map_default'; import { generateMappingChain } from './generate_mapping_chain'; export function mapFilter(filter: Filter) { diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_default.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_default.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_default.test.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_default.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_default.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_default.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_default.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_default.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_exists.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_exists.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_exists.test.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_exists.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_exists.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_exists.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_exists.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_exists.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_geo_bounding_box.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_bounding_box.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_geo_bounding_box.test.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_bounding_box.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_geo_bounding_box.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_bounding_box.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_geo_bounding_box.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_bounding_box.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_geo_polygon.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_polygon.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_geo_polygon.test.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_polygon.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_geo_polygon.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_polygon.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_geo_polygon.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_polygon.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_match_all.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_match_all.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_match_all.test.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_match_all.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_match_all.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_match_all.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_match_all.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_match_all.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_missing.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_missing.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_missing.test.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_missing.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_missing.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_missing.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_missing.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_missing.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_phrase.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrase.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_phrase.test.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_phrase.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_phrase.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrase.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_phrase.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_phrase.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_phrases.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrases.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_phrases.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_phrases.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_query_string.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_query_string.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_query_string.test.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_query_string.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_query_string.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_query_string.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_query_string.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_query_string.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_range.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_range.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_range.test.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_range.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_range.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_range.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/map_range.ts rename to src/plugins/data/public/query/filter_manager/lib/mappers/map_range.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/only_disabled.test.ts b/src/plugins/data/public/query/filter_manager/lib/only_disabled.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/only_disabled.test.ts rename to src/plugins/data/public/query/filter_manager/lib/only_disabled.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/only_disabled.ts b/src/plugins/data/public/query/filter_manager/lib/only_disabled.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/only_disabled.ts rename to src/plugins/data/public/query/filter_manager/lib/only_disabled.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/uniq_filters.test.ts b/src/plugins/data/public/query/filter_manager/lib/uniq_filters.test.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/uniq_filters.test.ts rename to src/plugins/data/public/query/filter_manager/lib/uniq_filters.test.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/lib/uniq_filters.ts b/src/plugins/data/public/query/filter_manager/lib/uniq_filters.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/lib/uniq_filters.ts rename to src/plugins/data/public/query/filter_manager/lib/uniq_filters.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/test_helpers/get_filters_array.ts b/src/plugins/data/public/query/filter_manager/test_helpers/get_filters_array.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/test_helpers/get_filters_array.ts rename to src/plugins/data/public/query/filter_manager/test_helpers/get_filters_array.ts diff --git a/src/plugins/data/public/query/filter_manager/test_helpers/get_stub_filter.ts b/src/plugins/data/public/query/filter_manager/test_helpers/get_stub_filter.ts new file mode 100644 index 0000000000000..20d9e236f49be --- /dev/null +++ b/src/plugins/data/public/query/filter_manager/test_helpers/get_stub_filter.ts @@ -0,0 +1,45 @@ +/* + * 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, FilterStateStore } from '@kbn/es-query'; + +export function getFilter( + store: FilterStateStore, + disabled: boolean, + negated: boolean, + queryKey: string, + queryValue: any +): Filter { + return { + $state: { + store, + }, + meta: { + index: 'logstash-*', + disabled, + negate: negated, + alias: null, + }, + query: { + match: { + [queryKey]: queryValue, + }, + }, + }; +} diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/partitioned_filters.ts b/src/plugins/data/public/query/filter_manager/types.ts similarity index 100% rename from src/legacy/core_plugins/data/public/filter/filter_manager/partitioned_filters.ts rename to src/plugins/data/public/query/filter_manager/types.ts diff --git a/src/legacy/core_plugins/data/public/filter/filter_manager/test_helpers/stub_index_pattern.ts b/src/plugins/data/public/query/index.tsx similarity index 84% rename from src/legacy/core_plugins/data/public/filter/filter_manager/test_helpers/stub_index_pattern.ts rename to src/plugins/data/public/query/index.tsx index d429fc7f70f38..44b371b6adf19 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_manager/test_helpers/stub_index_pattern.ts +++ b/src/plugins/data/public/query/index.tsx @@ -17,12 +17,6 @@ * under the License. */ -export class StubIndexPatterns { - async get(index: string) { - return { - fields: { - getByName: () => undefined, - }, - }; - } -} +export * from './query_service'; + +export * from './filter_manager'; diff --git a/src/legacy/core_plugins/data/public/filter/filter_service.mock.ts b/src/plugins/data/public/query/mocks.ts similarity index 80% rename from src/legacy/core_plugins/data/public/filter/filter_service.mock.ts rename to src/plugins/data/public/query/mocks.ts index 94268ef69c49a..e5030c5765316 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_service.mock.ts +++ b/src/plugins/data/public/query/mocks.ts @@ -17,12 +17,12 @@ * under the License. */ -import { FilterService, FilterStart, FilterSetup } from '.'; +import { QueryService, QueryStart, QuerySetup } from '.'; -type FilterServiceClientContract = PublicMethodsOf; +type QueryServiceClientContract = PublicMethodsOf; const createSetupContractMock = () => { - const setupContract: jest.Mocked = { + const setupContract: jest.Mocked = { filterManager: jest.fn() as any, }; @@ -30,7 +30,7 @@ const createSetupContractMock = () => { }; const createStartContractMock = () => { - const startContract: jest.Mocked = { + const startContract: jest.Mocked = { filterManager: jest.fn() as any, }; @@ -38,7 +38,7 @@ const createStartContractMock = () => { }; const createMock = () => { - const mocked: jest.Mocked = { + const mocked: jest.Mocked = { setup: jest.fn(), start: jest.fn(), stop: jest.fn(), @@ -49,7 +49,7 @@ const createMock = () => { return mocked; }; -export const filterServiceMock = { +export const queryServiceMock = { create: createMock, createSetupContract: createSetupContractMock, createStartContract: createStartContractMock, diff --git a/src/legacy/core_plugins/data/public/filter/filter_service.ts b/src/plugins/data/public/query/query_service.ts similarity index 82% rename from src/legacy/core_plugins/data/public/filter/filter_service.ts rename to src/plugins/data/public/query/query_service.ts index 0c46259ef0e00..d34909a5e03b7 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_service.ts +++ b/src/plugins/data/public/query/query_service.ts @@ -21,18 +21,18 @@ import { UiSettingsClientContract } from 'src/core/public'; import { FilterManager } from './filter_manager'; /** - * Filter Service + * Query Service * @internal */ -export interface FilterServiceDependencies { +export interface QueryServiceDependencies { uiSettings: UiSettingsClientContract; } -export class FilterService { +export class QueryService { filterManager!: FilterManager; - public setup({ uiSettings }: FilterServiceDependencies) { + public setup({ uiSettings }: QueryServiceDependencies) { this.filterManager = new FilterManager(uiSettings); return { @@ -52,5 +52,5 @@ export class FilterService { } /** @public */ -export type FilterSetup = ReturnType; -export type FilterStart = ReturnType; +export type QuerySetup = ReturnType; +export type QueryStart = ReturnType; diff --git a/src/plugins/data/public/types.ts b/src/plugins/data/public/types.ts index 5f94734fef083..9939815c1efd1 100644 --- a/src/plugins/data/public/types.ts +++ b/src/plugins/data/public/types.ts @@ -22,15 +22,18 @@ export * from './autocomplete_provider/types'; import { AutocompletePublicPluginSetup, AutocompletePublicPluginStart } from '.'; import { ISearchSetup, ISearchStart } from './search'; import { IGetSuggestions } from './suggestions_provider/types'; +import { QuerySetup, QueryStart } from './query'; export interface DataPublicPluginSetup { autocomplete: AutocompletePublicPluginSetup; search: ISearchSetup; + query: QuerySetup; } export interface DataPublicPluginStart { autocomplete: AutocompletePublicPluginStart; getSuggestions: IGetSuggestions; search: ISearchStart; + query: QueryStart; } export { IGetSuggestions } from './suggestions_provider/types'; diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx index 6d9c846aed10e..a1710d67b31db 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx @@ -97,6 +97,11 @@ describe('Lens App', () => { }, }, }, + data: { + query: { + filterManager: createMockFilterManager(), + }, + }, dataShim: { indexPatterns: { indexPatterns: { @@ -106,9 +111,6 @@ describe('Lens App', () => { }, }, timefilter: { history: {} }, - filter: { - filterManager: createMockFilterManager(), - }, }, storage: { get: jest.fn(), @@ -592,7 +594,7 @@ describe('Lens App', () => { const instance = mount(); - args.dataShim.filter.filterManager.setFilters([ + args.data.query.filterManager.setFilters([ buildExistsFilter({ name: 'myfield' }, { id: 'index1' }), ]); @@ -723,7 +725,7 @@ describe('Lens App', () => { query: { query: 'new', language: 'lucene' }, }); - args.dataShim.filter.filterManager.setFilters([ + args.data.query.filterManager.setFilters([ buildExistsFilter({ name: 'myfield' }, { id: 'index1' }), ]); instance.update(); diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index c667cad7fafe5..a95e0450f614c 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx @@ -82,10 +82,9 @@ export function App({ const { lastKnownDoc } = state; useEffect(() => { - const subscription = dataShim.filter.filterManager.getUpdates$().subscribe({ + const subscription = data.query.filterManager.getUpdates$().subscribe({ next: () => { - setState(s => ({ ...s, filters: dataShim.filter.filterManager.getFilters() })); - + setState(s => ({ ...s, filters: data.query.filterManager.getFilters() })); trackUiEvent('app_filters_updated'); }, }); @@ -227,9 +226,7 @@ export function App({ setState(s => ({ ...s, savedQuery })); }} onSavedQueryUpdated={savedQuery => { - dataShim.filter.filterManager.setFilters( - savedQuery.attributes.filters || state.filters - ); + data.query.filterManager.setFilters(savedQuery.attributes.filters || state.filters); setState(s => ({ ...s, savedQuery: { ...savedQuery }, // Shallow query for reference issues @@ -242,7 +239,7 @@ export function App({ })); }} onClearSavedQuery={() => { - dataShim.filter.filterManager.removeAll(); + data.query.filterManager.removeAll(); setState(s => ({ ...s, savedQuery: undefined, diff --git a/x-pack/legacy/plugins/maps/public/angular/map_controller.js b/x-pack/legacy/plugins/maps/public/angular/map_controller.js index b7052bd83a568..cef2a70a6d03d 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -55,6 +55,7 @@ import { } from '../../common/constants'; import { FilterStateStore } from '@kbn/es-query'; import { start as data } from '../../../../../../src/legacy/core_plugins/data/public/legacy'; +import { npStart } from 'ui/new_platform'; const { savedQueryService } = data.search.services; @@ -63,7 +64,7 @@ const REACT_ANCHOR_DOM_ELEMENT_ID = 'react-maps-root'; const app = uiModules.get(MAP_APP_PATH, []); app.controller('GisMapController', ($scope, $route, kbnUrl, localStorage, AppState, globalState) => { - + const { filterManager } = npStart.plugins.data.query; const savedMap = $route.current.locals.map; let unsubscribe; let initialLayerListConfig; @@ -99,7 +100,7 @@ app.controller('GisMapController', ($scope, $route, kbnUrl, localStorage, AppSta $scope.$evalAsync(() => { // appState $state.query = $scope.query; - $state.filters = data.filter.filterManager.getAppFilters(); + $state.filters = filterManager.getAppFilters(); $state.save(); // globalState @@ -108,7 +109,7 @@ app.controller('GisMapController', ($scope, $route, kbnUrl, localStorage, AppSta pause: $scope.refreshConfig.isPaused, value: $scope.refreshConfig.interval, }; - globalState.filters = data.filter.filterManager.getGlobalFilters(); + globalState.filters = filterManager.getGlobalFilters(); globalState.save(); }); } @@ -199,8 +200,8 @@ app.controller('GisMapController', ($scope, $route, kbnUrl, localStorage, AppSta /* End of Saved Queries */ async function onQueryChange({ filters, query, time }) { if (filters) { - await data.filter.filterManager.setFilters(filters); // Maps and merges filters - $scope.filters = data.filter.filterManager.getFilters(); + filterManager.setFilters(filters); // Maps and merges filters + $scope.filters = filterManager.getFilters(); } if (query) { $scope.query = query; diff --git a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.js b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.js index ad190f46f6876..3cff39f684a28 100644 --- a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.js +++ b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.js @@ -11,7 +11,7 @@ import { render, unmountComponentAtNode } from 'react-dom'; import 'mapbox-gl/dist/mapbox-gl.css'; import { Embeddable, APPLY_FILTER_TRIGGER } from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public'; -import { onlyDisabledFiltersChanged } from '../../../../../../src/legacy/core_plugins/data/public'; +import { onlyDisabledFiltersChanged } from '../../../../../../src/plugins/data/public'; import { I18nContext } from 'ui/i18n'; diff --git a/x-pack/legacy/plugins/siem/public/components/search_bar/index.tsx b/x-pack/legacy/plugins/siem/public/components/search_bar/index.tsx index 2ee93471b62d0..e024a4e68492b 100644 --- a/x-pack/legacy/plugins/siem/public/components/search_bar/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/search_bar/index.tsx @@ -17,6 +17,7 @@ import { TimeRange, Query } from 'src/plugins/data/common/types'; import { SavedQuery } from 'src/legacy/core_plugins/data/public'; import { OnTimeChangeProps } from '@elastic/eui'; +import { npStart } from 'ui/new_platform'; import { start as data } from '../../../../../../../src/legacy/core_plugins/data/public/legacy'; import { inputsActions } from '../../store/inputs'; @@ -39,12 +40,11 @@ import { timelineActions, hostsActions, networkActions } from '../../store/actio const { ui: { SearchBar }, - filter, search, timefilter, } = data; -export const siemFilterManager = filter.filterManager; +export const siemFilterManager = npStart.plugins.data.query.filterManager; export const savedQueryService = search.services.savedQueryService; interface SiemSearchBarRedux {