From d3ffbc9089471c1e29c0c7f2444a8f4b778070f6 Mon Sep 17 00:00:00 2001 From: Liza K Date: Mon, 9 Dec 2019 18:42:28 +0200 Subject: [PATCH 01/15] Moved SearchBar component to NP --- src/legacy/core_plugins/data/public/index.ts | 7 +------ .../components/create_search_bar.tsx | 9 ++++++--- .../search/search_bar/components/index.tsx | 1 - src/plugins/data/public/ui/index.ts | 2 +- .../data/public/ui/search_bar/index.tsx | 20 +++++++++++++++++++ .../public/ui/search_bar}/search_bar.test.tsx | 13 ++++++++---- .../data/public/ui/search_bar}/search_bar.tsx | 11 ++++------ 7 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 src/plugins/data/public/ui/search_bar/index.tsx rename src/{legacy/core_plugins/data/public/search/search_bar/components => plugins/data/public/ui/search_bar}/search_bar.test.tsx (96%) rename src/{legacy/core_plugins/data/public/search/search_bar/components => plugins/data/public/ui/search_bar}/search_bar.tsx (98%) diff --git a/src/legacy/core_plugins/data/public/index.ts b/src/legacy/core_plugins/data/public/index.ts index 481349463fc56..c9ce825f3596e 100644 --- a/src/legacy/core_plugins/data/public/index.ts +++ b/src/legacy/core_plugins/data/public/index.ts @@ -30,12 +30,7 @@ export function plugin() { export { DataStart }; export { Field, FieldType, IFieldList, IndexPattern } from './index_patterns'; -export { SearchBar, SearchBarProps } from './search'; -export { - SavedQueryAttributes, - SavedQuery, - SavedQueryTimeFilter, -} from '../../../../plugins/data/public'; +export { SavedQuery, SavedQueryTimeFilter } from '../../../../plugins/data/public'; /** @public static code */ export * from '../common'; diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx b/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx index 125c6b8dad006..d80ef1ab97643 100644 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx +++ b/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx @@ -22,9 +22,12 @@ import { Subscription } from 'rxjs'; import { CoreStart } from 'src/core/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; -import { SearchBar } from '../../../'; -import { SearchBarOwnProps } from '.'; -import { DataPublicPluginStart, esFilters } from '../../../../../../../plugins/data/public'; +import { + DataPublicPluginStart, + SearchBarOwnProps, + SearchBar, + esFilters, +} from '../../../../../../../plugins/data/public'; interface StatefulSearchBarDeps { core: CoreStart; diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx b/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx index accaac163acfc..412d79d07ef4c 100644 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx +++ b/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx @@ -17,5 +17,4 @@ * under the License. */ -export * from './search_bar'; export * from './create_search_bar'; diff --git a/src/plugins/data/public/ui/index.ts b/src/plugins/data/public/ui/index.ts index 8bfccd49bdff3..a0160f3f6f590 100644 --- a/src/plugins/data/public/ui/index.ts +++ b/src/plugins/data/public/ui/index.ts @@ -21,8 +21,8 @@ export { SuggestionsComponent } from './typeahead/suggestions_component'; export { IndexPatternSelect } from './index_pattern_select'; export { FilterBar } from './filter_bar'; export { QueryStringInput } from './query_string_input/query_string_input'; +export { SearchBar, SearchBarOwnProps } from './search_bar'; // temp export - will be removed as final components are migrated to NP -export { QueryBarTopRow } from './query_string_input/query_bar_top_row'; export { SavedQueryManagementComponent } from './saved_query_management'; export { SaveQueryForm, SavedQueryMeta } from './saved_query_form'; diff --git a/src/plugins/data/public/ui/search_bar/index.tsx b/src/plugins/data/public/ui/search_bar/index.tsx new file mode 100644 index 0000000000000..9c0ab5c406241 --- /dev/null +++ b/src/plugins/data/public/ui/search_bar/index.tsx @@ -0,0 +1,20 @@ +/* + * 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 { SearchBar, SearchBarOwnProps } from './search_bar'; diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.test.tsx b/src/plugins/data/public/ui/search_bar/search_bar.test.tsx similarity index 96% rename from src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.test.tsx rename to src/plugins/data/public/ui/search_bar/search_bar.test.tsx index 5752d6a502225..56d444761153f 100644 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.test.tsx +++ b/src/plugins/data/public/ui/search_bar/search_bar.test.tsx @@ -19,15 +19,15 @@ import React from 'react'; import { SearchBar } from './search_bar'; -import { IndexPattern } from '../../../index_patterns'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; import { I18nProvider } from '@kbn/i18n/react'; -import { coreMock } from '../../../../../../../../src/core/public/mocks'; +import { coreMock } from '../../../../../core/public/mocks'; const startMock = coreMock.createStart(); import { mount } from 'enzyme'; +import { IIndexPattern } from '../..'; const mockTimeHistory = { get: () => { @@ -35,9 +35,14 @@ const mockTimeHistory = { }, }; -jest.mock('../../../../../../../plugins/data/public', () => { +jest.mock('../..', () => { return { FilterBar: () =>
, + }; +}); + +jest.mock('../query_string_input/query_bar_top_row', () => { + return { QueryBarTopRow: () =>
, }; }); @@ -74,7 +79,7 @@ const mockIndexPattern = { searchable: true, }, ], -} as IndexPattern; +} as IIndexPattern; const kqlQuery = { query: 'response:200', diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.tsx b/src/plugins/data/public/ui/search_bar/search_bar.tsx similarity index 98% rename from src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.tsx rename to src/plugins/data/public/ui/search_bar/search_bar.tsx index f547fada4a3b1..ceaeb24e7fe7c 100644 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.tsx +++ b/src/plugins/data/public/ui/search_bar/search_bar.tsx @@ -24,10 +24,7 @@ import React, { Component } from 'react'; import ResizeObserver from 'resize-observer-polyfill'; import { get, isEqual } from 'lodash'; -import { - withKibana, - KibanaReactContextValue, -} from '../../../../../../../plugins/kibana_react/public'; +import { withKibana, KibanaReactContextValue } from '../../../../kibana_react/public'; import { IDataPluginServices, TimeRange, @@ -37,12 +34,12 @@ import { TimeHistoryContract, FilterBar, SavedQuery, - SavedQueryAttributes, SavedQueryMeta, SaveQueryForm, SavedQueryManagementComponent, - QueryBarTopRow, -} from '../../../../../../../plugins/data/public'; + SavedQueryAttributes, +} from '../..'; +import { QueryBarTopRow } from '../query_string_input/query_bar_top_row'; interface SearchBarInjectedDeps { kibana: KibanaReactContextValue; From 4196e8b4b9d65f76ea54fec4d8274eba816a4e3c Mon Sep 17 00:00:00 2001 From: Liza K Date: Tue, 10 Dec 2019 13:49:16 +0200 Subject: [PATCH 02/15] move search bar to NP --- src/legacy/core_plugins/data/public/plugin.ts | 37 +---- .../components/create_search_bar.tsx | 129 ------------------ .../search/search_bar/components/index.tsx | 20 --- .../core_plugins/navigation/public/legacy.ts | 3 +- .../core_plugins/navigation/public/plugin.ts | 4 +- .../top_nav_menu/create_top_nav_menu.tsx | 4 +- .../public/top_nav_menu/top_nav_menu.tsx | 7 +- src/plugins/data/public/plugin.ts | 23 +++- src/plugins/data/public/types.ts | 6 +- src/plugins/data/public/ui/index.ts | 2 +- .../data/public/ui/search_bar/index.tsx | 3 +- .../filter_editor/filter_editor.js | 4 +- .../join_editor/resources/where_expression.js | 5 +- .../public/components/query_bar/index.tsx | 3 +- .../public/components/search_bar/index.tsx | 5 +- 15 files changed, 47 insertions(+), 208 deletions(-) delete mode 100644 src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx delete mode 100644 src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index a4fdfd7482f74..7222d7fbaab6d 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -17,9 +17,7 @@ * under the License. */ -import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; -import { createSearchBar, StatetfulSearchBarProps } from './search'; -import { Storage, IStorageWrapper } from '../../../../../src/plugins/kibana_utils/public'; +import { CoreStart, Plugin } from 'kibana/public'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; import { initLegacyModule } from './shim/legacy_module'; @@ -30,17 +28,6 @@ export interface DataPluginStartDependencies { data: DataPublicPluginStart; } -/** - * Interface for this plugin's returned `start` contract. - * - * @public - */ -export interface DataStart { - ui: { - SearchBar: React.ComponentType; - }; -} - /** * Data Plugin - public * @@ -53,29 +40,13 @@ export interface DataStart { * or static code. */ -export class DataPlugin implements Plugin { - private storage!: IStorageWrapper; +export class DataPlugin implements Plugin { + public setup() {} - public setup(core: CoreSetup) { - this.storage = new Storage(window.localStorage); - } - - public start(core: CoreStart, { data }: DataPluginStartDependencies): DataStart { + public start(core: CoreStart, { data }: DataPluginStartDependencies) { // This is required for when Angular code uses Field and FieldList. setFieldFormats(data.fieldFormats); initLegacyModule(data.indexPatterns); - - const SearchBar = createSearchBar({ - core, - data, - storage: this.storage, - }); - - return { - ui: { - SearchBar, - }, - }; } public stop() {} diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx b/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx deleted file mode 100644 index d80ef1ab97643..0000000000000 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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 React, { useState, useEffect } from 'react'; -import { Subscription } from 'rxjs'; -import { CoreStart } from 'src/core/public'; -import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; -import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; -import { - DataPublicPluginStart, - SearchBarOwnProps, - SearchBar, - esFilters, -} from '../../../../../../../plugins/data/public'; - -interface StatefulSearchBarDeps { - core: CoreStart; - data: DataPublicPluginStart; - storage: IStorageWrapper; -} - -export type StatetfulSearchBarProps = SearchBarOwnProps & { - appName: string; -}; - -const defaultFiltersUpdated = (data: DataPublicPluginStart) => { - return (filters: esFilters.Filter[]) => { - data.query.filterManager.setFilters(filters); - }; -}; - -const defaultOnRefreshChange = (data: DataPublicPluginStart) => { - const { timefilter } = data.query.timefilter; - return (options: { isPaused: boolean; refreshInterval: number }) => { - timefilter.setRefreshInterval({ - value: options.refreshInterval, - pause: options.isPaused, - }); - }; -}; - -export function createSearchBar({ core, storage, 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, timefilter } = data.query; - const tfRefreshInterval = timefilter.timefilter.getRefreshInterval(); - const fmFilters = filterManager.getFilters(); - const [refreshInterval, setRefreshInterval] = useState(tfRefreshInterval.value); - const [refreshPaused, setRefreshPaused] = useState(tfRefreshInterval.pause); - - const [filters, setFilters] = useState(fmFilters); - - // We do not really need to keep track of the time - // since this is just for initialization - const timeRange = timefilter.timefilter.getTime(); - - useEffect(() => { - let isSubscribed = true; - const subscriptions = new Subscription(); - subscriptions.add( - timefilter.timefilter.getRefreshIntervalUpdate$().subscribe({ - next: () => { - if (isSubscribed) { - const newRefreshInterval = timefilter.timefilter.getRefreshInterval(); - setRefreshInterval(newRefreshInterval.value); - setRefreshPaused(newRefreshInterval.pause); - } - }, - }) - ); - - subscriptions.add( - filterManager.getUpdates$().subscribe({ - next: () => { - if (isSubscribed) { - const newFilters = filterManager.getFilters(); - setFilters(newFilters); - } - }, - }) - ); - - return () => { - isSubscribed = false; - subscriptions.unsubscribe(); - }; - }, []); - - return ( - - - - ); - }; -} diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx b/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx deleted file mode 100644 index 412d79d07ef4c..0000000000000 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 * from './create_search_bar'; diff --git a/src/legacy/core_plugins/navigation/public/legacy.ts b/src/legacy/core_plugins/navigation/public/legacy.ts index 1783514e6fbdc..8a2fdb5ea4964 100644 --- a/src/legacy/core_plugins/navigation/public/legacy.ts +++ b/src/legacy/core_plugins/navigation/public/legacy.ts @@ -18,7 +18,6 @@ */ import { npSetup, npStart } from 'ui/new_platform'; -import { start as dataShim } from '../../data/public/legacy'; import { plugin } from '.'; const navPlugin = plugin(); @@ -26,5 +25,5 @@ const navPlugin = plugin(); export const setup = navPlugin.setup(npSetup.core); export const start = navPlugin.start(npStart.core, { - data: dataShim, + data: npStart.plugins.data, }); diff --git a/src/legacy/core_plugins/navigation/public/plugin.ts b/src/legacy/core_plugins/navigation/public/plugin.ts index 65a0902dec986..8857120e3f5d0 100644 --- a/src/legacy/core_plugins/navigation/public/plugin.ts +++ b/src/legacy/core_plugins/navigation/public/plugin.ts @@ -21,7 +21,7 @@ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; import { TopNavMenuExtensionsRegistry, TopNavMenuExtensionsRegistrySetup } from './top_nav_menu'; import { createTopNav } from './top_nav_menu/create_top_nav_menu'; import { TopNavMenuProps } from './top_nav_menu/top_nav_menu'; -import { DataStart } from '../../data/public'; +import { DataPublicPluginStart } from '../../../../plugins/data/public'; /** * Interface for this plugin's returned `setup` contract. @@ -44,7 +44,7 @@ export interface NavigationStart { } export interface NavigationPluginStartDependencies { - data: DataStart; + data: DataPublicPluginStart; } export class NavigationPlugin implements Plugin { diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx b/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx index fa0e5fcac7407..53998c2c6db47 100644 --- a/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx +++ b/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx @@ -20,9 +20,9 @@ import React from 'react'; import { TopNavMenuProps, TopNavMenu } from './top_nav_menu'; import { TopNavMenuData } from './top_nav_menu_data'; -import { DataStart } from '../../../../core_plugins/data/public'; +import { DataPublicPluginStart } from '../../../../../plugins/data/public'; -export function createTopNav(data: DataStart, extraConfig: TopNavMenuData[]) { +export function createTopNav(data: DataPublicPluginStart, extraConfig: TopNavMenuData[]) { return (props: TopNavMenuProps) => { const config = (props.config || []).concat(extraConfig); diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx b/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx index 14599e76470c0..b6f055e50bba1 100644 --- a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx +++ b/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx @@ -24,13 +24,13 @@ import { I18nProvider } from '@kbn/i18n/react'; import { TopNavMenuData } from './top_nav_menu_data'; import { TopNavMenuItem } from './top_nav_menu_item'; -import { SearchBarProps, DataStart } from '../../../../core_plugins/data/public'; +import { SearchBarProps, DataPublicPluginStart } from '../../../../../plugins/data/public'; -export type TopNavMenuProps = Partial & { +export type TopNavMenuProps = SearchBarProps & { appName: string; config?: TopNavMenuData[]; showSearchBar?: boolean; - data?: DataStart; + data?: DataPublicPluginStart; }; /* @@ -59,6 +59,7 @@ export function TopNavMenu(props: TopNavMenuProps) { // Validate presense of all required fields if (!showSearchBar || !props.data) return; const { SearchBar } = props.data.ui; + if (!searchBarProps) return; return ; } diff --git a/src/plugins/data/public/plugin.ts b/src/plugins/data/public/plugin.ts index 2a37be7f3f46a..9a83561c3e52b 100644 --- a/src/plugins/data/public/plugin.ts +++ b/src/plugins/data/public/plugin.ts @@ -18,7 +18,7 @@ */ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public'; -import { Storage } from '../../kibana_utils/public'; +import { Storage, IStorageWrapper } from '../../kibana_utils/public'; import { DataPublicPluginSetup, DataPublicPluginStart, @@ -35,24 +35,26 @@ import { IndexPatterns } from './index_patterns'; import { setNotifications, setFieldFormats, setOverlays, setIndexPatterns } from './services'; import { createFilterAction, GLOBAL_APPLY_FILTER_ACTION } from './actions'; import { APPLY_FILTER_TRIGGER } from '../../embeddable/public'; +import { createSearchBar } from './ui/search_bar'; export class DataPublicPlugin implements Plugin { private readonly autocomplete = new AutocompleteProviderRegister(); private readonly searchService: SearchService; private readonly fieldFormatsService: FieldFormatsService; private readonly queryService: QueryService; + private readonly storage!: IStorageWrapper; constructor(initializerContext: PluginInitializerContext) { this.searchService = new SearchService(initializerContext); this.queryService = new QueryService(); this.fieldFormatsService = new FieldFormatsService(); + this.storage = new Storage(window.localStorage); } public setup(core: CoreSetup, { uiActions }: DataSetupDependencies): DataPublicPluginSetup { - const storage = new Storage(window.localStorage); const queryService = this.queryService.setup({ uiSettings: core.uiSettings, - storage, + storage: this.storage, }); uiActions.registerAction( @@ -79,16 +81,27 @@ export class DataPublicPlugin implements Plugin; + SearchBar: React.ComponentType; }; } export * from './autocomplete_provider/types'; export { IGetSuggestions } from './suggestions_provider/types'; +export type IDataPluginNoUI = Omit; + export interface IDataPluginServices extends Partial { appName: string; uiSettings: CoreStart['uiSettings']; @@ -65,5 +69,5 @@ export interface IDataPluginServices extends Partial { notifications: CoreStart['notifications']; http: CoreStart['http']; storage: IStorageWrapper; - data: DataPublicPluginStart; + data: IDataPluginNoUI; } diff --git a/src/plugins/data/public/ui/index.ts b/src/plugins/data/public/ui/index.ts index a0160f3f6f590..820416d99580e 100644 --- a/src/plugins/data/public/ui/index.ts +++ b/src/plugins/data/public/ui/index.ts @@ -21,7 +21,7 @@ export { SuggestionsComponent } from './typeahead/suggestions_component'; export { IndexPatternSelect } from './index_pattern_select'; export { FilterBar } from './filter_bar'; export { QueryStringInput } from './query_string_input/query_string_input'; -export { SearchBar, SearchBarOwnProps } from './search_bar'; +export { SearchBar, SearchBarOwnProps, SearchBarProps } from './search_bar'; // temp export - will be removed as final components are migrated to NP export { SavedQueryManagementComponent } from './saved_query_management'; diff --git a/src/plugins/data/public/ui/search_bar/index.tsx b/src/plugins/data/public/ui/search_bar/index.tsx index 9c0ab5c406241..e288d55a1c914 100644 --- a/src/plugins/data/public/ui/search_bar/index.tsx +++ b/src/plugins/data/public/ui/search_bar/index.tsx @@ -17,4 +17,5 @@ * under the License. */ -export { SearchBar, SearchBarOwnProps } from './search_bar'; +export { SearchBar, SearchBarOwnProps, SearchBarProps } from './search_bar'; +export { createSearchBar } from './create_search_bar'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js index 0086c5067ba12..2e4d0f31bf1db 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js @@ -22,10 +22,8 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { indexPatternService } from '../../../kibana_services'; -import { start as data } from '../../../../../../../../src/legacy/core_plugins/data/public/legacy'; -const { SearchBar } = data.ui; - import { npStart } from 'ui/new_platform'; +const { SearchBar } = npStart.plugins.data.ui; export class FilterEditor extends Component { state = { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js index fb09ed342b8d3..4f91b5f68e5b1 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js @@ -13,9 +13,12 @@ import { EuiFormHelpText, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { SearchBar } from 'plugins/data'; import { npStart } from 'ui/new_platform'; +import { + SearchBar, +} from '../../../../../../../../../src/plugins/data/public'; + export class WhereExpression extends Component { state = { diff --git a/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx b/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx index bf440e238c2a3..a51ee08d17add 100644 --- a/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx @@ -8,11 +8,12 @@ import { isEqual } from 'lodash/fp'; import React, { memo, useState, useEffect, useMemo, useCallback } from 'react'; import { IndexPattern } from 'ui/index_patterns'; -import { SavedQuery, SearchBar } from '../../../../../../../src/legacy/core_plugins/data/public'; import { esFilters, IIndexPattern, FilterManager, + SearchBar, + SavedQuery, Query, TimeHistory, TimeRange, 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 fa9ff1e16ddb7..0474c3885350d 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 @@ -37,12 +37,9 @@ import { import { timelineActions, hostsActions, networkActions } from '../../store/actions'; import { TimeRange, Query, esFilters } from '../../../../../../../src/plugins/data/public'; -const { - ui: { SearchBar }, -} = data; - export const siemFilterManager = npStart.plugins.data.query.filterManager; export const savedQueryService = npStart.plugins.data.query.savedQueries; +const { SearchBar } = npStart.plugins.data.ui; interface SiemSearchBarRedux { end: number; From 52d990fbe4d16a794b3096477da0824a3cc5cef5 Mon Sep 17 00:00:00 2001 From: Liza K Date: Tue, 10 Dec 2019 14:30:24 +0200 Subject: [PATCH 03/15] change import --- .../ui/search_bar/create_search_bar.tsx | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 src/plugins/data/public/ui/search_bar/create_search_bar.tsx diff --git a/src/plugins/data/public/ui/search_bar/create_search_bar.tsx b/src/plugins/data/public/ui/search_bar/create_search_bar.tsx new file mode 100644 index 0000000000000..6a933a251f858 --- /dev/null +++ b/src/plugins/data/public/ui/search_bar/create_search_bar.tsx @@ -0,0 +1,125 @@ +/* + * 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 React, { useState, useEffect } from 'react'; +import { Subscription } from 'rxjs'; +import { CoreStart } from 'src/core/public'; +import { IStorageWrapper } from '../../../../kibana_utils/public'; +import { KibanaContextProvider } from '../../../../kibana_react/public'; +import { IDataPluginNoUI, esFilters } from '../..'; +import { SearchBarOwnProps, SearchBar } from './search_bar'; + +interface StatefulSearchBarDeps { + core: CoreStart; + data: IDataPluginNoUI; + storage: IStorageWrapper; +} + +export type StatefulSearchBarProps = SearchBarOwnProps & { + appName: string; +}; + +const defaultFiltersUpdated = (data: IDataPluginNoUI) => { + return (filters: esFilters.Filter[]) => { + data.query.filterManager.setFilters(filters); + }; +}; + +const defaultOnRefreshChange = (data: IDataPluginNoUI) => { + const { timefilter } = data.query.timefilter; + return (options: { isPaused: boolean; refreshInterval: number }) => { + timefilter.setRefreshInterval({ + value: options.refreshInterval, + pause: options.isPaused, + }); + }; +}; + +export function createSearchBar({ core, storage, 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: StatefulSearchBarProps) => { + const { filterManager, timefilter } = data.query; + const tfRefreshInterval = timefilter.timefilter.getRefreshInterval(); + const fmFilters = filterManager.getFilters(); + const [refreshInterval, setRefreshInterval] = useState(tfRefreshInterval.value); + const [refreshPaused, setRefreshPaused] = useState(tfRefreshInterval.pause); + + const [filters, setFilters] = useState(fmFilters); + + // We do not really need to keep track of the time + // since this is just for initialization + const timeRange = timefilter.timefilter.getTime(); + + useEffect(() => { + let isSubscribed = true; + const subscriptions = new Subscription(); + subscriptions.add( + timefilter.timefilter.getRefreshIntervalUpdate$().subscribe({ + next: () => { + if (isSubscribed) { + const newRefreshInterval = timefilter.timefilter.getRefreshInterval(); + setRefreshInterval(newRefreshInterval.value); + setRefreshPaused(newRefreshInterval.pause); + } + }, + }) + ); + + subscriptions.add( + filterManager.getUpdates$().subscribe({ + next: () => { + if (isSubscribed) { + const newFilters = filterManager.getFilters(); + setFilters(newFilters); + } + }, + }) + ); + + return () => { + isSubscribed = false; + subscriptions.unsubscribe(); + }; + }, [filterManager, timefilter.timefilter]); + + return ( + + + + ); + }; +} From 5e1cfc9f1a064a4c16b6de29531776bbb31566f7 Mon Sep 17 00:00:00 2001 From: Liza K Date: Tue, 10 Dec 2019 15:55:26 +0200 Subject: [PATCH 04/15] Revert "change import" This reverts commit 52d990fbe4d16a794b3096477da0824a3cc5cef5. --- .../ui/search_bar/create_search_bar.tsx | 125 ------------------ 1 file changed, 125 deletions(-) delete mode 100644 src/plugins/data/public/ui/search_bar/create_search_bar.tsx diff --git a/src/plugins/data/public/ui/search_bar/create_search_bar.tsx b/src/plugins/data/public/ui/search_bar/create_search_bar.tsx deleted file mode 100644 index 6a933a251f858..0000000000000 --- a/src/plugins/data/public/ui/search_bar/create_search_bar.tsx +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 React, { useState, useEffect } from 'react'; -import { Subscription } from 'rxjs'; -import { CoreStart } from 'src/core/public'; -import { IStorageWrapper } from '../../../../kibana_utils/public'; -import { KibanaContextProvider } from '../../../../kibana_react/public'; -import { IDataPluginNoUI, esFilters } from '../..'; -import { SearchBarOwnProps, SearchBar } from './search_bar'; - -interface StatefulSearchBarDeps { - core: CoreStart; - data: IDataPluginNoUI; - storage: IStorageWrapper; -} - -export type StatefulSearchBarProps = SearchBarOwnProps & { - appName: string; -}; - -const defaultFiltersUpdated = (data: IDataPluginNoUI) => { - return (filters: esFilters.Filter[]) => { - data.query.filterManager.setFilters(filters); - }; -}; - -const defaultOnRefreshChange = (data: IDataPluginNoUI) => { - const { timefilter } = data.query.timefilter; - return (options: { isPaused: boolean; refreshInterval: number }) => { - timefilter.setRefreshInterval({ - value: options.refreshInterval, - pause: options.isPaused, - }); - }; -}; - -export function createSearchBar({ core, storage, 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: StatefulSearchBarProps) => { - const { filterManager, timefilter } = data.query; - const tfRefreshInterval = timefilter.timefilter.getRefreshInterval(); - const fmFilters = filterManager.getFilters(); - const [refreshInterval, setRefreshInterval] = useState(tfRefreshInterval.value); - const [refreshPaused, setRefreshPaused] = useState(tfRefreshInterval.pause); - - const [filters, setFilters] = useState(fmFilters); - - // We do not really need to keep track of the time - // since this is just for initialization - const timeRange = timefilter.timefilter.getTime(); - - useEffect(() => { - let isSubscribed = true; - const subscriptions = new Subscription(); - subscriptions.add( - timefilter.timefilter.getRefreshIntervalUpdate$().subscribe({ - next: () => { - if (isSubscribed) { - const newRefreshInterval = timefilter.timefilter.getRefreshInterval(); - setRefreshInterval(newRefreshInterval.value); - setRefreshPaused(newRefreshInterval.pause); - } - }, - }) - ); - - subscriptions.add( - filterManager.getUpdates$().subscribe({ - next: () => { - if (isSubscribed) { - const newFilters = filterManager.getFilters(); - setFilters(newFilters); - } - }, - }) - ); - - return () => { - isSubscribed = false; - subscriptions.unsubscribe(); - }; - }, [filterManager, timefilter.timefilter]); - - return ( - - - - ); - }; -} From b788ae37e695d58ada5b81303ebd446785ed3062 Mon Sep 17 00:00:00 2001 From: Liza K Date: Tue, 10 Dec 2019 15:55:36 +0200 Subject: [PATCH 05/15] Revert "move search bar to NP" This reverts commit 4196e8b4b9d65f76ea54fec4d8274eba816a4e3c. --- src/legacy/core_plugins/data/public/plugin.ts | 37 ++++- .../components/create_search_bar.tsx | 129 ++++++++++++++++++ .../search/search_bar/components/index.tsx | 20 +++ .../core_plugins/navigation/public/legacy.ts | 3 +- .../core_plugins/navigation/public/plugin.ts | 4 +- .../top_nav_menu/create_top_nav_menu.tsx | 4 +- .../public/top_nav_menu/top_nav_menu.tsx | 7 +- src/plugins/data/public/plugin.ts | 23 +--- src/plugins/data/public/types.ts | 6 +- src/plugins/data/public/ui/index.ts | 2 +- .../data/public/ui/search_bar/index.tsx | 3 +- .../filter_editor/filter_editor.js | 4 +- .../join_editor/resources/where_expression.js | 5 +- .../public/components/query_bar/index.tsx | 3 +- .../public/components/search_bar/index.tsx | 5 +- 15 files changed, 208 insertions(+), 47 deletions(-) create mode 100644 src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx create mode 100644 src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index 7222d7fbaab6d..a4fdfd7482f74 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -17,7 +17,9 @@ * under the License. */ -import { CoreStart, Plugin } from 'kibana/public'; +import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; +import { createSearchBar, StatetfulSearchBarProps } from './search'; +import { Storage, IStorageWrapper } from '../../../../../src/plugins/kibana_utils/public'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; import { initLegacyModule } from './shim/legacy_module'; @@ -28,6 +30,17 @@ export interface DataPluginStartDependencies { data: DataPublicPluginStart; } +/** + * Interface for this plugin's returned `start` contract. + * + * @public + */ +export interface DataStart { + ui: { + SearchBar: React.ComponentType; + }; +} + /** * Data Plugin - public * @@ -40,13 +53,29 @@ export interface DataPluginStartDependencies { * or static code. */ -export class DataPlugin implements Plugin { - public setup() {} +export class DataPlugin implements Plugin { + private storage!: IStorageWrapper; - public start(core: CoreStart, { data }: DataPluginStartDependencies) { + public setup(core: CoreSetup) { + this.storage = new Storage(window.localStorage); + } + + public start(core: CoreStart, { data }: DataPluginStartDependencies): DataStart { // This is required for when Angular code uses Field and FieldList. setFieldFormats(data.fieldFormats); initLegacyModule(data.indexPatterns); + + const SearchBar = createSearchBar({ + core, + data, + storage: this.storage, + }); + + return { + ui: { + SearchBar, + }, + }; } public stop() {} diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx b/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx new file mode 100644 index 0000000000000..d80ef1ab97643 --- /dev/null +++ b/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx @@ -0,0 +1,129 @@ +/* + * 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 React, { useState, useEffect } from 'react'; +import { Subscription } from 'rxjs'; +import { CoreStart } from 'src/core/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; +import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; +import { + DataPublicPluginStart, + SearchBarOwnProps, + SearchBar, + esFilters, +} from '../../../../../../../plugins/data/public'; + +interface StatefulSearchBarDeps { + core: CoreStart; + data: DataPublicPluginStart; + storage: IStorageWrapper; +} + +export type StatetfulSearchBarProps = SearchBarOwnProps & { + appName: string; +}; + +const defaultFiltersUpdated = (data: DataPublicPluginStart) => { + return (filters: esFilters.Filter[]) => { + data.query.filterManager.setFilters(filters); + }; +}; + +const defaultOnRefreshChange = (data: DataPublicPluginStart) => { + const { timefilter } = data.query.timefilter; + return (options: { isPaused: boolean; refreshInterval: number }) => { + timefilter.setRefreshInterval({ + value: options.refreshInterval, + pause: options.isPaused, + }); + }; +}; + +export function createSearchBar({ core, storage, 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, timefilter } = data.query; + const tfRefreshInterval = timefilter.timefilter.getRefreshInterval(); + const fmFilters = filterManager.getFilters(); + const [refreshInterval, setRefreshInterval] = useState(tfRefreshInterval.value); + const [refreshPaused, setRefreshPaused] = useState(tfRefreshInterval.pause); + + const [filters, setFilters] = useState(fmFilters); + + // We do not really need to keep track of the time + // since this is just for initialization + const timeRange = timefilter.timefilter.getTime(); + + useEffect(() => { + let isSubscribed = true; + const subscriptions = new Subscription(); + subscriptions.add( + timefilter.timefilter.getRefreshIntervalUpdate$().subscribe({ + next: () => { + if (isSubscribed) { + const newRefreshInterval = timefilter.timefilter.getRefreshInterval(); + setRefreshInterval(newRefreshInterval.value); + setRefreshPaused(newRefreshInterval.pause); + } + }, + }) + ); + + subscriptions.add( + filterManager.getUpdates$().subscribe({ + next: () => { + if (isSubscribed) { + const newFilters = filterManager.getFilters(); + setFilters(newFilters); + } + }, + }) + ); + + return () => { + isSubscribed = false; + subscriptions.unsubscribe(); + }; + }, []); + + return ( + + + + ); + }; +} diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx b/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx new file mode 100644 index 0000000000000..412d79d07ef4c --- /dev/null +++ b/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx @@ -0,0 +1,20 @@ +/* + * 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 * from './create_search_bar'; diff --git a/src/legacy/core_plugins/navigation/public/legacy.ts b/src/legacy/core_plugins/navigation/public/legacy.ts index 8a2fdb5ea4964..1783514e6fbdc 100644 --- a/src/legacy/core_plugins/navigation/public/legacy.ts +++ b/src/legacy/core_plugins/navigation/public/legacy.ts @@ -18,6 +18,7 @@ */ import { npSetup, npStart } from 'ui/new_platform'; +import { start as dataShim } from '../../data/public/legacy'; import { plugin } from '.'; const navPlugin = plugin(); @@ -25,5 +26,5 @@ const navPlugin = plugin(); export const setup = navPlugin.setup(npSetup.core); export const start = navPlugin.start(npStart.core, { - data: npStart.plugins.data, + data: dataShim, }); diff --git a/src/legacy/core_plugins/navigation/public/plugin.ts b/src/legacy/core_plugins/navigation/public/plugin.ts index 8857120e3f5d0..65a0902dec986 100644 --- a/src/legacy/core_plugins/navigation/public/plugin.ts +++ b/src/legacy/core_plugins/navigation/public/plugin.ts @@ -21,7 +21,7 @@ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; import { TopNavMenuExtensionsRegistry, TopNavMenuExtensionsRegistrySetup } from './top_nav_menu'; import { createTopNav } from './top_nav_menu/create_top_nav_menu'; import { TopNavMenuProps } from './top_nav_menu/top_nav_menu'; -import { DataPublicPluginStart } from '../../../../plugins/data/public'; +import { DataStart } from '../../data/public'; /** * Interface for this plugin's returned `setup` contract. @@ -44,7 +44,7 @@ export interface NavigationStart { } export interface NavigationPluginStartDependencies { - data: DataPublicPluginStart; + data: DataStart; } export class NavigationPlugin implements Plugin { diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx b/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx index 53998c2c6db47..fa0e5fcac7407 100644 --- a/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx +++ b/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx @@ -20,9 +20,9 @@ import React from 'react'; import { TopNavMenuProps, TopNavMenu } from './top_nav_menu'; import { TopNavMenuData } from './top_nav_menu_data'; -import { DataPublicPluginStart } from '../../../../../plugins/data/public'; +import { DataStart } from '../../../../core_plugins/data/public'; -export function createTopNav(data: DataPublicPluginStart, extraConfig: TopNavMenuData[]) { +export function createTopNav(data: DataStart, extraConfig: TopNavMenuData[]) { return (props: TopNavMenuProps) => { const config = (props.config || []).concat(extraConfig); diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx b/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx index b6f055e50bba1..14599e76470c0 100644 --- a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx +++ b/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx @@ -24,13 +24,13 @@ import { I18nProvider } from '@kbn/i18n/react'; import { TopNavMenuData } from './top_nav_menu_data'; import { TopNavMenuItem } from './top_nav_menu_item'; -import { SearchBarProps, DataPublicPluginStart } from '../../../../../plugins/data/public'; +import { SearchBarProps, DataStart } from '../../../../core_plugins/data/public'; -export type TopNavMenuProps = SearchBarProps & { +export type TopNavMenuProps = Partial & { appName: string; config?: TopNavMenuData[]; showSearchBar?: boolean; - data?: DataPublicPluginStart; + data?: DataStart; }; /* @@ -59,7 +59,6 @@ export function TopNavMenu(props: TopNavMenuProps) { // Validate presense of all required fields if (!showSearchBar || !props.data) return; const { SearchBar } = props.data.ui; - if (!searchBarProps) return; return ; } diff --git a/src/plugins/data/public/plugin.ts b/src/plugins/data/public/plugin.ts index 9a83561c3e52b..2a37be7f3f46a 100644 --- a/src/plugins/data/public/plugin.ts +++ b/src/plugins/data/public/plugin.ts @@ -18,7 +18,7 @@ */ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public'; -import { Storage, IStorageWrapper } from '../../kibana_utils/public'; +import { Storage } from '../../kibana_utils/public'; import { DataPublicPluginSetup, DataPublicPluginStart, @@ -35,26 +35,24 @@ import { IndexPatterns } from './index_patterns'; import { setNotifications, setFieldFormats, setOverlays, setIndexPatterns } from './services'; import { createFilterAction, GLOBAL_APPLY_FILTER_ACTION } from './actions'; import { APPLY_FILTER_TRIGGER } from '../../embeddable/public'; -import { createSearchBar } from './ui/search_bar'; export class DataPublicPlugin implements Plugin { private readonly autocomplete = new AutocompleteProviderRegister(); private readonly searchService: SearchService; private readonly fieldFormatsService: FieldFormatsService; private readonly queryService: QueryService; - private readonly storage!: IStorageWrapper; constructor(initializerContext: PluginInitializerContext) { this.searchService = new SearchService(initializerContext); this.queryService = new QueryService(); this.fieldFormatsService = new FieldFormatsService(); - this.storage = new Storage(window.localStorage); } public setup(core: CoreSetup, { uiActions }: DataSetupDependencies): DataPublicPluginSetup { + const storage = new Storage(window.localStorage); const queryService = this.queryService.setup({ uiSettings: core.uiSettings, - storage: this.storage, + storage, }); uiActions.registerAction( @@ -81,27 +79,16 @@ export class DataPublicPlugin implements Plugin; - SearchBar: React.ComponentType; }; } export * from './autocomplete_provider/types'; export { IGetSuggestions } from './suggestions_provider/types'; -export type IDataPluginNoUI = Omit; - export interface IDataPluginServices extends Partial { appName: string; uiSettings: CoreStart['uiSettings']; @@ -69,5 +65,5 @@ export interface IDataPluginServices extends Partial { notifications: CoreStart['notifications']; http: CoreStart['http']; storage: IStorageWrapper; - data: IDataPluginNoUI; + data: DataPublicPluginStart; } diff --git a/src/plugins/data/public/ui/index.ts b/src/plugins/data/public/ui/index.ts index 820416d99580e..a0160f3f6f590 100644 --- a/src/plugins/data/public/ui/index.ts +++ b/src/plugins/data/public/ui/index.ts @@ -21,7 +21,7 @@ export { SuggestionsComponent } from './typeahead/suggestions_component'; export { IndexPatternSelect } from './index_pattern_select'; export { FilterBar } from './filter_bar'; export { QueryStringInput } from './query_string_input/query_string_input'; -export { SearchBar, SearchBarOwnProps, SearchBarProps } from './search_bar'; +export { SearchBar, SearchBarOwnProps } from './search_bar'; // temp export - will be removed as final components are migrated to NP export { SavedQueryManagementComponent } from './saved_query_management'; diff --git a/src/plugins/data/public/ui/search_bar/index.tsx b/src/plugins/data/public/ui/search_bar/index.tsx index e288d55a1c914..9c0ab5c406241 100644 --- a/src/plugins/data/public/ui/search_bar/index.tsx +++ b/src/plugins/data/public/ui/search_bar/index.tsx @@ -17,5 +17,4 @@ * under the License. */ -export { SearchBar, SearchBarOwnProps, SearchBarProps } from './search_bar'; -export { createSearchBar } from './create_search_bar'; +export { SearchBar, SearchBarOwnProps } from './search_bar'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js index 2e4d0f31bf1db..0086c5067ba12 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js @@ -22,8 +22,10 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { indexPatternService } from '../../../kibana_services'; +import { start as data } from '../../../../../../../../src/legacy/core_plugins/data/public/legacy'; +const { SearchBar } = data.ui; + import { npStart } from 'ui/new_platform'; -const { SearchBar } = npStart.plugins.data.ui; export class FilterEditor extends Component { state = { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js index 4f91b5f68e5b1..fb09ed342b8d3 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js @@ -13,12 +13,9 @@ import { EuiFormHelpText, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; +import { SearchBar } from 'plugins/data'; import { npStart } from 'ui/new_platform'; -import { - SearchBar, -} from '../../../../../../../../../src/plugins/data/public'; - export class WhereExpression extends Component { state = { diff --git a/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx b/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx index a51ee08d17add..bf440e238c2a3 100644 --- a/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx @@ -8,12 +8,11 @@ import { isEqual } from 'lodash/fp'; import React, { memo, useState, useEffect, useMemo, useCallback } from 'react'; import { IndexPattern } from 'ui/index_patterns'; +import { SavedQuery, SearchBar } from '../../../../../../../src/legacy/core_plugins/data/public'; import { esFilters, IIndexPattern, FilterManager, - SearchBar, - SavedQuery, Query, TimeHistory, TimeRange, 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 0474c3885350d..fa9ff1e16ddb7 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 @@ -37,9 +37,12 @@ import { import { timelineActions, hostsActions, networkActions } from '../../store/actions'; import { TimeRange, Query, esFilters } from '../../../../../../../src/plugins/data/public'; +const { + ui: { SearchBar }, +} = data; + export const siemFilterManager = npStart.plugins.data.query.filterManager; export const savedQueryService = npStart.plugins.data.query.savedQueries; -const { SearchBar } = npStart.plugins.data.ui; interface SiemSearchBarRedux { end: number; From f8e64e1955b9f55872b5faedf500c5a2e4edec06 Mon Sep 17 00:00:00 2001 From: Liza K Date: Tue, 10 Dec 2019 14:37:46 +0000 Subject: [PATCH 06/15] move create search bar --- src/legacy/core_plugins/data/public/plugin.ts | 28 +++---------------- .../core_plugins/data/public/search/index.ts | 2 -- .../search/search_bar/components/index.tsx | 20 ------------- .../data/public/search/search_bar/index.tsx | 20 ------------- .../core_plugins/navigation/public/legacy.ts | 3 +- .../core_plugins/navigation/public/plugin.ts | 4 +-- .../top_nav_menu/create_top_nav_menu.tsx | 4 +-- .../public/top_nav_menu/top_nav_menu.tsx | 4 +-- src/plugins/data/public/mocks.ts | 1 + src/plugins/data/public/plugin.ts | 23 +++++++++++---- src/plugins/data/public/types.ts | 2 ++ src/plugins/data/public/ui/index.ts | 2 +- .../ui/search_bar}/create_search_bar.tsx | 27 ++++++++---------- .../data/public/ui/search_bar/index.tsx | 2 +- .../filter_editor/filter_editor.js | 4 +-- .../join_editor/resources/where_expression.js | 2 +- .../components/query_bar/index.test.tsx | 3 +- .../public/components/query_bar/index.tsx | 3 +- .../public/components/search_bar/index.tsx | 6 +--- 19 files changed, 52 insertions(+), 108 deletions(-) delete mode 100644 src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx delete mode 100644 src/legacy/core_plugins/data/public/search/search_bar/index.tsx rename src/{legacy/core_plugins/data/public/search/search_bar/components => plugins/data/public/ui/search_bar}/create_search_bar.tsx (85%) diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index a4fdfd7482f74..03e797fba069f 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -18,8 +18,6 @@ */ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; -import { createSearchBar, StatetfulSearchBarProps } from './search'; -import { Storage, IStorageWrapper } from '../../../../../src/plugins/kibana_utils/public'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; import { initLegacyModule } from './shim/legacy_module'; @@ -35,11 +33,8 @@ export interface DataPluginStartDependencies { * * @public */ -export interface DataStart { - ui: { - SearchBar: React.ComponentType; - }; -} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface DataStart {} /** * Data Plugin - public @@ -54,28 +49,13 @@ export interface DataStart { */ export class DataPlugin implements Plugin { - private storage!: IStorageWrapper; - - public setup(core: CoreSetup) { - this.storage = new Storage(window.localStorage); - } + public setup(core: CoreSetup) {} public start(core: CoreStart, { data }: DataPluginStartDependencies): DataStart { // This is required for when Angular code uses Field and FieldList. setFieldFormats(data.fieldFormats); initLegacyModule(data.indexPatterns); - - const SearchBar = createSearchBar({ - core, - data, - storage: this.storage, - }); - - return { - ui: { - SearchBar, - }, - }; + return {}; } public stop() {} diff --git a/src/legacy/core_plugins/data/public/search/index.ts b/src/legacy/core_plugins/data/public/search/index.ts index 24ffa939a746e..9880b336e76e5 100644 --- a/src/legacy/core_plugins/data/public/search/index.ts +++ b/src/legacy/core_plugins/data/public/search/index.ts @@ -16,5 +16,3 @@ * specific language governing permissions and limitations * under the License. */ - -export * from './search_bar'; diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx b/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx deleted file mode 100644 index 412d79d07ef4c..0000000000000 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 * from './create_search_bar'; diff --git a/src/legacy/core_plugins/data/public/search/search_bar/index.tsx b/src/legacy/core_plugins/data/public/search/search_bar/index.tsx deleted file mode 100644 index faf6e24aa6ed5..0000000000000 --- a/src/legacy/core_plugins/data/public/search/search_bar/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 * from './components'; diff --git a/src/legacy/core_plugins/navigation/public/legacy.ts b/src/legacy/core_plugins/navigation/public/legacy.ts index 1783514e6fbdc..8a2fdb5ea4964 100644 --- a/src/legacy/core_plugins/navigation/public/legacy.ts +++ b/src/legacy/core_plugins/navigation/public/legacy.ts @@ -18,7 +18,6 @@ */ import { npSetup, npStart } from 'ui/new_platform'; -import { start as dataShim } from '../../data/public/legacy'; import { plugin } from '.'; const navPlugin = plugin(); @@ -26,5 +25,5 @@ const navPlugin = plugin(); export const setup = navPlugin.setup(npSetup.core); export const start = navPlugin.start(npStart.core, { - data: dataShim, + data: npStart.plugins.data, }); diff --git a/src/legacy/core_plugins/navigation/public/plugin.ts b/src/legacy/core_plugins/navigation/public/plugin.ts index 65a0902dec986..27533e6c8fcf6 100644 --- a/src/legacy/core_plugins/navigation/public/plugin.ts +++ b/src/legacy/core_plugins/navigation/public/plugin.ts @@ -18,10 +18,10 @@ */ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; +import { DataPublicPluginStart } from 'src/plugins/data/public'; import { TopNavMenuExtensionsRegistry, TopNavMenuExtensionsRegistrySetup } from './top_nav_menu'; import { createTopNav } from './top_nav_menu/create_top_nav_menu'; import { TopNavMenuProps } from './top_nav_menu/top_nav_menu'; -import { DataStart } from '../../data/public'; /** * Interface for this plugin's returned `setup` contract. @@ -44,7 +44,7 @@ export interface NavigationStart { } export interface NavigationPluginStartDependencies { - data: DataStart; + data: DataPublicPluginStart; } export class NavigationPlugin implements Plugin { diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx b/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx index fa0e5fcac7407..0b3b7b5b2a272 100644 --- a/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx +++ b/src/legacy/core_plugins/navigation/public/top_nav_menu/create_top_nav_menu.tsx @@ -18,11 +18,11 @@ */ import React from 'react'; +import { DataPublicPluginStart } from 'src/plugins/data/public'; import { TopNavMenuProps, TopNavMenu } from './top_nav_menu'; import { TopNavMenuData } from './top_nav_menu_data'; -import { DataStart } from '../../../../core_plugins/data/public'; -export function createTopNav(data: DataStart, extraConfig: TopNavMenuData[]) { +export function createTopNav(data: DataPublicPluginStart, extraConfig: TopNavMenuData[]) { return (props: TopNavMenuProps) => { const config = (props.config || []).concat(extraConfig); diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx b/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx index 14599e76470c0..d5f951ea3eeea 100644 --- a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx +++ b/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.tsx @@ -24,13 +24,13 @@ import { I18nProvider } from '@kbn/i18n/react'; import { TopNavMenuData } from './top_nav_menu_data'; import { TopNavMenuItem } from './top_nav_menu_item'; -import { SearchBarProps, DataStart } from '../../../../core_plugins/data/public'; +import { SearchBarProps, DataPublicPluginStart } from '../../../../../plugins/data/public'; export type TopNavMenuProps = Partial & { appName: string; config?: TopNavMenuData[]; showSearchBar?: boolean; - data?: DataStart; + data?: DataPublicPluginStart; }; /* diff --git a/src/plugins/data/public/mocks.ts b/src/plugins/data/public/mocks.ts index 058e6c0e2f5c5..03d3dad61ed05 100644 --- a/src/plugins/data/public/mocks.ts +++ b/src/plugins/data/public/mocks.ts @@ -74,6 +74,7 @@ const createStartContract = (): Start => { query: queryStartMock, ui: { IndexPatternSelect: jest.fn(), + SearchBar: jest.fn(), }, indexPatterns: {} as IndexPatternsContract, }; diff --git a/src/plugins/data/public/plugin.ts b/src/plugins/data/public/plugin.ts index 2a37be7f3f46a..cd55048ca527f 100644 --- a/src/plugins/data/public/plugin.ts +++ b/src/plugins/data/public/plugin.ts @@ -18,7 +18,7 @@ */ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public'; -import { Storage } from '../../kibana_utils/public'; +import { Storage, IStorageWrapper } from '../../kibana_utils/public'; import { DataPublicPluginSetup, DataPublicPluginStart, @@ -35,24 +35,26 @@ import { IndexPatterns } from './index_patterns'; import { setNotifications, setFieldFormats, setOverlays, setIndexPatterns } from './services'; import { createFilterAction, GLOBAL_APPLY_FILTER_ACTION } from './actions'; import { APPLY_FILTER_TRIGGER } from '../../embeddable/public'; +import { createSearchBar } from './ui/search_bar/create_search_bar'; export class DataPublicPlugin implements Plugin { private readonly autocomplete = new AutocompleteProviderRegister(); private readonly searchService: SearchService; private readonly fieldFormatsService: FieldFormatsService; private readonly queryService: QueryService; + private readonly storage: IStorageWrapper; constructor(initializerContext: PluginInitializerContext) { this.searchService = new SearchService(initializerContext); this.queryService = new QueryService(); this.fieldFormatsService = new FieldFormatsService(); + this.storage = new Storage(window.localStorage); } public setup(core: CoreSetup, { uiActions }: DataSetupDependencies): DataPublicPluginSetup { - const storage = new Storage(window.localStorage); const queryService = this.queryService.setup({ uiSettings: core.uiSettings, - storage, + storage: this.storage, }); uiActions.registerAction( @@ -79,16 +81,27 @@ export class DataPublicPlugin implements Plugin; + SearchBar: React.ComponentType; }; } diff --git a/src/plugins/data/public/ui/index.ts b/src/plugins/data/public/ui/index.ts index a0160f3f6f590..820416d99580e 100644 --- a/src/plugins/data/public/ui/index.ts +++ b/src/plugins/data/public/ui/index.ts @@ -21,7 +21,7 @@ export { SuggestionsComponent } from './typeahead/suggestions_component'; export { IndexPatternSelect } from './index_pattern_select'; export { FilterBar } from './filter_bar'; export { QueryStringInput } from './query_string_input/query_string_input'; -export { SearchBar, SearchBarOwnProps } from './search_bar'; +export { SearchBar, SearchBarOwnProps, SearchBarProps } from './search_bar'; // temp export - will be removed as final components are migrated to NP export { SavedQueryManagementComponent } from './saved_query_management'; diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx b/src/plugins/data/public/ui/search_bar/create_search_bar.tsx similarity index 85% rename from src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx rename to src/plugins/data/public/ui/search_bar/create_search_bar.tsx index d80ef1ab97643..dfafeb12f0d72 100644 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/create_search_bar.tsx +++ b/src/plugins/data/public/ui/search_bar/create_search_bar.tsx @@ -21,17 +21,14 @@ import React, { useState, useEffect } from 'react'; import { Subscription } from 'rxjs'; import { CoreStart } from 'src/core/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; -import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; -import { - DataPublicPluginStart, - SearchBarOwnProps, - SearchBar, - esFilters, -} from '../../../../../../../plugins/data/public'; +import { KibanaContextProvider } from '../../../../kibana_react/public'; +import { DataPublicPluginStart, esFilters } from '../..'; +import { SearchBarOwnProps, SearchBar } from '.'; +import { QueryStart } from '../../query'; interface StatefulSearchBarDeps { core: CoreStart; - data: DataPublicPluginStart; + data: Omit; storage: IStorageWrapper; } @@ -39,14 +36,14 @@ export type StatetfulSearchBarProps = SearchBarOwnProps & { appName: string; }; -const defaultFiltersUpdated = (data: DataPublicPluginStart) => { +const defaultFiltersUpdated = (query: QueryStart) => { return (filters: esFilters.Filter[]) => { - data.query.filterManager.setFilters(filters); + query.filterManager.setFilters(filters); }; }; -const defaultOnRefreshChange = (data: DataPublicPluginStart) => { - const { timefilter } = data.query.timefilter; +const defaultOnRefreshChange = (query: QueryStart) => { + const { timefilter } = query.timefilter; return (options: { isPaused: boolean; refreshInterval: number }) => { timefilter.setRefreshInterval({ value: options.refreshInterval, @@ -101,7 +98,7 @@ export function createSearchBar({ core, storage, data }: StatefulSearchBarDeps) isSubscribed = false; subscriptions.unsubscribe(); }; - }, []); + }, [filterManager, timefilter.timefilter]); return ( diff --git a/src/plugins/data/public/ui/search_bar/index.tsx b/src/plugins/data/public/ui/search_bar/index.tsx index 9c0ab5c406241..f1d27d1a91764 100644 --- a/src/plugins/data/public/ui/search_bar/index.tsx +++ b/src/plugins/data/public/ui/search_bar/index.tsx @@ -17,4 +17,4 @@ * under the License. */ -export { SearchBar, SearchBarOwnProps } from './search_bar'; +export { SearchBar, SearchBarOwnProps, SearchBarProps } from './search_bar'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js index 0086c5067ba12..2e4d0f31bf1db 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js @@ -22,10 +22,8 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { indexPatternService } from '../../../kibana_services'; -import { start as data } from '../../../../../../../../src/legacy/core_plugins/data/public/legacy'; -const { SearchBar } = data.ui; - import { npStart } from 'ui/new_platform'; +const { SearchBar } = npStart.plugins.data.ui; export class FilterEditor extends Component { state = { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js index fb09ed342b8d3..4fc1eba1f1e2f 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js @@ -13,8 +13,8 @@ import { EuiFormHelpText, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { SearchBar } from 'plugins/data'; import { npStart } from 'ui/new_platform'; +const { SearchBar } = npStart.plugins.data.ui; export class WhereExpression extends Component { diff --git a/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx index ce102d7ade53b..10b769e2a791c 100644 --- a/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx @@ -7,8 +7,7 @@ import { mount } from 'enzyme'; import React from 'react'; -import { SearchBar } from '../../../../../../../src/legacy/core_plugins/data/public'; -import { FilterManager } from '../../../../../../../src/plugins/data/public'; +import { FilterManager, SearchBar } from '../../../../../../../src/plugins/data/public'; import { uiSettingsServiceMock } from '../../../../../../../src/core/public/ui_settings/ui_settings_service.mock'; import { useKibanaCore } from '../../lib/compose/kibana_core'; import { TestProviders, mockIndexPattern } from '../../mock'; diff --git a/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx b/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx index bf440e238c2a3..9f706790bec67 100644 --- a/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/query_bar/index.tsx @@ -8,7 +8,6 @@ import { isEqual } from 'lodash/fp'; import React, { memo, useState, useEffect, useMemo, useCallback } from 'react'; import { IndexPattern } from 'ui/index_patterns'; -import { SavedQuery, SearchBar } from '../../../../../../../src/legacy/core_plugins/data/public'; import { esFilters, IIndexPattern, @@ -16,6 +15,8 @@ import { Query, TimeHistory, TimeRange, + SavedQuery, + SearchBar, SavedQueryTimeFilter, } from '../../../../../../../src/plugins/data/public'; import { Storage } from '../../../../../../../src/plugins/kibana_utils/public'; 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 fa9ff1e16ddb7..3d02cff7b72e8 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 @@ -16,7 +16,6 @@ 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'; import { InputsRange } from '../../store/inputs/model'; @@ -37,12 +36,9 @@ import { import { timelineActions, hostsActions, networkActions } from '../../store/actions'; import { TimeRange, Query, esFilters } from '../../../../../../../src/plugins/data/public'; -const { - ui: { SearchBar }, -} = data; - export const siemFilterManager = npStart.plugins.data.query.filterManager; export const savedQueryService = npStart.plugins.data.query.savedQueries; +const { SearchBar } = npStart.plugins.data.ui; interface SiemSearchBarRedux { end: number; From dad4dbea05b258487c3b55447b5f4a7b1c9e8427 Mon Sep 17 00:00:00 2001 From: Liza K Date: Tue, 10 Dec 2019 14:43:36 +0000 Subject: [PATCH 07/15] Clean up jest mocks --- .../public/top_nav_menu/top_nav_menu.test.tsx | 2 -- .../index_patterns/index_pattern.test.ts | 15 --------------- 2 files changed, 17 deletions(-) diff --git a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx b/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx index 9077de8910327..4e2ea44bf7642 100644 --- a/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx +++ b/src/legacy/core_plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx @@ -22,8 +22,6 @@ import { TopNavMenu } from './top_nav_menu'; import { TopNavMenuData } from './top_nav_menu_data'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -jest.mock('ui/new_platform'); - const mockTimeHistory = { add: () => {}, get: () => { diff --git a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.test.ts b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.test.ts index f56f94fa8c260..1f83e4bd5b80c 100644 --- a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.test.ts +++ b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.test.ts @@ -33,8 +33,6 @@ import { setNotifications, setFieldFormats } from '../../services'; import { notificationServiceMock } from '../../../../../core/public/notifications/notifications_service.mock'; import { FieldFormatRegisty } from '../../field_formats_provider'; -jest.mock('ui/new_platform'); - jest.mock('../../../../kibana_utils/public', () => { const originalModule = jest.requireActual('../../../../kibana_utils/public'); @@ -50,19 +48,6 @@ jest.mock('../../../../kibana_utils/public', () => { }; }); -jest.mock('ui/notify', () => ({ - toastNotifications: { - addDanger: jest.fn(), - addError: jest.fn(), - }, -})); - -jest.mock('ui/saved_objects', () => { - return { - findObjectByTitle: jest.fn(), - }; -}); - let mockFieldsFetcherResponse: any[] = []; jest.mock('./_fields_fetcher', () => ({ From 7746fae676697f5873a0ff1741ae89df809d698d Mon Sep 17 00:00:00 2001 From: Liza K Date: Tue, 10 Dec 2019 15:29:03 +0000 Subject: [PATCH 08/15] update snapshots --- .../__snapshots__/query_string_input.test.tsx.snap | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/data/public/ui/query_string_input/__snapshots__/query_string_input.test.tsx.snap b/src/plugins/data/public/ui/query_string_input/__snapshots__/query_string_input.test.tsx.snap index 80a5ede567054..4de883295bd8a 100644 --- a/src/plugins/data/public/ui/query_string_input/__snapshots__/query_string_input.test.tsx.snap +++ b/src/plugins/data/public/ui/query_string_input/__snapshots__/query_string_input.test.tsx.snap @@ -209,6 +209,7 @@ exports[`QueryStringInput Should disable autoFocus on EuiFieldText when disableA }, "ui": Object { "IndexPatternSelect": [MockFunction], + "SearchBar": [MockFunction], }, }, "docLinks": Object { @@ -829,6 +830,7 @@ exports[`QueryStringInput Should disable autoFocus on EuiFieldText when disableA }, "ui": Object { "IndexPatternSelect": [MockFunction], + "SearchBar": [MockFunction], }, }, "docLinks": Object { @@ -1437,6 +1439,7 @@ exports[`QueryStringInput Should pass the query language to the language switche }, "ui": Object { "IndexPatternSelect": [MockFunction], + "SearchBar": [MockFunction], }, }, "docLinks": Object { @@ -2054,6 +2057,7 @@ exports[`QueryStringInput Should pass the query language to the language switche }, "ui": Object { "IndexPatternSelect": [MockFunction], + "SearchBar": [MockFunction], }, }, "docLinks": Object { @@ -2662,6 +2666,7 @@ exports[`QueryStringInput Should render the given query 1`] = ` }, "ui": Object { "IndexPatternSelect": [MockFunction], + "SearchBar": [MockFunction], }, }, "docLinks": Object { @@ -3279,6 +3284,7 @@ exports[`QueryStringInput Should render the given query 1`] = ` }, "ui": Object { "IndexPatternSelect": [MockFunction], + "SearchBar": [MockFunction], }, }, "docLinks": Object { From da0418e75cb13c0ebaa223fe7f26a9483f72a475 Mon Sep 17 00:00:00 2001 From: Liza K Date: Wed, 11 Dec 2019 11:50:11 +0000 Subject: [PATCH 09/15] Remove indexPatterns angular service --- src/legacy/core_plugins/data/public/plugin.ts | 3 +- .../data/public/shim/legacy_module.ts | 29 ------------------- .../create_index_pattern_wizard/index.js | 4 +-- .../create_edit_field/create_edit_field.js | 4 ++- .../edit_index_pattern/edit_index_pattern.js | 6 ++-- .../management/sections/objects/_objects.js | 2 +- .../arg_value_suggestions.js | 8 ++--- .../ui/public/saved_objects/saved_object.js | 6 ++-- 8 files changed, 18 insertions(+), 44 deletions(-) delete mode 100644 src/legacy/core_plugins/data/public/shim/legacy_module.ts diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index 03e797fba069f..3f71cbbe068e4 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -19,7 +19,7 @@ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; -import { initLegacyModule } from './shim/legacy_module'; +// import { initLegacyModule } from './shim/legacy_module'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { setFieldFormats } from '../../../../plugins/data/public/services'; @@ -54,7 +54,6 @@ export class DataPlugin implements Plugin { - uiModules.get('kibana/index_patterns').value('indexPatterns', indexPatterns); -}); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js index 833ca8467292e..fd92987614283 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js @@ -20,7 +20,7 @@ import { SavedObjectsClientProvider } from 'ui/saved_objects'; import uiRoutes from 'ui/routes'; import angularTemplate from './angular_template.html'; -import 'ui/index_patterns'; +import { npStart } from 'ui/new_platform'; import { setup as managementSetup } from '../../../../../../management/public/legacy'; import { getCreateBreadcrumbs } from '../breadcrumbs'; @@ -41,7 +41,7 @@ uiRoutes.when('/management/kibana/index_pattern', { const services = { config: $injector.get('config'), es: $injector.get('es'), - indexPatterns: $injector.get('indexPatterns'), + indexPatterns: npStart.plugins.data.indexPatterns, $http: $injector.get('$http'), savedObjectsClient: Private(SavedObjectsClientProvider), indexPatternCreationType, diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.js index 5f0994abc11e4..f1c2d6598b134 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.js @@ -23,6 +23,7 @@ import { docTitle } from 'ui/doc_title'; import { KbnUrlProvider } from 'ui/url'; import uiRoutes from 'ui/routes'; import { toastNotifications } from 'ui/notify'; +import { npStart } from 'ui/new_platform'; import template from './create_edit_field.html'; import { getEditFieldBreadcrumbs, getCreateFieldBreadcrumbs } from '../../breadcrumbs'; @@ -96,7 +97,8 @@ uiRoutes }); }, resolve: { - indexPattern: function ($route, Promise, redirectWhenMissing, indexPatterns) { + indexPattern: function ($route, Promise, redirectWhenMissing) { + const { indexPatterns } = npStart.plugins.data; return Promise.resolve(indexPatterns.get($route.current.params.indexPatternId)) .catch(redirectWhenMissing('/management/kibana/index_patterns')); } diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js index 150fae6e87dde..c5ffa0826f10e 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js @@ -36,6 +36,7 @@ import { IndexedFieldsTable } from './indexed_fields_table'; import { ScriptedFieldsTable } from './scripted_fields_table'; import { i18n } from '@kbn/i18n'; import { I18nContext } from 'ui/i18n'; +import { npStart } from 'ui/new_platform'; import { getEditBreadcrumbs } from '../breadcrumbs'; @@ -168,7 +169,8 @@ uiRoutes.when('/management/kibana/index_patterns/:indexPatternId', { template, k7Breadcrumbs: getEditBreadcrumbs, resolve: { - indexPattern: function ($route, Promise, redirectWhenMissing, indexPatterns) { + indexPattern: function ($route, Promise, redirectWhenMissing) { + const { indexPatterns } = npStart.plugins.data; return Promise.resolve(indexPatterns.get($route.current.params.indexPatternId)).catch( redirectWhenMissing('/management/kibana/index_patterns') ); @@ -179,7 +181,7 @@ uiRoutes.when('/management/kibana/index_patterns/:indexPatternId', { uiModules .get('apps/management') .controller('managementIndexPatternsEdit', function ( - $scope, $location, $route, Promise, config, indexPatterns, Private, AppState, confirmModal) { + $scope, $location, $route, Promise, config, Private, AppState, confirmModal) { const $state = $scope.state = new AppState(); $scope.fieldWildcardMatcher = (...args) => fieldWildcardMatcher(...args, config.get('metaFields')); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/_objects.js b/src/legacy/core_plugins/kibana/public/management/sections/objects/_objects.js index 32cdce1bb4ac4..bd3aa20d097c9 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/objects/_objects.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/objects/_objects.js @@ -36,7 +36,7 @@ const REACT_OBJECTS_TABLE_DOM_ELEMENT_ID = 'reactSavedObjectsTable'; function updateObjectsTable($scope, $injector) { const Private = $injector.get('Private'); - const indexPatterns = $injector.get('indexPatterns'); + const indexPatterns = npStart.plugins.data.indexPatterns; const $http = $injector.get('$http'); const kbnUrl = $injector.get('kbnUrl'); const config = $injector.get('config'); diff --git a/src/legacy/core_plugins/timelion/public/directives/timelion_expression_suggestions/arg_value_suggestions.js b/src/legacy/core_plugins/timelion/public/directives/timelion_expression_suggestions/arg_value_suggestions.js index 81d459f70a5e1..dc3a5be40dff4 100644 --- a/src/legacy/core_plugins/timelion/public/directives/timelion_expression_suggestions/arg_value_suggestions.js +++ b/src/legacy/core_plugins/timelion/public/directives/timelion_expression_suggestions/arg_value_suggestions.js @@ -18,11 +18,11 @@ */ import _ from 'lodash'; -import { SavedObjectsClientProvider } from 'ui/saved_objects'; +import { npStart } from 'ui/new_platform'; -export function ArgValueSuggestionsProvider(Private, indexPatterns) { - - const savedObjectsClient = Private(SavedObjectsClientProvider); +export function ArgValueSuggestionsProvider() { + const { indexPatterns } = npStart.plugins.data; + const { client: savedObjectsClient } = npStart.core.savedObjects; async function getIndexPattern(functionArgs) { const indexPatternArg = functionArgs.find(argument => { diff --git a/src/legacy/ui/public/saved_objects/saved_object.js b/src/legacy/ui/public/saved_objects/saved_object.js index 1db651ad9308f..91479ad5fa5b1 100644 --- a/src/legacy/ui/public/saved_objects/saved_object.js +++ b/src/legacy/ui/public/saved_objects/saved_object.js @@ -36,7 +36,6 @@ import { InvalidJSONProperty, SavedObjectNotFound, expandShorthand } from '../.. import { SearchSource } from '../courier'; import { findObjectByTitle } from './find_object_by_title'; -import { SavedObjectsClientProvider } from './saved_objects_client_provider'; import { migrateLegacyQuery } from '../utils/migrate_legacy_query'; import { npStart } from 'ui/new_platform'; import { i18n } from '@kbn/i18n'; @@ -66,8 +65,9 @@ function isErrorNonFatal(error) { return error.message === OVERWRITE_REJECTED || error.message === SAVE_DUPLICATE_REJECTED; } -export function SavedObjectProvider(Promise, Private, confirmModalPromise, indexPatterns) { - const savedObjectsClient = Private(SavedObjectsClientProvider); +export function SavedObjectProvider(Promise, confirmModalPromise) { + const { indexPatterns } = npStart.plugins.data; + const { client: savedObjectsClient } = npStart.core.savedObjects; /** * The SavedObject class is a base class for saved objects loaded from the server and From 70f9748d1b28ebe8d16b19e7e980ad271338df7c Mon Sep 17 00:00:00 2001 From: Liza K Date: Wed, 11 Dec 2019 11:53:59 +0000 Subject: [PATCH 10/15] Deleted comment --- src/legacy/core_plugins/data/public/plugin.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index 3f71cbbe068e4..676904faf6f2f 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -19,7 +19,6 @@ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; -// import { initLegacyModule } from './shim/legacy_module'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { setFieldFormats } from '../../../../plugins/data/public/services'; From da63c3c1122d7cbed2b5ae0ba54f151ee22eee71 Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 12 Dec 2019 10:05:27 +0000 Subject: [PATCH 11/15] Mock npStart.core.savedObjects --- .../new_platform/new_platform.karma_mock.js | 2 ++ .../saved_objects/__tests__/saved_object.js | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) 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 f8850d1691cdd..6a1ee9663e805 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 @@ -153,8 +153,10 @@ export const npStart = { getProvider: sinon.fake(), }, getSuggestions: sinon.fake(), + indexPatterns: sinon.fake(), ui: { IndexPatternSelect: mockComponent, + SearchBar: mockComponent, }, query: { filterManager: { diff --git a/src/legacy/ui/public/saved_objects/__tests__/saved_object.js b/src/legacy/ui/public/saved_objects/__tests__/saved_object.js index 56124a047ba6d..dc040dfba01e0 100644 --- a/src/legacy/ui/public/saved_objects/__tests__/saved_object.js +++ b/src/legacy/ui/public/saved_objects/__tests__/saved_object.js @@ -24,7 +24,7 @@ import Bluebird from 'bluebird'; import { SavedObjectProvider } from '../saved_object'; import StubIndexPattern from 'test_utils/stub_index_pattern'; -import { SavedObjectsClientProvider } from '../saved_objects_client_provider'; +import { npStart } from 'ui/new_platform'; import { InvalidJSONProperty } from '../../../../../plugins/kibana_utils/public'; import { mockUiSettings } from '../../new_platform/new_platform.karma_mock'; @@ -82,6 +82,10 @@ describe('Saved Object', function () { return savedObject.init(); } + function restoreIfWrapped(obj, fName) { + obj[fName].restore && obj[fName].restore(); + } + const mock409FetchError = { res: { status: 409 } }; @@ -99,10 +103,18 @@ describe('Saved Object', function () { beforeEach(ngMock.inject(function (es, Private, $window) { SavedObject = Private(SavedObjectProvider); esDataStub = es; - savedObjectsClientStub = Private(SavedObjectsClientProvider); + savedObjectsClientStub = npStart.core.savedObjects.client; window = $window; })); + afterEach(ngMock.inject(function () { + restoreIfWrapped(savedObjectsClientStub, 'create'); + restoreIfWrapped(savedObjectsClientStub, 'get'); + restoreIfWrapped(savedObjectsClientStub, 'update'); + restoreIfWrapped(savedObjectsClientStub, 'find'); + restoreIfWrapped(savedObjectsClientStub, 'bulkGet'); + })); + describe('save', function () { describe('with confirmOverwrite', function () { function stubConfirmOverwrite() { From 79eb18438fc67ae567468ae4d9646aecf78154f9 Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 12 Dec 2019 10:17:31 +0000 Subject: [PATCH 12/15] Removed export of SearchBarOwnProps --- src/plugins/data/public/ui/index.ts | 2 +- src/plugins/data/public/ui/search_bar/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/data/public/ui/index.ts b/src/plugins/data/public/ui/index.ts index 820416d99580e..cd4ec3c3bf74b 100644 --- a/src/plugins/data/public/ui/index.ts +++ b/src/plugins/data/public/ui/index.ts @@ -21,7 +21,7 @@ export { SuggestionsComponent } from './typeahead/suggestions_component'; export { IndexPatternSelect } from './index_pattern_select'; export { FilterBar } from './filter_bar'; export { QueryStringInput } from './query_string_input/query_string_input'; -export { SearchBar, SearchBarOwnProps, SearchBarProps } from './search_bar'; +export { SearchBar, SearchBarProps } from './search_bar'; // temp export - will be removed as final components are migrated to NP export { SavedQueryManagementComponent } from './saved_query_management'; diff --git a/src/plugins/data/public/ui/search_bar/index.tsx b/src/plugins/data/public/ui/search_bar/index.tsx index f1d27d1a91764..4aa7f5fe2b040 100644 --- a/src/plugins/data/public/ui/search_bar/index.tsx +++ b/src/plugins/data/public/ui/search_bar/index.tsx @@ -17,4 +17,4 @@ * under the License. */ -export { SearchBar, SearchBarOwnProps, SearchBarProps } from './search_bar'; +export { SearchBar, SearchBarProps } from './search_bar'; From feca2c2422a5ebbd50beffff2ea8d415440c40d6 Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 12 Dec 2019 10:40:00 +0000 Subject: [PATCH 13/15] fix import --- src/plugins/data/public/ui/search_bar/create_search_bar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data/public/ui/search_bar/create_search_bar.tsx b/src/plugins/data/public/ui/search_bar/create_search_bar.tsx index dfafeb12f0d72..7dbf7eb588f0f 100644 --- a/src/plugins/data/public/ui/search_bar/create_search_bar.tsx +++ b/src/plugins/data/public/ui/search_bar/create_search_bar.tsx @@ -23,8 +23,8 @@ import { CoreStart } from 'src/core/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { KibanaContextProvider } from '../../../../kibana_react/public'; import { DataPublicPluginStart, esFilters } from '../..'; -import { SearchBarOwnProps, SearchBar } from '.'; import { QueryStart } from '../../query'; +import { SearchBarOwnProps, SearchBar } from './search_bar'; interface StatefulSearchBarDeps { core: CoreStart; From 4740eaea070f611404637cc44df4336feada9906 Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 12 Dec 2019 13:21:54 +0000 Subject: [PATCH 14/15] Fix typo --- src/plugins/data/public/types.ts | 4 ++-- src/plugins/data/public/ui/search_bar/create_search_bar.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/data/public/types.ts b/src/plugins/data/public/types.ts index b4e4ce6aaccd9..4fd8bdbaae7b8 100644 --- a/src/plugins/data/public/types.ts +++ b/src/plugins/data/public/types.ts @@ -27,7 +27,7 @@ import { IGetSuggestions } from './suggestions_provider/types'; import { QuerySetup, QueryStart } from './query'; import { IndexPatternSelectProps } from './ui/index_pattern_select'; import { IndexPatternsContract } from './index_patterns'; -import { StatetfulSearchBarProps } from './ui/search_bar/create_search_bar'; +import { StatefulSearchBarProps } from './ui/search_bar/create_search_bar'; export interface DataSetupDependencies { uiActions: IUiActionsSetup; @@ -53,7 +53,7 @@ export interface DataPublicPluginStart { query: QueryStart; ui: { IndexPatternSelect: React.ComponentType; - SearchBar: React.ComponentType; + SearchBar: React.ComponentType; }; } diff --git a/src/plugins/data/public/ui/search_bar/create_search_bar.tsx b/src/plugins/data/public/ui/search_bar/create_search_bar.tsx index 7dbf7eb588f0f..6f1be2825dd01 100644 --- a/src/plugins/data/public/ui/search_bar/create_search_bar.tsx +++ b/src/plugins/data/public/ui/search_bar/create_search_bar.tsx @@ -32,7 +32,7 @@ interface StatefulSearchBarDeps { storage: IStorageWrapper; } -export type StatetfulSearchBarProps = SearchBarOwnProps & { +export type StatefulSearchBarProps = SearchBarOwnProps & { appName: string; }; @@ -55,7 +55,7 @@ const defaultOnRefreshChange = (query: QueryStart) => { export function createSearchBar({ core, storage, 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) => { + return (props: StatefulSearchBarProps) => { const { filterManager, timefilter } = data.query; const tfRefreshInterval = timefilter.timefilter.getRefreshInterval(); const fmFilters = filterManager.getFilters(); From d43e519351a7f29380c9a829f08fbd0a0c89d81c Mon Sep 17 00:00:00 2001 From: Liza K Date: Fri, 13 Dec 2019 10:45:49 +0000 Subject: [PATCH 15/15] eslint --- .../ui/public/saved_objects/__tests__/saved_object.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/legacy/ui/public/saved_objects/__tests__/saved_object.js b/src/legacy/ui/public/saved_objects/__tests__/saved_object.js index 730e3e06b1894..720fc63fb89e7 100644 --- a/src/legacy/ui/public/saved_objects/__tests__/saved_object.js +++ b/src/legacy/ui/public/saved_objects/__tests__/saved_object.js @@ -100,10 +100,10 @@ describe('Saved Object', function () { }) ); - beforeEach(ngMock.inject(function (es, Private, $window) { - SavedObject = Private(SavedObjectProvider); - esDataStub = es; + beforeEach(ngMock.inject(function (es, $window) { savedObjectsClientStub = npStart.core.savedObjects.client; + SavedObject = createSavedObjectClass({ savedObjectsClient: savedObjectsClientStub }); + esDataStub = es; window = $window; }));