Skip to content

Commit

Permalink
[Visualize] Deangularize and typescriptify saved_object usage (#52984)
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Dec 18, 2019
1 parent 1b22317 commit e03b15e
Show file tree
Hide file tree
Showing 17 changed files with 339 additions and 296 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import * as docViewsRegistry from 'ui/registry/doc_views';
import { FilterManager, TimefilterContract, IndexPatternsContract } from 'src/plugins/data/public';
// @ts-ignore
import { createSavedSearchesService } from '../saved_searches/saved_searches';
import { createSavedSearchesService } from '../saved_searches';
// @ts-ignore
import { DiscoverStartPlugins } from '../plugin';
import { DataStart } from '../../../../data/public';
Expand Down
2 changes: 2 additions & 0 deletions src/legacy/core_plugins/kibana/public/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ export const pluginInstance = plugin({} as PluginInitializerContext);
SavedObjectRegistryProvider.register((savedSearches: any) => {
return savedSearches;
});

export { createSavedSearchesService } from './saved_searches/saved_searches';
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
* under the License.
*/

import './saved_searches';
export * from './saved_searches';
import './saved_searches_register';
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
import { npStart } from 'ui/new_platform';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { SavedObjectLoader } from 'ui/saved_objects';
import { SavedObjectKibanaServices } from 'ui/saved_objects/types';
// @ts-ignore
import { savedObjectManagementRegistry } from '../../management/saved_object_registry';
import { createSavedSearchClass } from './_saved_search';

// Register this service with the saved object registry so it can be
// edited by the object editor.
savedObjectManagementRegistry.register({
service: 'savedSearches',
title: 'searches',
});

export function createSavedSearchesService(services: SavedObjectKibanaServices) {
const SavedSearchClass = createSavedSearchClass(services);
const savedSearchLoader = new SavedObjectLoader(
Expand All @@ -50,14 +38,3 @@ export function createSavedSearchesService(services: SavedObjectKibanaServices)

return savedSearchLoader;
}
// this is needed for saved object management
const module = uiModules.get('discover/saved_searches');
module.service('savedSearches', () => {
const services = {
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};
return createSavedSearchesService(services);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 { npStart } from 'ui/new_platform';
// @ts-ignore
import { uiModules } from 'ui/modules';
// @ts-ignore
import { savedObjectManagementRegistry } from '../../management/saved_object_registry';

import { createSavedSearchesService } from './saved_searches';

// this is needed for saved object management
// Register this service with the saved object registry so it can be
// edited by the object editor.
savedObjectManagementRegistry.register({
service: 'savedSearches',
title: 'searches',
});
const module = uiModules.get('discover/saved_searches');
module.service('savedSearches', () => {
const services = {
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};
return createSavedSearchesService(services);
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { getTableAggs } from 'ui/visualize/loader/pipeline_helpers/utilities';
import { AppState } from 'ui/state_management/app_state';
import { npStart } from 'ui/new_platform';
import { IExpressionLoaderParams } from 'src/plugins/expressions/public';
import { SearchSourceContract } from '../../../../../ui/public/courier';
import { SearchSourceContract } from 'ui/courier';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {
IIndexPattern,
Expand All @@ -47,6 +47,7 @@ import {
APPLY_FILTER_TRIGGER,
} from '../../../../../../plugins/embeddable/public';
import { dispatchRenderComplete } from '../../../../../../plugins/kibana_utils/public';
import { SavedSearch } from '../../discover/types';

const getKeys = <T extends {}>(o: T): Array<keyof T> => Object.keys(o) as Array<keyof T>;

Expand All @@ -57,6 +58,10 @@ export interface VisSavedObject extends SavedObject {
title: string;
uiStateJSON?: string;
destroy: () => void;
savedSearchRefName?: string;
savedSearchId?: string;
savedSearch?: SavedSearch;
visState: any;
}

export interface VisualizeEmbeddableConfiguration {
Expand Down

This file was deleted.

Loading

0 comments on commit e03b15e

Please sign in to comment.