From 54d4fd6fa748095b8724191a004b0d3be1b82f84 Mon Sep 17 00:00:00 2001 From: Liza K Date: Sun, 27 Oct 2019 13:53:20 +0200 Subject: [PATCH 1/6] Move storage to kibana_utils --- src/legacy/core_plugins/data/public/types.ts | 7 ---- src/legacy/ui/public/storage/directive.js | 2 +- src/legacy/ui/public/storage/index.ts | 2 -- src/plugins/kibana_utils/public/index.ts | 1 + .../public/storage/__tests__/storage.js | 0 .../kibana_utils/public/storage/index.ts} | 3 +- .../kibana_utils}/public/storage/storage.ts | 12 +++---- .../kibana_utils/public/storage/types.ts | 32 +++++++++++++++++++ 8 files changed, 41 insertions(+), 18 deletions(-) rename src/{legacy/ui => plugins/kibana_utils}/public/storage/__tests__/storage.js (100%) rename src/{legacy/ui/public/storage/web_storage.ts => plugins/kibana_utils/public/storage/index.ts} (91%) rename src/{legacy/ui => plugins/kibana_utils}/public/storage/storage.ts (88%) create mode 100644 src/plugins/kibana_utils/public/storage/types.ts diff --git a/src/legacy/core_plugins/data/public/types.ts b/src/legacy/core_plugins/data/public/types.ts index 2c02a9b764755..d99d5d3310274 100644 --- a/src/legacy/core_plugins/data/public/types.ts +++ b/src/legacy/core_plugins/data/public/types.ts @@ -20,13 +20,6 @@ import { UiSettingsClientContract, CoreStart } from 'src/core/public'; import { DataPublicPluginStart } from 'src/plugins/data/public'; -export interface Storage { - get: (key: string) => any; - set: (key: string, value: any) => void; - remove: (key: string) => any; - clear: () => void; -} - export interface IDataPluginServices extends Partial { appName: string; uiSettings: UiSettingsClientContract; diff --git a/src/legacy/ui/public/storage/directive.js b/src/legacy/ui/public/storage/directive.js index a5bb2ee3b6b0b..38fff521d1a8f 100644 --- a/src/legacy/ui/public/storage/directive.js +++ b/src/legacy/ui/public/storage/directive.js @@ -19,7 +19,7 @@ import { uiModules } from '../modules'; -import { Storage } from './storage'; +import { Storage } from '../../../../plugins/kibana_utils/public'; const createService = function (type) { return function ($window) { diff --git a/src/legacy/ui/public/storage/index.ts b/src/legacy/ui/public/storage/index.ts index 17bbb61b2b8d5..b8fdf06729640 100644 --- a/src/legacy/ui/public/storage/index.ts +++ b/src/legacy/ui/public/storage/index.ts @@ -18,5 +18,3 @@ */ import './directive'; - -export { Storage } from './storage'; diff --git a/src/plugins/kibana_utils/public/index.ts b/src/plugins/kibana_utils/public/index.ts index bac0ef629789a..46f763bbdde81 100644 --- a/src/plugins/kibana_utils/public/index.ts +++ b/src/plugins/kibana_utils/public/index.ts @@ -22,3 +22,4 @@ export * from './parse'; export * from './render_complete'; export * from './errors'; export * from './field_mapping'; +export * from './storage'; diff --git a/src/legacy/ui/public/storage/__tests__/storage.js b/src/plugins/kibana_utils/public/storage/__tests__/storage.js similarity index 100% rename from src/legacy/ui/public/storage/__tests__/storage.js rename to src/plugins/kibana_utils/public/storage/__tests__/storage.js diff --git a/src/legacy/ui/public/storage/web_storage.ts b/src/plugins/kibana_utils/public/storage/index.ts similarity index 91% rename from src/legacy/ui/public/storage/web_storage.ts rename to src/plugins/kibana_utils/public/storage/index.ts index d5f775431143d..fa7c0fb7ba985 100644 --- a/src/legacy/ui/public/storage/web_storage.ts +++ b/src/plugins/kibana_utils/public/storage/index.ts @@ -17,4 +17,5 @@ * under the License. */ -export type WebStorage = Storage; +export { Storage } from './storage'; +export { IStorage } from './types'; diff --git a/src/legacy/ui/public/storage/storage.ts b/src/plugins/kibana_utils/public/storage/storage.ts similarity index 88% rename from src/legacy/ui/public/storage/storage.ts rename to src/plugins/kibana_utils/public/storage/storage.ts index 703886c1e034c..56e9ef7537e87 100644 --- a/src/legacy/ui/public/storage/storage.ts +++ b/src/plugins/kibana_utils/public/storage/storage.ts @@ -17,17 +17,15 @@ * under the License. */ -import angular from 'angular'; - // This is really silly, but I wasn't prepared to rename the kibana Storage class everywhere it is used // and this is the only way I could figure out how to use the type definition for a built in object // in a file that creates a type with the same name as that built in object. -import { WebStorage } from './web_storage'; +import { IStorage, IStorageWrapper } from './types'; -export class Storage { - public store: WebStorage; +export class Storage implements IStorageWrapper { + public store: IStorage; - constructor(store: WebStorage) { + constructor(store: IStorage) { this.store = store; } @@ -50,7 +48,7 @@ export class Storage { public set = (key: string, value: any) => { try { - return this.store.setItem(key, angular.toJson(value)); + return this.store.setItem(key, JSON.stringify(value)); } catch (e) { return false; } diff --git a/src/plugins/kibana_utils/public/storage/types.ts b/src/plugins/kibana_utils/public/storage/types.ts new file mode 100644 index 0000000000000..875bb44bcad17 --- /dev/null +++ b/src/plugins/kibana_utils/public/storage/types.ts @@ -0,0 +1,32 @@ +/* + * 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 interface IStorageWrapper { + get: (key: string) => any; + set: (key: string, value: any) => void; + remove: (key: string) => any; + clear: () => void; +} + +export interface IStorage { + getItem: (key: string) => any; + setItem: (key: string, value: any) => void; + removeItem: (key: string) => any; + clear: () => void; +} From 99a2362fb0ab22afd51dc4a209ab6ca7d95889c9 Mon Sep 17 00:00:00 2001 From: Liza K Date: Sun, 27 Oct 2019 16:04:15 +0200 Subject: [PATCH 2/6] Updated all references to Storage and replace places where it was referenced to as "store" to avoid confusion. --- src/legacy/core_plugins/data/public/plugin.ts | 4 ++-- .../query/persisted_log/persisted_log.ts | 6 +++--- .../components/query_bar_input.test.tsx | 6 +++--- .../query_bar/components/query_bar_input.tsx | 6 +++--- .../components/query_bar_top_row.test.tsx | 4 ++-- .../components/query_bar_top_row.tsx | 12 +++++------ .../query/query_bar/lib/get_query_log.ts | 6 +++--- .../components/create_search_bar.tsx | 8 ++++---- .../search_bar/components/search_bar.test.tsx | 4 ++-- .../public/shim/legacy_dependencies_plugin.ts | 6 +++--- .../data/public/timefilter/time_history.ts | 6 +++--- .../public/timefilter/timefilter_service.ts | 8 ++++---- src/legacy/core_plugins/data/public/types.ts | 2 +- .../public/discover/angular/discover.js | 1 + .../kibana/public/visualize/editor/editor.js | 1 + .../public/components/vis_editor.js | 9 +++++---- .../contexts/query_input_bar_context.ts | 4 ++-- .../ui/public/agg_types/buckets/filters.ts | 2 +- src/legacy/ui/public/autoload/modules.js | 1 - src/legacy/ui/public/chrome/chrome.js | 2 +- .../storage/index.js} | 4 ++-- src/legacy/ui/public/storage/index.ts | 20 ------------------- .../vis/editors/default/controls/filter.tsx | 4 ++-- .../kibana_utils/public/storage/index.ts | 2 +- .../plugins/canvas/public/lib/clipboard.js | 2 +- .../graph/public/angular/templates/index.html | 2 +- x-pack/legacy/plugins/graph/public/app.js | 6 +++--- .../plugins/graph/public/components/app.tsx | 8 ++++---- .../public/components/search_bar.test.tsx | 2 +- .../lens/public/app_plugin/app.test.tsx | 8 ++++---- .../plugins/lens/public/app_plugin/app.tsx | 12 +++++------ .../plugins/lens/public/app_plugin/plugin.tsx | 4 ++-- .../dimension_panel/dimension_panel.tsx | 4 ++-- .../indexpattern_plugin/indexpattern.tsx | 6 +++--- .../operations/definitions/index.ts | 4 ++-- .../public/indexpattern_plugin/plugin.tsx | 2 +- .../maps/public/angular/map_controller.js | 1 + .../connected_components/layer_panel/view.js | 4 ++-- .../metricbeat_migration/flyout/flyout.js | 2 +- .../plugins/monitoring/public/monitoring.js | 1 + 40 files changed, 90 insertions(+), 106 deletions(-) rename src/legacy/ui/public/{storage/directive.js => directives/storage/index.js} (90%) delete mode 100644 src/legacy/ui/public/storage/index.ts diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index c25d6742db8da..8ee2b46b1e201 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -99,7 +99,7 @@ export class DataPlugin const timefilterService = this.timefilter.setup({ uiSettings, - store: __LEGACY.storage, + storage: __LEGACY.storage, }); const filterService = this.filter.setup({ uiSettings, @@ -127,7 +127,7 @@ export class DataPlugin const SearchBar = createSearchBar({ core, data, - store: __LEGACY.storage, + storage: __LEGACY.storage, timefilter: this.setupApi.timefilter, filterManager: this.setupApi.filter.filterManager, }); diff --git a/src/legacy/core_plugins/data/public/query/persisted_log/persisted_log.ts b/src/legacy/core_plugins/data/public/query/persisted_log/persisted_log.ts index e0e6a0d0c44e4..082d923d2bef4 100644 --- a/src/legacy/core_plugins/data/public/query/persisted_log/persisted_log.ts +++ b/src/legacy/core_plugins/data/public/query/persisted_log/persisted_log.ts @@ -20,7 +20,7 @@ import _ from 'lodash'; import * as Rx from 'rxjs'; import { map } from 'rxjs/operators'; -import { Storage } from '../../types'; +import { IStorageWrapper } from '../../../../../../plugins/kibana_utils/public'; const defaultIsDuplicate = (oldItem: any, newItem: any) => { return _.isEqual(oldItem, newItem); @@ -37,12 +37,12 @@ export class PersistedLog { public maxLength?: number; public filterDuplicates?: boolean; public isDuplicate: (oldItem: T, newItem: T) => boolean; - public storage: Storage; + public storage: IStorageWrapper; public items: T[]; private update$ = new Rx.BehaviorSubject(undefined); - constructor(name: string, options: PersistedLogOptions = {}, storage: Storage) { + constructor(name: string, options: PersistedLogOptions = {}, storage: IStorageWrapper) { this.name = name; this.maxLength = typeof options.maxLength === 'string' diff --git a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.test.tsx b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.test.tsx index f1249da997dfe..3edb689ca2bfe 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.test.tsx +++ b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.test.tsx @@ -58,7 +58,7 @@ const createMockWebStorage = () => ({ }); const createMockStorage = () => ({ - store: createMockWebStorage(), + storage: createMockWebStorage(), get: jest.fn(), set: jest.fn(), remove: jest.fn(), @@ -80,7 +80,7 @@ const mockIndexPattern = { ], } as IndexPattern; -function wrapQueryBarInputInContext(testProps: any, store?: any) { +function wrapQueryBarInputInContext(testProps: any, storage?: any) { const defaultOptions = { screenTitle: 'Another Screen', intl: null as any, @@ -89,7 +89,7 @@ function wrapQueryBarInputInContext(testProps: any, store?: any) { const services = { ...startMock, appName: testProps.appName || 'test', - store: store || createMockStorage(), + storage: storage || createMockStorage(), }; return ( diff --git a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.tsx b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.tsx index a57018b118185..d73e741b6d5cb 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.tsx +++ b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.tsx @@ -365,7 +365,7 @@ export class QueryBarInputUI extends Component { body: JSON.stringify({ opt_in: language === 'kuery' }), }); - this.services.store.set('kibana.userQueryLanguage', language); + this.services.storage.set('kibana.userQueryLanguage', language); const newQuery = { query: '', language }; this.onChange(newQuery); @@ -387,10 +387,10 @@ export class QueryBarInputUI extends Component { }; private initPersistedLog = () => { - const { uiSettings, store, appName } = this.services; + const { uiSettings, storage, appName } = this.services; this.persistedLog = this.props.persistedLog ? this.props.persistedLog - : getQueryLog(uiSettings, store, appName, this.props.query.language); + : getQueryLog(uiSettings, storage, appName, this.props.query.language); }; public onMouseEnterSuggestion = (index: number) => { diff --git a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.test.tsx b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.test.tsx index 7ab191062e32d..7281eea956fbf 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.test.tsx +++ b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.test.tsx @@ -79,7 +79,7 @@ const createMockWebStorage = () => ({ }); const createMockStorage = () => ({ - store: createMockWebStorage(), + storage: createMockWebStorage(), get: jest.fn(), set: jest.fn(), remove: jest.fn(), @@ -112,7 +112,7 @@ function wrapQueryBarTopRowInContext(testProps: any) { const services = { ...startMock, appName: 'discover', - store: createMockStorage(), + storage: createMockStorage(), }; return ( diff --git a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.tsx b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.tsx index 9a846ab82f47c..26ee2d80ebf65 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.tsx +++ b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.tsx @@ -73,7 +73,7 @@ function QueryBarTopRowUI(props: Props) { const [isDateRangeInvalid, setIsDateRangeInvalid] = useState(false); const kibana = useKibana(); - const { uiSettings, notifications, store, appName, docLinks } = kibana.services; + const { uiSettings, notifications, storage, appName, docLinks } = kibana.services; const kueryQuerySyntaxLink: string = docLinks!.links.query.kueryQuerySyntax; @@ -82,7 +82,7 @@ function QueryBarTopRowUI(props: Props) { useEffect(() => { if (!props.query) return; - persistedLog = getQueryLog(uiSettings!, store, appName, props.query.language); + persistedLog = getQueryLog(uiSettings!, storage, appName, props.query.language); }, [queryLanguage]); function onClickSubmitButton(event: React.MouseEvent) { @@ -211,7 +211,7 @@ function QueryBarTopRowUI(props: Props) { } function shouldRenderQueryInput(): boolean { - return Boolean(props.showQueryInput && props.indexPatterns && props.query && store); + return Boolean(props.showQueryInput && props.indexPatterns && props.query && storage); } function renderUpdateButton() { @@ -293,7 +293,7 @@ function QueryBarTopRowUI(props: Props) { if ( language === 'kuery' && typeof query === 'string' && - (!store || !store.get('kibana.luceneSyntaxWarningOptOut')) && + (!storage || !storage.get('kibana.luceneSyntaxWarningOptOut')) && doesKueryExpressionHaveLuceneSyntaxError(query) ) { const toast = notifications!.toasts.addWarning({ @@ -337,8 +337,8 @@ function QueryBarTopRowUI(props: Props) { } function onLuceneSyntaxWarningOptOut(toast: Toast) { - if (!store) return; - store.set('kibana.luceneSyntaxWarningOptOut', true); + if (!storage) return; + storage.set('kibana.luceneSyntaxWarningOptOut', true); notifications!.toasts.remove(toast); } diff --git a/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts b/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts index 8b26e14c6ed7b..7dc05da63b655 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts +++ b/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts @@ -19,11 +19,11 @@ import { UiSettingsClientContract } from 'src/core/public'; import { PersistedLog } from '../../persisted_log'; -import { Storage } from '../../../types'; +import { IStorageWrapper } from '../../../../../../../plugins/kibana_utils/public'; export function getQueryLog( uiSettings: UiSettingsClientContract, - store: Storage, + storage: IStorageWrapper, appName: string, language: string ) { @@ -33,6 +33,6 @@ export function getQueryLog( maxLength: uiSettings.get('history:limit'), filterDuplicates: true, }, - store + storage ); } 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 d801f8a69e2d6..fa3ec1d412750 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,7 +22,7 @@ import { Subscription } from 'rxjs'; import { Filter } from '@kbn/es-query'; import { CoreStart } from 'src/core/public'; import { DataPublicPluginStart } from 'src/plugins/data/public'; -import { Storage } from '../../../types'; +import { IStorageWrapper } from '../../../../../../../plugins/kibana_utils/public'; import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; import { TimefilterSetup } from '../../../timefilter'; import { FilterManager, SearchBar } from '../../../'; @@ -31,7 +31,7 @@ import { SearchBarOwnProps } from '.'; interface StatefulSearchBarDeps { core: CoreStart; data: DataPublicPluginStart; - store: Storage; + storage: IStorageWrapper; timefilter: TimefilterSetup; filterManager: FilterManager; } @@ -57,7 +57,7 @@ const defaultOnRefreshChange = (timefilter: TimefilterSetup) => { export function createSearchBar({ core, - store, + storage, timefilter, filterManager, data, @@ -113,7 +113,7 @@ export function createSearchBar({ services={{ appName: props.appName, data, - store, + storage, ...core, }} > diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.test.tsx b/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.test.tsx index 73e81a38572c3..62b60fa262cb8 100644 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.test.tsx +++ b/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.test.tsx @@ -56,7 +56,7 @@ const createMockWebStorage = () => ({ }); const createMockStorage = () => ({ - store: createMockWebStorage(), + storage: createMockWebStorage(), get: jest.fn(), set: jest.fn(), remove: jest.fn(), @@ -95,7 +95,7 @@ function wrapSearchBarInContext(testProps: any) { savedObjects: startMock.savedObjects, notifications: startMock.notifications, http: startMock.http, - store: createMockStorage(), + storage: createMockStorage(), }; return ( diff --git a/src/legacy/core_plugins/data/public/shim/legacy_dependencies_plugin.ts b/src/legacy/core_plugins/data/public/shim/legacy_dependencies_plugin.ts index 5b12d56dc7b00..14eb6a4b364eb 100644 --- a/src/legacy/core_plugins/data/public/shim/legacy_dependencies_plugin.ts +++ b/src/legacy/core_plugins/data/public/shim/legacy_dependencies_plugin.ts @@ -17,17 +17,17 @@ * under the License. */ -import { Storage } from 'ui/storage'; +import { IStorageWrapper, Storage } from '../../../../../../src/plugins/kibana_utils/public'; import { Plugin } from '../../../../../../src/core/public'; import { initLegacyModule } from './legacy_module'; /** @internal */ export interface LegacyDependenciesPluginSetup { - storage: Storage; + storage: IStorageWrapper; } export interface LegacyDependenciesPluginStart { - storage: Storage; + storage: IStorageWrapper; } export class LegacyDependenciesPlugin implements Plugin { diff --git a/src/legacy/core_plugins/data/public/timefilter/time_history.ts b/src/legacy/core_plugins/data/public/timefilter/time_history.ts index 22778d1adea3c..cd2b57612441b 100644 --- a/src/legacy/core_plugins/data/public/timefilter/time_history.ts +++ b/src/legacy/core_plugins/data/public/timefilter/time_history.ts @@ -20,12 +20,12 @@ import moment from 'moment'; import { TimeRange } from 'src/plugins/data/public'; import { PersistedLog } from '../query/persisted_log'; -import { Storage } from '../types'; +import { IStorageWrapper } from '../../../../../plugins/kibana_utils/public'; export class TimeHistory { private history: PersistedLog; - constructor(store: Storage) { + constructor(storage: IStorageWrapper) { const historyOptions = { maxLength: 10, filterDuplicates: true, @@ -33,7 +33,7 @@ export class TimeHistory { return oldItem.from === newItem.from && oldItem.to === newItem.to; }, }; - this.history = new PersistedLog('kibana.timepicker.timeHistory', historyOptions, store); + this.history = new PersistedLog('kibana.timepicker.timeHistory', historyOptions, storage); } add(time: TimeRange) { diff --git a/src/legacy/core_plugins/data/public/timefilter/timefilter_service.ts b/src/legacy/core_plugins/data/public/timefilter/timefilter_service.ts index cda9b93ef08aa..17516c823e33f 100644 --- a/src/legacy/core_plugins/data/public/timefilter/timefilter_service.ts +++ b/src/legacy/core_plugins/data/public/timefilter/timefilter_service.ts @@ -19,7 +19,7 @@ import { UiSettingsClientContract } from 'src/core/public'; import { TimeHistory, Timefilter, TimeHistoryContract, TimefilterContract } from './index'; -import { Storage } from '../types'; +import { IStorageWrapper } from '../../../../../plugins/kibana_utils/public'; /** * Filter Service @@ -28,16 +28,16 @@ import { Storage } from '../types'; export interface TimeFilterServiceDependencies { uiSettings: UiSettingsClientContract; - store: Storage; + storage: IStorageWrapper; } export class TimefilterService { - public setup({ uiSettings, store }: TimeFilterServiceDependencies): TimefilterSetup { + public setup({ uiSettings, storage }: TimeFilterServiceDependencies): TimefilterSetup { const timefilterConfig = { timeDefaults: uiSettings.get('timepicker:timeDefaults'), refreshIntervalDefaults: uiSettings.get('timepicker:refreshIntervalDefaults'), }; - const history = new TimeHistory(store); + const history = new TimeHistory(storage); const timefilter = new Timefilter(timefilterConfig, history); return { diff --git a/src/legacy/core_plugins/data/public/types.ts b/src/legacy/core_plugins/data/public/types.ts index d99d5d3310274..7075c241da609 100644 --- a/src/legacy/core_plugins/data/public/types.ts +++ b/src/legacy/core_plugins/data/public/types.ts @@ -26,6 +26,6 @@ export interface IDataPluginServices extends Partial { savedObjects: CoreStart['savedObjects']; notifications: CoreStart['notifications']; http: CoreStart['http']; - store: Storage; + storage: Storage; data: DataPublicPluginStart; } diff --git a/src/legacy/core_plugins/kibana/public/discover/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/angular/discover.js index 840152fc40ced..4f2732ffd41b4 100644 --- a/src/legacy/core_plugins/kibana/public/discover/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/angular/discover.js @@ -34,6 +34,7 @@ import * as columnActions from '../doc_table/actions/columns'; import * as filterActions from '../doc_table/actions/filter'; import 'ui/directives/listen'; +import 'ui/directives/storage'; import 'ui/visualize'; import 'ui/fixed_scroll'; import 'ui/index_patterns'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js index dac0880e6fec4..45df227163fdb 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js @@ -25,6 +25,7 @@ import './visualization_editor'; import 'ui/vis/editors/default/sidebar'; import 'ui/visualize'; import 'ui/collapsible_sidebar'; +import 'ui/directives/storage'; import { capabilities } from 'ui/capabilities'; import chrome from 'ui/chrome'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js index 3497a35f5c99d..842d3aa6c4ad7 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/vis_editor.js @@ -32,10 +32,10 @@ import { fetchFields } from '../lib/fetch_fields'; import { extractIndexPatterns } from '../../common/extract_index_patterns'; import { npStart } from 'ui/new_platform'; -import { Storage } from 'ui/storage'; + import { CoreStartContextProvider } from '../contexts/query_input_bar_context'; import { KibanaContextProvider } from '../../../../../plugins/kibana_react/public'; -const localStorage = new Storage(window.localStorage); +import { Storage } from '../../../../../plugins/kibana_utils/public'; import { timefilter } from 'ui/timefilter'; const VIS_STATE_DEBOUNCE_DELAY = 200; @@ -46,6 +46,7 @@ export class VisEditor extends Component { super(props); const { vis } = props; this.appState = vis.API.getAppState(); + this.localStorage = new Storage(window.localStorage); this.state = { model: props.visParams, dirty: false, @@ -63,7 +64,7 @@ export class VisEditor extends Component { appName: APP_NAME, uiSettings: npStart.core.uiSettings, savedObjectsClient: npStart.core.savedObjects.client, - store: localStorage, + store: this.localStorage, }; } @@ -169,7 +170,7 @@ export class VisEditor extends Component { (null); diff --git a/src/legacy/ui/public/agg_types/buckets/filters.ts b/src/legacy/ui/public/agg_types/buckets/filters.ts index f0450f220f610..44a97abb7a1d7 100644 --- a/src/legacy/ui/public/agg_types/buckets/filters.ts +++ b/src/legacy/ui/public/agg_types/buckets/filters.ts @@ -21,7 +21,6 @@ import _ from 'lodash'; import angular from 'angular'; import { i18n } from '@kbn/i18n'; -import { Storage } from 'ui/storage'; import chrome from 'ui/chrome'; import { buildEsQuery } from '@kbn/es-query'; @@ -29,6 +28,7 @@ import { FiltersParamEditor, FilterValue } from '../../vis/editors/default/contr import { createFilterFilters } from './create_filter/filters'; import { BucketAggType, IBucketAggConfig } from './_bucket_agg_type'; import { setup as data } from '../../../../core_plugins/data/public/legacy'; +import { Storage } from '../../../../../plugins/kibana_utils/public'; const { getQueryLog } = data.query.helpers; const config = chrome.getUiSettingsClient(); diff --git a/src/legacy/ui/public/autoload/modules.js b/src/legacy/ui/public/autoload/modules.js index d662d479fc86b..e1d897236297e 100644 --- a/src/legacy/ui/public/autoload/modules.js +++ b/src/legacy/ui/public/autoload/modules.js @@ -27,7 +27,6 @@ import '../promises'; import '../modals'; import '../state_management/app_state'; import '../state_management/global_state'; -import '../storage'; import '../style_compile'; import '../url'; import '../directives/watch_multi'; diff --git a/src/legacy/ui/public/chrome/chrome.js b/src/legacy/ui/public/chrome/chrome.js index a5a0521013a6e..d644965e09225 100644 --- a/src/legacy/ui/public/chrome/chrome.js +++ b/src/legacy/ui/public/chrome/chrome.js @@ -26,7 +26,7 @@ import '../config'; import '../notify'; import '../private'; import '../promises'; -import '../storage'; +import '../directives/storage'; import '../directives/watch_multi'; import './services'; import '../react_components'; diff --git a/src/legacy/ui/public/storage/directive.js b/src/legacy/ui/public/directives/storage/index.js similarity index 90% rename from src/legacy/ui/public/storage/directive.js rename to src/legacy/ui/public/directives/storage/index.js index 38fff521d1a8f..8c18012672c1b 100644 --- a/src/legacy/ui/public/storage/directive.js +++ b/src/legacy/ui/public/directives/storage/index.js @@ -18,8 +18,8 @@ */ -import { uiModules } from '../modules'; -import { Storage } from '../../../../plugins/kibana_utils/public'; +import { uiModules } from '../../modules'; +import { Storage } from '../../../../../plugins/kibana_utils/public'; const createService = function (type) { return function ($window) { diff --git a/src/legacy/ui/public/storage/index.ts b/src/legacy/ui/public/storage/index.ts deleted file mode 100644 index b8fdf06729640..0000000000000 --- a/src/legacy/ui/public/storage/index.ts +++ /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. - */ - -import './directive'; diff --git a/src/legacy/ui/public/vis/editors/default/controls/filter.tsx b/src/legacy/ui/public/vis/editors/default/controls/filter.tsx index 2c0a2b6be37f8..4ebe7b0d835d7 100644 --- a/src/legacy/ui/public/vis/editors/default/controls/filter.tsx +++ b/src/legacy/ui/public/vis/editors/default/controls/filter.tsx @@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n'; import { Query, QueryBarInput } from 'plugins/data'; import { AggConfig } from '../../..'; import { npStart } from '../../../../new_platform'; -import { Storage } from '../../../../storage'; +import { Storage } from '../../../../../../../plugins/kibana_utils/public'; import { KibanaContextProvider } from '../../../../../../../plugins/kibana_react/public'; const localStorage = new Storage(window.localStorage); @@ -94,7 +94,7 @@ function FilterRow({ diff --git a/x-pack/legacy/plugins/graph/public/app.js b/x-pack/legacy/plugins/graph/public/app.js index e6bfc82f876c4..4ecd3d3811bd3 100644 --- a/x-pack/legacy/plugins/graph/public/app.js +++ b/x-pack/legacy/plugins/graph/public/app.js @@ -33,7 +33,7 @@ import { npStart } from 'ui/new_platform'; import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry'; import { capabilities } from 'ui/capabilities'; import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; -import { Storage } from 'ui/storage'; +import { Storage } from '../../../../../src/plugins/kibana_utils/public'; import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; @@ -98,7 +98,7 @@ app.directive('graphListing', function (reactDirective) { app.directive('graphApp', function (reactDirective) { return reactDirective(GraphApp, [ - ['store', { watchDepth: 'reference' }], + ['storage', { watchDepth: 'reference' }], ['isInitialized', { watchDepth: 'reference' }], ['currentIndexPattern', { watchDepth: 'reference' }], ['indexPatternProvider', { watchDepth: 'reference' }], @@ -322,7 +322,7 @@ app.controller('graphuiPlugin', function ( // register things on scope passed down to react components $scope.pluginDataStart = npStart.plugins.data; - $scope.store = new Storage(window.localStorage); + $scope.storage = new Storage(window.localStorage); $scope.coreStart = npStart.core; $scope.loading = false; $scope.reduxStore = store; diff --git a/x-pack/legacy/plugins/graph/public/components/app.tsx b/x-pack/legacy/plugins/graph/public/components/app.tsx index aa2221441793f..c14af75f3b057 100644 --- a/x-pack/legacy/plugins/graph/public/components/app.tsx +++ b/x-pack/legacy/plugins/graph/public/components/app.tsx @@ -10,20 +10,20 @@ import { DataPublicPluginStart } from 'src/plugins/data/public'; import { Provider } from 'react-redux'; import React, { useState } from 'react'; import { I18nProvider } from '@kbn/i18n/react'; -import { Storage } from 'ui/storage'; import { CoreStart } from 'kibana/public'; import { FieldManager } from './field_manager'; import { SearchBarProps, SearchBar } from './search_bar'; import { GraphStore } from '../state_management'; import { GuidancePanel } from './guidance_panel'; +import { IStorageWrapper } from '../../../../../../src/plugins/kibana_utils/public'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; export interface GraphAppProps extends SearchBarProps { coreStart: CoreStart; // This is not named dataStart because of Angular treating data- prefix differently pluginDataStart: DataPublicPluginStart; - store: Storage; + storage: IStorageWrapper; reduxStore: GraphStore; isInitialized: boolean; noIndexPatterns: boolean; @@ -34,7 +34,7 @@ export function GraphApp(props: GraphAppProps) { const { coreStart, pluginDataStart, - store, + storage, reduxStore, noIndexPatterns, ...searchBarProps @@ -45,7 +45,7 @@ export function GraphApp(props: GraphAppProps) { {}, }, }; diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx index 77d0d5a5305aa..35eb514f9b7b2 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx @@ -10,7 +10,7 @@ import { act } from 'react-dom/test-utils'; import { buildExistsFilter } from '@kbn/es-query'; import { App } from './app'; import { EditorFrameInstance } from '../types'; -import { Storage } from 'ui/storage'; +import { Storage } from '../../../../../../src/plugins/kibana_utils/public'; import { Document, SavedObjectStore } from '../persistence'; import { mount } from 'enzyme'; @@ -75,7 +75,7 @@ describe('Lens App', () => { data: typeof dataStartMock; core: typeof core; dataShim: DataStart; - store: Storage; + storage: Storage; docId?: string; docStorage: SavedObjectStore; redirectTo: (id?: string) => void; @@ -105,7 +105,7 @@ describe('Lens App', () => { filterManager: createMockFilterManager(), }, }, - store: { + storage: { get: jest.fn(), }, docStorage: { @@ -118,7 +118,7 @@ describe('Lens App', () => { data: typeof dataStartMock; core: typeof core; dataShim: DataStart; - store: Storage; + storage: Storage; docId?: string; docStorage: SavedObjectStore; redirectTo: (id?: string) => void; diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index 1152a3de77181..cd6bfb277f9ca 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx @@ -8,7 +8,6 @@ import _ from 'lodash'; import React, { useState, useEffect, useCallback } from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { Storage } from 'ui/storage'; import { DataPublicPluginStart } from 'src/plugins/data/public'; import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; import { CoreStart, NotificationsStart } from 'src/core/public'; @@ -22,6 +21,7 @@ import { import { Filter } from '@kbn/es-query'; import { TopNavMenu } from '../../../../../../src/legacy/core_plugins/kibana_react/public'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { IStorageWrapper } from '../../../../../../src/plugins/kibana_utils/public'; import { Document, SavedObjectStore } from '../persistence'; import { EditorFrameInstance } from '../types'; import { NativeRenderer } from '../native_renderer'; @@ -49,7 +49,7 @@ export function App({ data, dataShim, core, - store, + storage, docId, docStorage, redirectTo, @@ -58,14 +58,14 @@ export function App({ data: DataPublicPluginStart; core: CoreStart; dataShim: DataStart; - store: Storage; + storage: IStorageWrapper; docId?: string; docStorage: SavedObjectStore; redirectTo: (id?: string) => void; }) { const timeDefaults = core.uiSettings.get('timepicker:timeDefaults'); const language = - store.get('kibana.userQueryLanguage') || core.uiSettings.get('search:queryLanguage'); + storage.get('kibana.userQueryLanguage') || core.uiSettings.get('search:queryLanguage'); const [state, setState] = useState({ isLoading: !!docId, @@ -169,7 +169,7 @@ export function App({ services={{ appName: 'lens', data, - store, + storage, ...core, }} > @@ -248,7 +248,7 @@ export function App({ query: { query: '', language: - store.get('kibana.userQueryLanguage') || + storage.get('kibana.userQueryLanguage') || core.uiSettings.get('search:queryLanguage'), }, })); diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx index 1f8779bb68b81..78255b6c849d8 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx @@ -8,12 +8,12 @@ import React from 'react'; import { I18nProvider, FormattedMessage } from '@kbn/i18n/react'; import { HashRouter, Switch, Route, RouteComponentProps } from 'react-router-dom'; import chrome from 'ui/chrome'; -import { Storage } from 'ui/storage'; import { CoreSetup, CoreStart } from 'src/core/public'; import { npSetup, npStart } from 'ui/new_platform'; import { DataPublicPluginStart } from 'src/plugins/data/public'; import { DataStart } from '../../../../../../src/legacy/core_plugins/data/public'; import { start as dataShimStart } from '../../../../../../src/legacy/core_plugins/data/public/legacy'; +import { Storage } from '../../../../../../src/plugins/kibana_utils/public'; import { editorFrameSetup, editorFrameStart, editorFrameStop } from '../editor_frame_plugin'; import { indexPatternDatasourceSetup, indexPatternDatasourceStop } from '../indexpattern_plugin'; import { SavedObjectIndexStore } from '../persistence'; @@ -85,7 +85,7 @@ export class AppPlugin { data={data} dataShim={dataShim} editorFrame={this.instance!} - store={new Storage(localStorage)} + storage={new Storage(localStorage)} docId={routeProps.match.params.id} docStorage={store} redirectTo={id => { diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.tsx index c0c774a225642..3bba9425023a5 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.tsx @@ -7,13 +7,13 @@ import _ from 'lodash'; import React, { memo, useMemo } from 'react'; import { EuiButtonIcon } from '@elastic/eui'; -import { Storage } from 'ui/storage'; import { i18n } from '@kbn/i18n'; import { UiSettingsClientContract, SavedObjectsClientContract, HttpServiceBase, } from 'src/core/public'; +import { IStorageWrapper } from '../../../../../../../src/plugins/kibana_utils/public'; import { DatasourceDimensionPanelProps, StateSetter } from '../../types'; import { IndexPatternColumn, OperationType } from '../indexpattern'; import { getAvailableOperationsByMetadata, buildColumn, changeField } from '../operations'; @@ -29,7 +29,7 @@ export type IndexPatternDimensionPanelProps = DatasourceDimensionPanelProps & { setState: StateSetter; dragDropContext: DragContextState; uiSettings: UiSettingsClientContract; - storage: Storage; + storage: IStorageWrapper; savedObjectsClient: SavedObjectsClientContract; layerId: string; http: HttpServiceBase; diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx index 359eb687b5741..20837b6b82d45 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx @@ -9,8 +9,8 @@ import React from 'react'; import { render } from 'react-dom'; import { I18nProvider } from '@kbn/i18n/react'; import { CoreStart, SavedObjectsClientContract } from 'src/core/public'; -import { Storage } from 'ui/storage'; import { i18n } from '@kbn/i18n'; +import { IStorageWrapper } from '../../../../../../src/plugins/kibana_utils/public'; import { DatasourceDimensionPanelProps, DatasourceDataPanelProps, @@ -104,7 +104,7 @@ export function getIndexPatternDatasource({ // Core start is being required here because it contains the savedObject client // In the new platform, this plugin wouldn't be initialized until after setup core: CoreStart; - storage: Storage; + storage: IStorageWrapper; savedObjectsClient: SavedObjectsClientContract; data: ReturnType; }) { @@ -221,7 +221,7 @@ export function getIndexPatternDatasource({ { columnId: string; layerId: string; uiSettings: UiSettingsClientContract; - storage: Storage; + storage: IStorageWrapper; savedObjectsClient: SavedObjectsClientContract; http: HttpServiceBase; } diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/plugin.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/plugin.tsx index 9c4835437546e..4dde289259c41 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/plugin.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/plugin.tsx @@ -8,8 +8,8 @@ import { Registry } from '@kbn/interpreter/target/common'; import { CoreSetup } from 'src/core/public'; // The following dependencies on ui/* and src/legacy/core_plugins must be mocked when testing import chrome, { Chrome } from 'ui/chrome'; -import { Storage } from 'ui/storage'; import { npSetup, npStart } from 'ui/new_platform'; +import { Storage } from '../../../../../../src/plugins/kibana_utils/public'; import { ExpressionFunction } from '../../../../../../src/legacy/core_plugins/interpreter/public'; import { functionsRegistry } from '../../../../../../src/legacy/core_plugins/interpreter/public/registries'; import { getIndexPatternDatasource } from './indexpattern'; diff --git a/x-pack/legacy/plugins/maps/public/angular/map_controller.js b/x-pack/legacy/plugins/maps/public/angular/map_controller.js index d8f957bd38199..b7052bd83a568 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -7,6 +7,7 @@ import _ from 'lodash'; import chrome from 'ui/chrome'; import 'ui/directives/listen'; +import 'ui/directives/storage'; import React from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.js b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.js index 28afabc40bd75..78cb8aa827e35 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.js @@ -30,8 +30,8 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; +import { Storage } from '../../../../../../../src/plugins/kibana_utils/public'; -import { Storage } from 'ui/storage'; const localStorage = new Storage(window.localStorage); // This import will eventually become a dependency injected by the fully deangularized NP plugin. @@ -154,7 +154,7 @@ export class LayerPanel extends React.Component { Date: Sun, 27 Oct 2019 17:48:21 +0200 Subject: [PATCH 3/6] fixed tests --- .../public/query/persisted_log/persisted_log.ts | 2 +- .../public/query/query_bar/lib/get_query_log.ts | 2 +- .../search_bar/components/create_search_bar.tsx | 2 +- .../data/public/timefilter/time_history.ts | 2 +- .../data/public/timefilter/timefilter_service.ts | 2 +- src/legacy/core_plugins/data/public/types.ts | 3 ++- .../public/contexts/query_input_bar_context.ts | 2 +- x-pack/legacy/plugins/graph/public/app.js | 4 ++-- .../legacy/plugins/graph/public/components/app.tsx | 2 +- .../legacy/plugins/lens/public/app_plugin/app.tsx | 2 +- .../dimension_panel/dimension_panel.test.tsx | 4 ++-- .../dimension_panel/dimension_panel.tsx | 2 +- .../indexpattern_plugin/indexpattern.test.ts | 4 ++-- .../public/indexpattern_plugin/indexpattern.tsx | 2 +- .../operations/definitions/date_histogram.test.tsx | 14 +++++++------- .../operations/definitions/index.ts | 2 +- .../operations/definitions/terms.test.tsx | 14 +++++++------- .../lens/public/lens_ui_telemetry/factory.test.ts | 4 ++-- .../lens/public/lens_ui_telemetry/factory.ts | 6 +++--- .../layer_panel/__snapshots__/view.test.js.snap | 2 +- 20 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/legacy/core_plugins/data/public/query/persisted_log/persisted_log.ts b/src/legacy/core_plugins/data/public/query/persisted_log/persisted_log.ts index 082d923d2bef4..553b0bf5ef7e0 100644 --- a/src/legacy/core_plugins/data/public/query/persisted_log/persisted_log.ts +++ b/src/legacy/core_plugins/data/public/query/persisted_log/persisted_log.ts @@ -20,7 +20,7 @@ import _ from 'lodash'; import * as Rx from 'rxjs'; import { map } from 'rxjs/operators'; -import { IStorageWrapper } from '../../../../../../plugins/kibana_utils/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; const defaultIsDuplicate = (oldItem: any, newItem: any) => { return _.isEqual(oldItem, newItem); diff --git a/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts b/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts index 7dc05da63b655..f78eb5e07f189 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts +++ b/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts @@ -18,8 +18,8 @@ */ import { UiSettingsClientContract } from 'src/core/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { PersistedLog } from '../../persisted_log'; -import { IStorageWrapper } from '../../../../../../../plugins/kibana_utils/public'; export function getQueryLog( uiSettings: UiSettingsClientContract, 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 fa3ec1d412750..664f83c5874dd 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,7 +22,7 @@ import { Subscription } from 'rxjs'; import { Filter } from '@kbn/es-query'; import { CoreStart } from 'src/core/public'; import { DataPublicPluginStart } from 'src/plugins/data/public'; -import { IStorageWrapper } from '../../../../../../../plugins/kibana_utils/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; import { TimefilterSetup } from '../../../timefilter'; import { FilterManager, SearchBar } from '../../../'; diff --git a/src/legacy/core_plugins/data/public/timefilter/time_history.ts b/src/legacy/core_plugins/data/public/timefilter/time_history.ts index cd2b57612441b..36ad1a4427a47 100644 --- a/src/legacy/core_plugins/data/public/timefilter/time_history.ts +++ b/src/legacy/core_plugins/data/public/timefilter/time_history.ts @@ -19,8 +19,8 @@ import moment from 'moment'; import { TimeRange } from 'src/plugins/data/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { PersistedLog } from '../query/persisted_log'; -import { IStorageWrapper } from '../../../../../plugins/kibana_utils/public'; export class TimeHistory { private history: PersistedLog; diff --git a/src/legacy/core_plugins/data/public/timefilter/timefilter_service.ts b/src/legacy/core_plugins/data/public/timefilter/timefilter_service.ts index 17516c823e33f..831ccebedc9cc 100644 --- a/src/legacy/core_plugins/data/public/timefilter/timefilter_service.ts +++ b/src/legacy/core_plugins/data/public/timefilter/timefilter_service.ts @@ -18,8 +18,8 @@ */ import { UiSettingsClientContract } from 'src/core/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { TimeHistory, Timefilter, TimeHistoryContract, TimefilterContract } from './index'; -import { IStorageWrapper } from '../../../../../plugins/kibana_utils/public'; /** * Filter Service diff --git a/src/legacy/core_plugins/data/public/types.ts b/src/legacy/core_plugins/data/public/types.ts index 7075c241da609..b6c9c47cc0ae6 100644 --- a/src/legacy/core_plugins/data/public/types.ts +++ b/src/legacy/core_plugins/data/public/types.ts @@ -19,6 +19,7 @@ import { UiSettingsClientContract, CoreStart } from 'src/core/public'; import { DataPublicPluginStart } from 'src/plugins/data/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; export interface IDataPluginServices extends Partial { appName: string; @@ -26,6 +27,6 @@ export interface IDataPluginServices extends Partial { savedObjects: CoreStart['savedObjects']; notifications: CoreStart['notifications']; http: CoreStart['http']; - storage: Storage; + storage: IStorageWrapper; data: DataPublicPluginStart; } diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/contexts/query_input_bar_context.ts b/src/legacy/core_plugins/vis_type_timeseries/public/contexts/query_input_bar_context.ts index 76d3ae20f5f5e..925b483905d01 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/contexts/query_input_bar_context.ts +++ b/src/legacy/core_plugins/vis_type_timeseries/public/contexts/query_input_bar_context.ts @@ -19,7 +19,7 @@ import React from 'react'; import { UiSettingsClientContract, SavedObjectsClientContract } from 'src/core/public'; -import { IStorageWrapper } from '../../../../../kibana_utils/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; export interface ICoreStartContext { appName: string; diff --git a/x-pack/legacy/plugins/graph/public/app.js b/x-pack/legacy/plugins/graph/public/app.js index 41e5819bcbf37..ab83815457981 100644 --- a/x-pack/legacy/plugins/graph/public/app.js +++ b/x-pack/legacy/plugins/graph/public/app.js @@ -100,7 +100,7 @@ export function initGraphApp(angularModule, deps) { app.directive('graphApp', function (reactDirective) { return reactDirective(GraphApp, [ - ['store', { watchDepth: 'reference' }], + ['storage', { watchDepth: 'reference' }], ['isInitialized', { watchDepth: 'reference' }], ['currentIndexPattern', { watchDepth: 'reference' }], ['indexPatternProvider', { watchDepth: 'reference' }], @@ -310,7 +310,7 @@ export function initGraphApp(angularModule, deps) { // register things on scope passed down to react components $scope.pluginDataStart = npData; - $scope.store = new Storage(window.localStorage); + $scope.storage = new Storage(window.localStorage); $scope.coreStart = coreStart; $scope.loading = false; $scope.reduxStore = store; diff --git a/x-pack/legacy/plugins/graph/public/components/app.tsx b/x-pack/legacy/plugins/graph/public/components/app.tsx index c14af75f3b057..5ff7fc2e5da93 100644 --- a/x-pack/legacy/plugins/graph/public/components/app.tsx +++ b/x-pack/legacy/plugins/graph/public/components/app.tsx @@ -11,12 +11,12 @@ import { Provider } from 'react-redux'; import React, { useState } from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import { CoreStart } from 'kibana/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { FieldManager } from './field_manager'; import { SearchBarProps, SearchBar } from './search_bar'; import { GraphStore } from '../state_management'; import { GuidancePanel } from './guidance_panel'; -import { IStorageWrapper } from '../../../../../../src/plugins/kibana_utils/public'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; export interface GraphAppProps extends SearchBarProps { diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index cd6bfb277f9ca..afde46974017d 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx @@ -19,9 +19,9 @@ import { Query, } from 'src/legacy/core_plugins/data/public'; import { Filter } from '@kbn/es-query'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { TopNavMenu } from '../../../../../../src/legacy/core_plugins/kibana_react/public'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; -import { IStorageWrapper } from '../../../../../../src/plugins/kibana_utils/public'; import { Document, SavedObjectStore } from '../persistence'; import { EditorFrameInstance } from '../types'; import { NativeRenderer } from '../native_renderer'; diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.test.tsx index 49a04e59b7cc9..a6ccc6361c3d0 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.test.tsx @@ -18,7 +18,7 @@ import { SavedObjectsClientContract, HttpServiceBase, } from 'src/core/public'; -import { Storage } from 'ui/storage'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { IndexPatternPrivateState } from '../types'; jest.mock('ui/new_platform'); @@ -133,7 +133,7 @@ describe('IndexPatternDimensionPanel', () => { layerId: 'first', uniqueLabel: 'stuff', filterOperations: () => true, - storage: {} as Storage, + storage: {} as IStorageWrapper, uiSettings: {} as UiSettingsClientContract, savedObjectsClient: {} as SavedObjectsClientContract, http: {} as HttpServiceBase, diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.tsx index 3bba9425023a5..a1242947a87d3 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/dimension_panel/dimension_panel.tsx @@ -13,7 +13,7 @@ import { SavedObjectsClientContract, HttpServiceBase, } from 'src/core/public'; -import { IStorageWrapper } from '../../../../../../../src/plugins/kibana_utils/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { DatasourceDimensionPanelProps, StateSetter } from '../../types'; import { IndexPatternColumn, OperationType } from '../indexpattern'; import { getAvailableOperationsByMetadata, buildColumn, changeField } from '../operations'; diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.ts b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.ts index b4f01078f1f78..2edf9dd0b5acb 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.ts +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.test.ts @@ -5,7 +5,7 @@ */ import chromeMock from 'ui/chrome'; -import { Storage } from 'ui/storage'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { SavedObjectsClientContract } from 'kibana/public'; import { getIndexPatternDatasource, IndexPatternColumn, uniqueLabels } from './indexpattern'; import { DatasourcePublicAPI, Operation, Datasource } from '../types'; @@ -143,7 +143,7 @@ describe('IndexPattern Data Source', () => { beforeEach(() => { indexPatternDatasource = getIndexPatternDatasource({ chrome: chromeMock, - storage: {} as Storage, + storage: {} as IStorageWrapper, core: coreMock.createStart(), savedObjectsClient: {} as SavedObjectsClientContract, data: pluginsMock.createStart().data, diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx index 20837b6b82d45..1ab6ab6307e8d 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.tsx @@ -10,7 +10,7 @@ import { render } from 'react-dom'; import { I18nProvider } from '@kbn/i18n/react'; import { CoreStart, SavedObjectsClientContract } from 'src/core/public'; import { i18n } from '@kbn/i18n'; -import { IStorageWrapper } from '../../../../../../src/plugins/kibana_utils/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { DatasourceDimensionPanelProps, DatasourceDataPanelProps, diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx index f984597a8eb4b..0b2243a01bf0a 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/date_histogram.test.tsx @@ -14,7 +14,7 @@ import { SavedObjectsClientContract, HttpServiceBase, } from 'src/core/public'; -import { Storage } from 'ui/storage'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { createMockedIndexPattern } from '../../mocks'; import { IndexPatternPrivateState } from '../../types'; @@ -327,7 +327,7 @@ describe('date_histogram', () => { columnId="col1" layerId="first" currentColumn={state.layers.first.columns.col1 as DateHistogramIndexPatternColumn} - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -346,7 +346,7 @@ describe('date_histogram', () => { columnId="col2" currentColumn={state.layers.second.columns.col2 as DateHistogramIndexPatternColumn} layerId="second" - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -364,7 +364,7 @@ describe('date_histogram', () => { columnId="col1" currentColumn={state.layers.third.columns.col1 as DateHistogramIndexPatternColumn} layerId="third" - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -383,7 +383,7 @@ describe('date_histogram', () => { columnId="col1" layerId="third" currentColumn={state.layers.third.columns.col1 as DateHistogramIndexPatternColumn} - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -406,7 +406,7 @@ describe('date_histogram', () => { columnId="col1" layerId="first" currentColumn={state.layers.first.columns.col1 as DateHistogramIndexPatternColumn} - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -469,7 +469,7 @@ describe('date_histogram', () => { columnId="col1" layerId="first" currentColumn={state.layers.first.columns.col1 as DateHistogramIndexPatternColumn} - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/index.ts b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/index.ts index 5f0ee51eaed4e..ea6a54f5fa17f 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/index.ts +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/index.ts @@ -9,6 +9,7 @@ import { SavedObjectsClientContract, HttpServiceBase, } from 'src/core/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { termsOperation } from './terms'; import { cardinalityOperation } from './cardinality'; import { minOperation, averageOperation, sumOperation, maxOperation } from './metrics'; @@ -17,7 +18,6 @@ import { countOperation } from './count'; import { DimensionPriority, StateSetter, OperationMetadata } from '../../../types'; import { BaseIndexPatternColumn, FieldBasedIndexPatternColumn } from './column_types'; import { IndexPatternPrivateState, IndexPattern, IndexPatternField } from '../../types'; -import { IStorageWrapper } from '../../../../../../../../src/plugins/kibana_utils/public'; // List of all operation definitions registered to this data source. // If you want to implement a new operation, add it to this array and diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/terms.test.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/terms.test.tsx index df5bfac6d03a4..9630f850dc247 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/terms.test.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/operations/definitions/terms.test.tsx @@ -12,7 +12,7 @@ import { SavedObjectsClientContract, HttpServiceBase, } from 'src/core/public'; -import { Storage } from 'ui/storage'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { createMockedIndexPattern } from '../../mocks'; import { TermsIndexPatternColumn } from './terms'; import { termsOperation } from '.'; @@ -329,7 +329,7 @@ describe('terms', () => { columnId="col1" currentColumn={state.layers.first.columns.col1 as TermsIndexPatternColumn} layerId="first" - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -355,7 +355,7 @@ describe('terms', () => { columnId="col1" currentColumn={state.layers.first.columns.col1 as TermsIndexPatternColumn} layerId="first" - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -403,7 +403,7 @@ describe('terms', () => { columnId="col1" layerId="first" currentColumn={state.layers.first.columns.col1 as TermsIndexPatternColumn} - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -427,7 +427,7 @@ describe('terms', () => { columnId="col1" layerId="first" currentColumn={state.layers.first.columns.col1 as TermsIndexPatternColumn} - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -472,7 +472,7 @@ describe('terms', () => { columnId="col1" layerId="first" currentColumn={state.layers.first.columns.col1 as TermsIndexPatternColumn} - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} @@ -491,7 +491,7 @@ describe('terms', () => { columnId="col1" layerId="first" currentColumn={state.layers.first.columns.col1 as TermsIndexPatternColumn} - storage={{} as Storage} + storage={{} as IStorageWrapper} uiSettings={{} as UiSettingsClientContract} savedObjectsClient={{} as SavedObjectsClientContract} http={{} as HttpServiceBase} diff --git a/x-pack/legacy/plugins/lens/public/lens_ui_telemetry/factory.test.ts b/x-pack/legacy/plugins/lens/public/lens_ui_telemetry/factory.test.ts index 6e860c594f4a5..15d36a7c31169 100644 --- a/x-pack/legacy/plugins/lens/public/lens_ui_telemetry/factory.test.ts +++ b/x-pack/legacy/plugins/lens/public/lens_ui_telemetry/factory.test.ts @@ -11,9 +11,9 @@ import { trackUiEvent, trackSuggestionEvent, } from './factory'; -import { Storage } from 'src/legacy/core_plugins/data/public/types'; import { coreMock } from 'src/core/public/mocks'; import { HttpServiceBase } from 'kibana/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; jest.useFakeTimers(); @@ -30,7 +30,7 @@ const createMockStorage = () => { }; describe('Lens UI telemetry', () => { - let storage: jest.Mocked; + let storage: jest.Mocked; let http: jest.Mocked; let dateSpy: jest.SpyInstance; diff --git a/x-pack/legacy/plugins/lens/public/lens_ui_telemetry/factory.ts b/x-pack/legacy/plugins/lens/public/lens_ui_telemetry/factory.ts index 673910deae339..1a8ec604eda54 100644 --- a/x-pack/legacy/plugins/lens/public/lens_ui_telemetry/factory.ts +++ b/x-pack/legacy/plugins/lens/public/lens_ui_telemetry/factory.ts @@ -7,7 +7,7 @@ import moment from 'moment'; import { HttpServiceBase } from 'src/core/public'; -import { Storage } from 'src/legacy/core_plugins/data/public/types'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { BASE_API_URL } from '../../common'; const STORAGE_KEY = 'lens-ui-telemetry'; @@ -43,11 +43,11 @@ export class LensReportManager { private events: Record> = {}; private suggestionEvents: Record> = {}; - private storage: Storage; + private storage: IStorageWrapper; private http: HttpServiceBase; private timer: ReturnType; - constructor({ storage, http }: { storage: Storage; http: HttpServiceBase }) { + constructor({ storage, http }: { storage: IStorageWrapper; http: HttpServiceBase }) { this.storage = storage; this.http = http; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/__snapshots__/view.test.js.snap b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/__snapshots__/view.test.js.snap index c3d4ff673e3d5..4377fa4725483 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/__snapshots__/view.test.js.snap +++ b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/__snapshots__/view.test.js.snap @@ -6,7 +6,7 @@ exports[`LayerPanel is rendered 1`] = ` Object { "appName": "maps", "data": undefined, - "store": Storage { + "storage": Storage { "clear": [Function], "get": [Function], "remove": [Function], From d801397db55b8317c8409e5598ee0201903ac3c3 Mon Sep 17 00:00:00 2001 From: Liza K Date: Sun, 27 Oct 2019 18:05:20 +0200 Subject: [PATCH 4/6] Delete data legacy dependencies plugin --- src/legacy/core_plugins/data/public/legacy.ts | 7 +-- src/legacy/core_plugins/data/public/plugin.ts | 34 +++++--------- .../public/shim/legacy_dependencies_plugin.ts | 44 ------------------- .../kibana_utils/public/storage/storage.ts | 3 -- 4 files changed, 11 insertions(+), 77 deletions(-) delete mode 100644 src/legacy/core_plugins/data/public/shim/legacy_dependencies_plugin.ts diff --git a/src/legacy/core_plugins/data/public/legacy.ts b/src/legacy/core_plugins/data/public/legacy.ts index e151726a6d702..b1d838aed992d 100644 --- a/src/legacy/core_plugins/data/public/legacy.ts +++ b/src/legacy/core_plugins/data/public/legacy.ts @@ -35,18 +35,13 @@ */ import { npSetup, npStart } from 'ui/new_platform'; -import { LegacyDependenciesPlugin } from './shim/legacy_dependencies_plugin'; import { plugin } from '.'; const dataPlugin = plugin(); -const legacyPlugin = new LegacyDependenciesPlugin(); -export const setup = dataPlugin.setup(npSetup.core, { - __LEGACY: legacyPlugin.setup(), -}); +export const setup = dataPlugin.setup(npSetup.core); export const start = dataPlugin.start(npStart.core, { data: npStart.plugins.data, uiActions: npSetup.plugins.uiActions, - __LEGACY: legacyPlugin.start(), }); diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index 42c41f3fd9795..0f12a5a498471 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -18,15 +18,13 @@ */ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { SearchService, SearchStart, createSearchBar, StatetfulSearchBarProps } from './search'; import { QueryService, QuerySetup } from './query'; import { FilterService, FilterSetup, FilterStart } from './filter'; import { TimefilterService, TimefilterSetup } from './timefilter'; import { IndexPatternsService, IndexPatternsSetup, IndexPatternsStart } from './index_patterns'; -import { - LegacyDependenciesPluginSetup, - LegacyDependenciesPluginStart, -} from './shim/legacy_dependencies_plugin'; +import { Storage } from '../../../../../src/plugins/kibana_utils/public'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; import { initLegacyModule } from './shim/legacy_module'; import { IUiActionsSetup } from '../../../../plugins/ui_actions/public'; @@ -36,19 +34,9 @@ import { } from './filter/action/apply_filter_action'; import { APPLY_FILTER_TRIGGER } from '../../../../plugins/embeddable/public'; -/** - * Interface for any dependencies on other plugins' `setup` contracts. - * - * @internal - */ -export interface DataPluginSetupDependencies { - __LEGACY: LegacyDependenciesPluginSetup; -} - export interface DataPluginStartDependencies { data: DataPublicPluginStart; uiActions: IUiActionsSetup; - __LEGACY: LegacyDependenciesPluginStart; } /** @@ -90,9 +78,7 @@ export interface DataStart { * in the setup/start interfaces. The remaining items exported here are either types, * or static code. */ -export class DataPlugin - implements - Plugin { +export class DataPlugin implements Plugin { // Exposed services, sorted alphabetically private readonly filter: FilterService = new FilterService(); private readonly indexPatterns: IndexPatternsService = new IndexPatternsService(); @@ -101,13 +87,16 @@ export class DataPlugin private readonly timefilter: TimefilterService = new TimefilterService(); private setupApi!: DataSetup; + private storage!: IStorageWrapper; - public setup(core: CoreSetup, { __LEGACY }: DataPluginSetupDependencies): DataSetup { + public setup(core: CoreSetup): DataSetup { const { uiSettings } = core; + this.storage = new Storage(window.localStorage); + const timefilterService = this.timefilter.setup({ uiSettings, - storage: __LEGACY.storage, + storage: this.storage, }); const filterService = this.filter.setup({ uiSettings, @@ -122,10 +111,7 @@ export class DataPlugin return this.setupApi; } - public start( - core: CoreStart, - { __LEGACY, data, uiActions }: DataPluginStartDependencies - ): DataStart { + public start(core: CoreStart, { data, uiActions }: DataPluginStartDependencies): DataStart { const { uiSettings, http, notifications, savedObjects } = core; const indexPatternsService = this.indexPatterns.start({ @@ -140,7 +126,7 @@ export class DataPlugin const SearchBar = createSearchBar({ core, data, - storage: __LEGACY.storage, + storage: this.storage, timefilter: this.setupApi.timefilter, filterManager: this.setupApi.filter.filterManager, }); diff --git a/src/legacy/core_plugins/data/public/shim/legacy_dependencies_plugin.ts b/src/legacy/core_plugins/data/public/shim/legacy_dependencies_plugin.ts deleted file mode 100644 index 9b13790084791..0000000000000 --- a/src/legacy/core_plugins/data/public/shim/legacy_dependencies_plugin.ts +++ /dev/null @@ -1,44 +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 { IStorageWrapper, Storage } from '../../../../../../src/plugins/kibana_utils/public'; -import { Plugin } from '../../../../../../src/core/public'; - -/** @internal */ -export interface LegacyDependenciesPluginSetup { - storage: IStorageWrapper; -} - -export interface LegacyDependenciesPluginStart { - storage: IStorageWrapper; -} - -export class LegacyDependenciesPlugin implements Plugin { - public setup() { - return { - storage: new Storage(window.localStorage), - } as LegacyDependenciesPluginSetup; - } - - public start() { - return { - storage: new Storage(window.localStorage), - } as LegacyDependenciesPluginStart; - } -} diff --git a/src/plugins/kibana_utils/public/storage/storage.ts b/src/plugins/kibana_utils/public/storage/storage.ts index 56e9ef7537e87..a7d3c5ac70074 100644 --- a/src/plugins/kibana_utils/public/storage/storage.ts +++ b/src/plugins/kibana_utils/public/storage/storage.ts @@ -17,9 +17,6 @@ * under the License. */ -// This is really silly, but I wasn't prepared to rename the kibana Storage class everywhere it is used -// and this is the only way I could figure out how to use the type definition for a built in object -// in a file that creates a type with the same name as that built in object. import { IStorage, IStorageWrapper } from './types'; export class Storage implements IStorageWrapper { From 8868f0436d7f5bfe16fcdaab809450ed83fa9934 Mon Sep 17 00:00:00 2001 From: Liza K Date: Sun, 27 Oct 2019 18:05:56 +0200 Subject: [PATCH 5/6] Imports fix --- src/legacy/core_plugins/data/public/plugin.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index 0f12a5a498471..e82db0d191f51 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -18,13 +18,12 @@ */ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; -import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { SearchService, SearchStart, createSearchBar, StatetfulSearchBarProps } from './search'; import { QueryService, QuerySetup } from './query'; import { FilterService, FilterSetup, FilterStart } from './filter'; import { TimefilterService, TimefilterSetup } from './timefilter'; import { IndexPatternsService, IndexPatternsSetup, IndexPatternsStart } from './index_patterns'; -import { Storage } from '../../../../../src/plugins/kibana_utils/public'; +import { Storage, IStorageWrapper } from '../../../../../src/plugins/kibana_utils/public'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; import { initLegacyModule } from './shim/legacy_module'; import { IUiActionsSetup } from '../../../../plugins/ui_actions/public'; From f5aa18655d470cc122dd740fdac8942e5e9a70f1 Mon Sep 17 00:00:00 2001 From: Liza K Date: Mon, 28 Oct 2019 09:54:57 +0200 Subject: [PATCH 6/6] update snapshots --- .../query_bar_input.test.tsx.snap | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/legacy/core_plugins/data/public/query/query_bar/components/__snapshots__/query_bar_input.test.tsx.snap b/src/legacy/core_plugins/data/public/query/query_bar/components/__snapshots__/query_bar_input.test.tsx.snap index 286e60cca9712..37dc0d14730c0 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/components/__snapshots__/query_bar_input.test.tsx.snap +++ b/src/legacy/core_plugins/data/public/query/query_bar/components/__snapshots__/query_bar_input.test.tsx.snap @@ -304,12 +304,12 @@ exports[`QueryBarInput Should disable autoFocus on EuiFieldText when disableAuto "update": [MockFunction], }, }, - "store": Object { + "storage": Object { "clear": [MockFunction], "get": [MockFunction], "remove": [MockFunction], "set": [MockFunction], - "store": Object { + "storage": Object { "clear": [MockFunction], "getItem": [MockFunction], "key": [MockFunction], @@ -867,12 +867,12 @@ exports[`QueryBarInput Should disable autoFocus on EuiFieldText when disableAuto "update": [MockFunction], }, }, - "store": Object { + "storage": Object { "clear": [MockFunction], "get": [MockFunction], "remove": [MockFunction], "set": [MockFunction], - "store": Object { + "storage": Object { "clear": [MockFunction], "getItem": [MockFunction], "key": [MockFunction], @@ -1418,12 +1418,12 @@ exports[`QueryBarInput Should pass the query language to the language switcher 1 "update": [MockFunction], }, }, - "store": Object { + "storage": Object { "clear": [MockFunction], "get": [MockFunction], "remove": [MockFunction], "set": [MockFunction], - "store": Object { + "storage": Object { "clear": [MockFunction], "getItem": [MockFunction], "key": [MockFunction], @@ -1978,12 +1978,12 @@ exports[`QueryBarInput Should pass the query language to the language switcher 1 "update": [MockFunction], }, }, - "store": Object { + "storage": Object { "clear": [MockFunction], "get": [MockFunction], "remove": [MockFunction], "set": [MockFunction], - "store": Object { + "storage": Object { "clear": [MockFunction], "getItem": [MockFunction], "key": [MockFunction], @@ -2529,12 +2529,12 @@ exports[`QueryBarInput Should render the given query 1`] = ` "update": [MockFunction], }, }, - "store": Object { + "storage": Object { "clear": [MockFunction], "get": [MockFunction], "remove": [MockFunction], "set": [MockFunction], - "store": Object { + "storage": Object { "clear": [MockFunction], "getItem": [MockFunction], "key": [MockFunction], @@ -3089,12 +3089,12 @@ exports[`QueryBarInput Should render the given query 1`] = ` "update": [MockFunction], }, }, - "store": Object { + "storage": Object { "clear": [MockFunction], "get": [MockFunction], "remove": [MockFunction], "set": [MockFunction], - "store": Object { + "storage": Object { "clear": [MockFunction], "getItem": [MockFunction], "key": [MockFunction],