From d801397db55b8317c8409e5598ee0201903ac3c3 Mon Sep 17 00:00:00 2001 From: Liza K Date: Sun, 27 Oct 2019 18:05:20 +0200 Subject: [PATCH] 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 {