From b51e97e650d58a2aa9509e59b3f5679897770fee Mon Sep 17 00:00:00 2001 From: sulemanof Date: Mon, 16 Mar 2020 12:55:42 +0300 Subject: [PATCH] Move history to discover services --- .../kibana/public/discover/build_services.ts | 4 ++++ .../kibana/public/discover/np_ready/angular/discover.js | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/build_services.ts b/src/legacy/core_plugins/kibana/public/discover/build_services.ts index c58307adaf38c..282eef0c983eb 100644 --- a/src/legacy/core_plugins/kibana/public/discover/build_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/build_services.ts @@ -16,6 +16,8 @@ * specific language governing permissions and limitations * under the License. */ +import { createHashHistory, History } from 'history'; + import { Capabilities, ChromeStart, @@ -46,6 +48,7 @@ export interface DiscoverServices { data: DataPublicPluginStart; docLinks: DocLinksStart; docViewsRegistry: DocViewsRegistry; + history: History; theme: ChartsPluginStart['theme']; filterManager: FilterManager; indexPatterns: IndexPatternsContract; @@ -79,6 +82,7 @@ export async function buildServices( data: plugins.data, docLinks: core.docLinks, docViewsRegistry, + history: createHashHistory(), theme: plugins.charts.theme, filterManager: plugins.data.query.filterManager, getSavedSearchById: async (id: string) => savedObjectService.get(id), diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js index d59f1e0125fdc..6978781fe6696 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js @@ -24,7 +24,6 @@ import { debounceTime } from 'rxjs/operators'; import moment from 'moment'; import dateMath from '@elastic/datemath'; import { i18n } from '@kbn/i18n'; -import { createHashHistory } from 'history'; import { getState, splitState } from './discover_state'; import { RequestAdapter } from '../../../../../../../plugins/inspector/public'; @@ -59,6 +58,7 @@ const { chrome, data, docTitle, + history, indexPatterns, filterManager, share, @@ -88,8 +88,6 @@ const fetchStatuses = { const app = getAngularModule(); -app.factory('history', () => createHashHistory()); - app.config($routeProvider => { const defaults = { requireDefaultIndex: true, @@ -117,7 +115,7 @@ app.config($routeProvider => { template: indexTemplate, reloadOnSearch: false, resolve: { - savedObjects: function($route, kbnUrl, Promise, $rootScope, history) { + savedObjects: function($route, kbnUrl, Promise, $rootScope) { const savedSearchId = $route.current.params.id; return ensureDefaultIndexPattern(core, data, $rootScope, kbnUrl).then(() => { const { appStateContainer } = getState({ history }); @@ -189,8 +187,7 @@ function discoverController( config, kbnUrl, localStorage, - uiCapabilities, - history + uiCapabilities ) { const { isDefault: isDefaultType } = indexPatternsUtils; const subscriptions = new Subscription();