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 af7c29bf2f4b9..597ad86d39d85 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -22,10 +22,7 @@ import { SearchService, SearchStart, createSearchBar, StatetfulSearchBarProps } import { QueryService, QuerySetup } from './query'; import { TimefilterService, TimefilterSetup } from './timefilter'; import { IndexPatternsService, IndexPatternsSetup, IndexPatternsStart } from './index_patterns'; -import { - LegacyDependenciesPluginSetup, - LegacyDependenciesPluginStart, -} from './shim/legacy_dependencies_plugin'; +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'; @@ -35,19 +32,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; } /** @@ -87,22 +74,24 @@ 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 { private readonly indexPatterns: IndexPatternsService = new IndexPatternsService(); private readonly query: QueryService = new QueryService(); private readonly search: SearchService = new SearchService(); 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, - store: __LEGACY.storage, + storage: this.storage, }); this.setupApi = { indexPatterns: this.indexPatterns.setup(), @@ -113,10 +102,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({ @@ -131,7 +117,7 @@ export class DataPlugin const SearchBar = createSearchBar({ core, data, - store: __LEGACY.storage, + storage: this.storage, timefilter: this.setupApi.timefilter, }); 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..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 { Storage } from '../../types'; +import { IStorageWrapper } from 'src/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/__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], 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..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,12 +18,12 @@ */ import { UiSettingsClientContract } from 'src/core/public'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { PersistedLog } from '../../persisted_log'; -import { Storage } from '../../../types'; 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 7fdbc996ac8c2..c186edf9a3ac9 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 'src/plugins/kibana_utils/public'; import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; import { TimefilterSetup } from '../../../timefilter'; import { SearchBar } from '../../../'; @@ -31,7 +31,7 @@ import { SearchBarOwnProps } from '.'; interface StatefulSearchBarDeps { core: CoreStart; data: DataPublicPluginStart; - store: Storage; + storage: IStorageWrapper; timefilter: TimefilterSetup; } @@ -54,7 +54,7 @@ const defaultOnRefreshChange = (timefilter: TimefilterSetup) => { }; }; -export function createSearchBar({ core, store, timefilter, data }: StatefulSearchBarDeps) { +export function createSearchBar({ core, storage, timefilter, data }: StatefulSearchBarDeps) { // App name should come from the core application service. // Until it's available, we'll ask the user to provide it for the pre-wired component. return (props: StatetfulSearchBarProps) => { @@ -107,7 +107,7 @@ export function createSearchBar({ core, store, timefilter, data }: StatefulSearc 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 deleted file mode 100644 index 83d276fe9ba74..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 { Storage } from 'ui/storage'; -import { Plugin } from '../../../../../../src/core/public'; - -/** @internal */ -export interface LegacyDependenciesPluginSetup { - storage: Storage; -} - -export interface LegacyDependenciesPluginStart { - storage: Storage; -} - -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/legacy/core_plugins/data/public/timefilter/time_history.ts b/src/legacy/core_plugins/data/public/timefilter/time_history.ts index 22778d1adea3c..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,13 +19,13 @@ 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 { Storage } from '../types'; 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..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 { Storage } from '../types'; /** * 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 2c02a9b764755..b6c9c47cc0ae6 100644 --- a/src/legacy/core_plugins/data/public/types.ts +++ b/src/legacy/core_plugins/data/public/types.ts @@ -19,13 +19,7 @@ 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; -} +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; export interface IDataPluginServices extends Partial { appName: string; @@ -33,6 +27,6 @@ export interface IDataPluginServices extends Partial { savedObjects: CoreStart['savedObjects']; notifications: CoreStart['notifications']; http: CoreStart['http']; - store: Storage; + storage: IStorageWrapper; data: DataPublicPluginStart; } diff --git a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts index dd0674073f442..b78d05e68acad 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -18,6 +18,7 @@ */ import 'ui/collapsible_sidebar'; import 'ui/directives/listen'; +import 'ui/directives/storage'; import 'ui/fixed_scroll'; import 'ui/directives/css_truncate'; 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 57a3f4bcbf6de..6f402ad59e38d 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js @@ -26,6 +26,7 @@ import './visualization'; 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 a5bb2ee3b6b0b..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 './storage'; +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/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({ { 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/legacy/ui/public/storage/web_storage.ts b/src/plugins/kibana_utils/public/storage/types.ts similarity index 70% rename from src/legacy/ui/public/storage/web_storage.ts rename to src/plugins/kibana_utils/public/storage/types.ts index d5f775431143d..875bb44bcad17 100644 --- a/src/legacy/ui/public/storage/web_storage.ts +++ b/src/plugins/kibana_utils/public/storage/types.ts @@ -17,4 +17,16 @@ * under the License. */ -export type WebStorage = Storage; +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; +} diff --git a/x-pack/legacy/plugins/canvas/public/lib/clipboard.js b/x-pack/legacy/plugins/canvas/public/lib/clipboard.js index 2cebf2a5bad96..f9d68769c9c3a 100644 --- a/x-pack/legacy/plugins/canvas/public/lib/clipboard.js +++ b/x-pack/legacy/plugins/canvas/public/lib/clipboard.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Storage } from 'ui/storage'; +import { Storage } from '../../../../../../src/plugins/kibana_utils/public'; import { LOCALSTORAGE_CLIPBOARD } from '../../common/lib/constants'; import { getWindow } from './get_window'; diff --git a/x-pack/legacy/plugins/graph/public/angular/templates/index.html b/x-pack/legacy/plugins/graph/public/angular/templates/index.html index 686f0f590a19c..b3f5bce7ea6ec 100644 --- a/x-pack/legacy/plugins/graph/public/angular/templates/index.html +++ b/x-pack/legacy/plugins/graph/public/angular/templates/index.html @@ -61,7 +61,7 @@ initial-query="initialQuery" plugin-data-start="pluginDataStart" core-start="coreStart" - store="store" + storage="storage" no-index-patterns="noIndexPatterns" > 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 aa2221441793f..5ff7fc2e5da93 100644 --- a/x-pack/legacy/plugins/graph/public/components/app.tsx +++ b/x-pack/legacy/plugins/graph/public/components/app.tsx @@ -10,8 +10,8 @@ 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 { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { FieldManager } from './field_manager'; import { SearchBarProps, SearchBar } from './search_bar'; import { GraphStore } from '../state_management'; @@ -23,7 +23,7 @@ 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/graph/public/index.ts b/x-pack/legacy/plugins/graph/public/index.ts index 0249ca74035d6..5e500367ccdc5 100644 --- a/x-pack/legacy/plugins/graph/public/index.ts +++ b/x-pack/legacy/plugins/graph/public/index.ts @@ -14,11 +14,11 @@ import chrome from 'ui/chrome'; import { IPrivate } from 'ui/private'; // @ts-ignore import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; -import { Storage } from 'ui/storage'; // @ts-ignore import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry'; import { npSetup, npStart } from 'ui/new_platform'; +import { Storage } from '../../../../../src/plugins/kibana_utils/public'; import { start as data } from '../../../../../src/legacy/core_plugins/data/public/legacy'; import { GraphPlugin } from './plugin'; 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 85494701749f1..a1710d67b31db 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx @@ -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'; @@ -80,7 +80,7 @@ describe('Lens App', () => { data: typeof dataStartMock; core: typeof core; dataShim: DataStart; - store: Storage; + storage: Storage; docId?: string; docStorage: SavedObjectStore; redirectTo: (id?: string) => void; @@ -112,7 +112,7 @@ describe('Lens App', () => { }, timefilter: { history: {} }, }, - store: { + storage: { get: jest.fn(), }, docStorage: { @@ -125,7 +125,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 3f27fe3cbc072..a95e0450f614c 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'; @@ -20,6 +19,7 @@ import { Query, } from 'src/legacy/core_plugins/data/public'; import { Filter } from '@kbn/es-query'; +import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { start as navigation } from '../../../../../../src/legacy/core_plugins/navigation/public/legacy'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { Document, SavedObjectStore } from '../persistence'; @@ -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, @@ -170,7 +170,7 @@ export function App({ services={{ appName: 'lens', data, - store, + storage, ...core, }} > @@ -247,7 +247,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 b7960b23651c6..56c19ea2bb9f2 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'; @@ -84,7 +84,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.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 c0c774a225642..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 @@ -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.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 359eb687b5741..1ab6ab6307e8d 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="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 fdb5419588e7e..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 @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Storage } from 'ui/storage'; import { UiSettingsClientContract, 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'; @@ -48,7 +48,7 @@ export interface ParamEditorProps { 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/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/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/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/angular/map_controller.js b/x-pack/legacy/plugins/maps/public/angular/map_controller.js index a3102417a9cb6..cef2a70a6d03d 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/__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], 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 {