Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover] Move State to inner angular #52369

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const {
data,
docTitle,
filterManager,
State,
share,
timefilter,
toastNotifications,
Expand Down Expand Up @@ -121,7 +120,7 @@ app.config($routeProvider => {
template: indexTemplate,
reloadOnSearch: false,
resolve: {
savedObjects: function (redirectWhenMissing, $route, kbnUrl, Promise, $rootScope) {
savedObjects: function (redirectWhenMissing, $route, kbnUrl, Promise, $rootScope, State) {
const indexPatterns = getServices().indexPatterns;
const savedSearchId = $route.current.params.id;
return ensureDefaultIndexPattern(core, getServices().data, $rootScope, kbnUrl).then(() => {
Expand All @@ -137,7 +136,6 @@ app.config($routeProvider => {
* @type {State}
*/
const state = new State('_a', {});

const id = getIndexPatternId(state.index, indexPatternList, uiSettings.get('defaultIndex'));
state.destroy();
return Promise.props({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import 'ui/angular-bootstrap';
import { IPrivate } from 'ui/private';
import { EuiIcon } from '@elastic/eui';
// @ts-ignore
import { StateProvider } from 'ui/state_management/state';
// @ts-ignore
import { EventsProvider } from 'ui/events';
import { PersistedState } from 'ui/persisted_state';
// @ts-ignore
Expand Down Expand Up @@ -277,6 +279,9 @@ function createLocalAppStateModule() {
})
.service('getAppState', function(Private: any) {
return Private(AppStateProvider).getAppState;
})
.service('State', function(Private: any) {
return Private(StateProvider);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import chromeLegacy from 'ui/chrome';
import { IPrivate } from 'ui/private';
import { FilterManager, TimefilterContract, IndexPatternsContract } from 'src/plugins/data/public';
// @ts-ignore
import { StateProvider } from 'ui/state_management/state';
// @ts-ignore
import { createSavedSearchesService } from '../saved_searches/saved_searches';
// @ts-ignore
import { createSavedSearchFactory } from '../saved_searches/_saved_search';
Expand All @@ -57,21 +55,18 @@ export interface DiscoverServices {
// legacy
getSavedSearchById: (id: string) => Promise<SavedSearch>;
getSavedSearchUrlById: (id: string) => Promise<string>;
State: unknown;
uiSettings: IUiSettingsClient;
}

export async function buildGlobalAngularServices() {
const injector = await chromeLegacy.dangerouslyGetActiveInjector();
const Private = injector.get<IPrivate>('Private');
const kbnUrl = injector.get<IPrivate>('kbnUrl');
const State = Private(StateProvider);
const SavedSearchFactory = createSavedSearchFactory(Private);
const service = createSavedSearchesService(Private, SavedSearchFactory, kbnUrl, chromeLegacy);
return {
getSavedSearchById: async (id: string) => service.get(id),
getSavedSearchUrlById: async (id: string) => service.urlFor(id),
State,
};
}

Expand Down