Use SavedObjectClass
from savedObject
start contract instead of createSavedObjectClass
(#80063)
* no longer export static createSavedObjectClass from savedObject plugin * fix forgotten call * yet another usage * more fixes * move so to required plugins for timelion
This commit is contained in:
parent
c646219f7c
commit
bb174fd1d5
|
@ -412,10 +412,7 @@ export class DashboardPlugin
|
|||
|
||||
public start(core: CoreStart, plugins: StartDependencies): DashboardStart {
|
||||
const { notifications } = core;
|
||||
const {
|
||||
uiActions,
|
||||
data: { indexPatterns, search },
|
||||
} = plugins;
|
||||
const { uiActions } = plugins;
|
||||
|
||||
const SavedObjectFinder = getSavedObjectFinder(core.savedObjects, core.uiSettings);
|
||||
|
||||
|
@ -447,10 +444,7 @@ export class DashboardPlugin
|
|||
|
||||
const savedDashboardLoader = createSavedDashboardLoader({
|
||||
savedObjectsClient: core.savedObjects.client,
|
||||
indexPatterns,
|
||||
search,
|
||||
chrome: core.chrome,
|
||||
overlays: core.overlays,
|
||||
savedObjects: plugins.savedObjects,
|
||||
});
|
||||
const dashboardContainerFactory = plugins.embeddable.getEmbeddableFactory(
|
||||
DASHBOARD_CONTAINER_TYPE
|
||||
|
|
|
@ -16,11 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import {
|
||||
createSavedObjectClass,
|
||||
SavedObject,
|
||||
SavedObjectKibanaServices,
|
||||
} from '../../../../plugins/saved_objects/public';
|
||||
import { SavedObject, SavedObjectsStart } from '../../../../plugins/saved_objects/public';
|
||||
import { extractReferences, injectReferences } from './saved_dashboard_references';
|
||||
|
||||
import { Filter, ISearchSource, Query, RefreshInterval } from '../../../../plugins/data/public';
|
||||
|
@ -45,10 +41,9 @@ export interface SavedObjectDashboard extends SavedObject {
|
|||
|
||||
// Used only by the savedDashboards service, usually no reason to change this
|
||||
export function createSavedDashboardClass(
|
||||
services: SavedObjectKibanaServices
|
||||
savedObjectStart: SavedObjectsStart
|
||||
): new (id: string) => SavedObjectDashboard {
|
||||
const SavedObjectClass = createSavedObjectClass(services);
|
||||
class SavedDashboard extends SavedObjectClass {
|
||||
class SavedDashboard extends savedObjectStart.SavedObjectClass {
|
||||
// save these objects with the 'dashboard' type
|
||||
public static type = 'dashboard';
|
||||
|
||||
|
|
|
@ -17,23 +17,19 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { SavedObjectsClientContract, ChromeStart, OverlayStart } from 'kibana/public';
|
||||
import { DataPublicPluginStart, IndexPatternsContract } from '../../../../plugins/data/public';
|
||||
import { SavedObjectLoader } from '../../../../plugins/saved_objects/public';
|
||||
import { SavedObjectsClientContract } from 'kibana/public';
|
||||
import { SavedObjectLoader, SavedObjectsStart } from '../../../../plugins/saved_objects/public';
|
||||
import { createSavedDashboardClass } from './saved_dashboard';
|
||||
|
||||
interface Services {
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
indexPatterns: IndexPatternsContract;
|
||||
search: DataPublicPluginStart['search'];
|
||||
chrome: ChromeStart;
|
||||
overlays: OverlayStart;
|
||||
savedObjects: SavedObjectsStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param services
|
||||
*/
|
||||
export function createSavedDashboardLoader(services: Services) {
|
||||
const SavedDashboard = createSavedDashboardClass(services);
|
||||
return new SavedObjectLoader(SavedDashboard, services.savedObjectsClient);
|
||||
export function createSavedDashboardLoader({ savedObjects, savedObjectsClient }: Services) {
|
||||
const SavedDashboard = createSavedDashboardClass(savedObjects);
|
||||
return new SavedObjectLoader(SavedDashboard, savedObjectsClient);
|
||||
}
|
||||
|
|
|
@ -12,13 +12,9 @@
|
|||
"urlForwarding",
|
||||
"navigation",
|
||||
"uiActions",
|
||||
"visualizations"
|
||||
"visualizations",
|
||||
"savedObjects"
|
||||
],
|
||||
"optionalPlugins": ["home", "share"],
|
||||
"requiredBundles": [
|
||||
"kibanaUtils",
|
||||
"home",
|
||||
"savedObjects",
|
||||
"kibanaReact"
|
||||
]
|
||||
"requiredBundles": ["kibanaUtils", "home", "kibanaReact"]
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import { Start as InspectorPublicPluginStart } from 'src/plugins/inspector/publi
|
|||
import { SharePluginStart } from 'src/plugins/share/public';
|
||||
import { ChartsPluginStart } from 'src/plugins/charts/public';
|
||||
import { VisualizationsStart } from 'src/plugins/visualizations/public';
|
||||
import { SavedObjectKibanaServices } from 'src/plugins/saved_objects/public';
|
||||
|
||||
import { DiscoverStartPlugins } from './plugin';
|
||||
import { createSavedSearchesLoader, SavedSearch } from './saved_searches';
|
||||
|
@ -78,12 +77,9 @@ export async function buildServices(
|
|||
context: PluginInitializerContext,
|
||||
getEmbeddableInjector: any
|
||||
): Promise<DiscoverServices> {
|
||||
const services: SavedObjectKibanaServices = {
|
||||
const services = {
|
||||
savedObjectsClient: core.savedObjects.client,
|
||||
indexPatterns: plugins.data.indexPatterns,
|
||||
search: plugins.data.search,
|
||||
chrome: core.chrome,
|
||||
overlays: core.overlays,
|
||||
savedObjects: plugins.savedObjects,
|
||||
};
|
||||
const savedObjectService = createSavedSearchesLoader(services);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ import { UrlForwardingSetup, UrlForwardingStart } from 'src/plugins/url_forwardi
|
|||
import { HomePublicPluginSetup } from 'src/plugins/home/public';
|
||||
import { Start as InspectorPublicPluginStart } from 'src/plugins/inspector/public';
|
||||
import { DataPublicPluginStart, DataPublicPluginSetup, esFilters } from '../../data/public';
|
||||
import { SavedObjectLoader } from '../../saved_objects/public';
|
||||
import { SavedObjectLoader, SavedObjectsStart } from '../../saved_objects/public';
|
||||
import { createKbnUrlTracker } from '../../kibana_utils/public';
|
||||
import { DEFAULT_APP_CATEGORIES } from '../../../core/public';
|
||||
import { UrlGeneratorState } from '../../share/public';
|
||||
|
@ -141,6 +141,7 @@ export interface DiscoverStartPlugins {
|
|||
urlForwarding: UrlForwardingStart;
|
||||
inspector: InspectorPublicPluginStart;
|
||||
visualizations: VisualizationsStart;
|
||||
savedObjects: SavedObjectsStart;
|
||||
}
|
||||
|
||||
const innerAngularName = 'app/discover';
|
||||
|
@ -351,10 +352,7 @@ export class DiscoverPlugin
|
|||
urlGenerator: this.urlGenerator,
|
||||
savedSearchLoader: createSavedSearchesLoader({
|
||||
savedObjectsClient: core.savedObjects.client,
|
||||
indexPatterns: plugins.data.indexPatterns,
|
||||
search: plugins.data.search,
|
||||
chrome: core.chrome,
|
||||
overlays: core.overlays,
|
||||
savedObjects: plugins.savedObjects,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,16 +16,10 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import {
|
||||
createSavedObjectClass,
|
||||
SavedObject,
|
||||
SavedObjectKibanaServices,
|
||||
} from '../../../saved_objects/public';
|
||||
import { SavedObject, SavedObjectsStart } from '../../../saved_objects/public';
|
||||
|
||||
export function createSavedSearchClass(services: SavedObjectKibanaServices) {
|
||||
const SavedObjectClass = createSavedObjectClass(services);
|
||||
|
||||
class SavedSearch extends SavedObjectClass {
|
||||
export function createSavedSearchClass(savedObjects: SavedObjectsStart) {
|
||||
class SavedSearch extends savedObjects.SavedObjectClass {
|
||||
public static type: string = 'search';
|
||||
public static mapping = {
|
||||
title: 'text',
|
||||
|
@ -70,5 +64,5 @@ export function createSavedSearchClass(services: SavedObjectKibanaServices) {
|
|||
}
|
||||
}
|
||||
|
||||
return SavedSearch as new (id: string) => SavedObject;
|
||||
return (SavedSearch as unknown) as new (id: string) => SavedObject;
|
||||
}
|
||||
|
|
|
@ -17,12 +17,18 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { SavedObjectLoader, SavedObjectKibanaServices } from '../../../saved_objects/public';
|
||||
import { SavedObjectsClientContract } from 'kibana/public';
|
||||
import { SavedObjectLoader, SavedObjectsStart } from '../../../saved_objects/public';
|
||||
import { createSavedSearchClass } from './_saved_search';
|
||||
|
||||
export function createSavedSearchesLoader(services: SavedObjectKibanaServices) {
|
||||
const SavedSearchClass = createSavedSearchClass(services);
|
||||
const savedSearchLoader = new SavedObjectLoader(SavedSearchClass, services.savedObjectsClient);
|
||||
interface Services {
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
savedObjects: SavedObjectsStart;
|
||||
}
|
||||
|
||||
export function createSavedSearchesLoader({ savedObjectsClient, savedObjects }: Services) {
|
||||
const SavedSearchClass = createSavedSearchClass(savedObjects);
|
||||
const savedSearchLoader = new SavedObjectLoader(SavedSearchClass, savedObjectsClient);
|
||||
// Customize loader properties since adding an 's' on type doesn't work for type 'search' .
|
||||
savedSearchLoader.loaderProperties = {
|
||||
name: 'searches',
|
||||
|
|
|
@ -30,7 +30,6 @@ export {
|
|||
export { getSavedObjectFinder, SavedObjectFinderUi, SavedObjectMetaData } from './finder';
|
||||
export {
|
||||
SavedObjectLoader,
|
||||
createSavedObjectClass,
|
||||
checkForDuplicateTitle,
|
||||
saveWithConfirmation,
|
||||
isErrorNonFatal,
|
||||
|
|
34
src/plugins/saved_objects/public/mocks.ts
Normal file
34
src/plugins/saved_objects/public/mocks.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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 { SavedObjectsStart } from './plugin';
|
||||
|
||||
const createStartContract = (): SavedObjectsStart => {
|
||||
return {
|
||||
SavedObjectClass: jest.fn(),
|
||||
settings: {
|
||||
getPerPage: () => 20,
|
||||
getListingLimit: () => 100,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const savedObjectsPluginMock = {
|
||||
createStartContract,
|
||||
};
|
|
@ -23,9 +23,10 @@ import './index.scss';
|
|||
import { createSavedObjectClass } from './saved_object';
|
||||
import { DataPublicPluginStart } from '../../data/public';
|
||||
import { PER_PAGE_SETTING, LISTING_LIMIT_SETTING } from '../common';
|
||||
import { SavedObject } from './types';
|
||||
|
||||
export interface SavedObjectsStart {
|
||||
SavedObjectClass: any;
|
||||
SavedObjectClass: new (raw: Record<string, any>) => SavedObject;
|
||||
settings: {
|
||||
getPerPage: () => number;
|
||||
getListingLimit: () => number;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
"requiredBundles": [
|
||||
"kibanaLegacy",
|
||||
"kibanaUtils",
|
||||
"savedObjects",
|
||||
"visTypeTimelion"
|
||||
],
|
||||
"requiredPlugins": [
|
||||
|
@ -14,6 +13,7 @@
|
|||
"data",
|
||||
"navigation",
|
||||
"visTypeTimelion",
|
||||
"savedObjects",
|
||||
"kibanaLegacy"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import {
|
|||
createTopNavDirective,
|
||||
createTopNavHelper,
|
||||
} from '../../kibana_legacy/public';
|
||||
import { TimelionPluginDependencies } from './plugin';
|
||||
import { TimelionPluginStartDependencies } from './plugin';
|
||||
import { DataPublicPluginStart } from '../../data/public';
|
||||
// @ts-ignore
|
||||
import { initTimelionApp } from './app';
|
||||
|
@ -50,7 +50,7 @@ export interface RenderDeps {
|
|||
pluginInitializerContext: PluginInitializerContext;
|
||||
mountParams: AppMountParameters;
|
||||
core: CoreStart;
|
||||
plugins: TimelionPluginDependencies;
|
||||
plugins: TimelionPluginStartDependencies;
|
||||
timelionPanels: Map<string, Panel>;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ function createLocalIconModule() {
|
|||
.directive('icon', (reactDirective) => reactDirective(EuiIcon));
|
||||
}
|
||||
|
||||
function createLocalTopNavModule(navigation: TimelionPluginDependencies['navigation']) {
|
||||
function createLocalTopNavModule(navigation: TimelionPluginStartDependencies['navigation']) {
|
||||
angular
|
||||
.module('app/timelion/TopNav', ['react'])
|
||||
.directive('kbnTopNav', createTopNavDirective)
|
||||
|
|
|
@ -36,20 +36,29 @@ import { createKbnUrlTracker } from '../../kibana_utils/public';
|
|||
import { DataPublicPluginStart, esFilters, DataPublicPluginSetup } from '../../data/public';
|
||||
import { NavigationPublicPluginStart } from '../../navigation/public';
|
||||
import { VisualizationsStart } from '../../visualizations/public';
|
||||
import { SavedObjectsStart } from '../../saved_objects/public';
|
||||
import {
|
||||
VisTypeTimelionPluginStart,
|
||||
VisTypeTimelionPluginSetup,
|
||||
} from '../../vis_type_timelion/public';
|
||||
|
||||
export interface TimelionPluginDependencies {
|
||||
export interface TimelionPluginSetupDependencies {
|
||||
data: DataPublicPluginSetup;
|
||||
visTypeTimelion: VisTypeTimelionPluginSetup;
|
||||
}
|
||||
|
||||
export interface TimelionPluginStartDependencies {
|
||||
data: DataPublicPluginStart;
|
||||
navigation: NavigationPublicPluginStart;
|
||||
visualizations: VisualizationsStart;
|
||||
visTypeTimelion: VisTypeTimelionPluginStart;
|
||||
savedObjects: SavedObjectsStart;
|
||||
kibanaLegacy: KibanaLegacyStart;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export class TimelionPlugin implements Plugin<void, void> {
|
||||
export class TimelionPlugin
|
||||
implements Plugin<void, void, TimelionPluginSetupDependencies, TimelionPluginStartDependencies> {
|
||||
initializerContext: PluginInitializerContext;
|
||||
private appStateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
|
||||
private stopUrlTracking: (() => void) | undefined = undefined;
|
||||
|
@ -60,7 +69,7 @@ export class TimelionPlugin implements Plugin<void, void> {
|
|||
}
|
||||
|
||||
public setup(
|
||||
core: CoreSetup,
|
||||
core: CoreSetup<TimelionPluginStartDependencies>,
|
||||
{
|
||||
data,
|
||||
visTypeTimelion,
|
||||
|
@ -122,7 +131,7 @@ export class TimelionPlugin implements Plugin<void, void> {
|
|||
pluginInitializerContext: this.initializerContext,
|
||||
timelionPanels,
|
||||
core: coreStart,
|
||||
plugins: pluginsStart as TimelionPluginDependencies,
|
||||
plugins: pluginsStart,
|
||||
});
|
||||
return () => {
|
||||
unlistenParentHistory();
|
||||
|
|
|
@ -18,16 +18,11 @@
|
|||
*/
|
||||
|
||||
import { IUiSettingsClient } from 'kibana/public';
|
||||
import { createSavedObjectClass, SavedObjectKibanaServices } from '../../../saved_objects/public';
|
||||
import { SavedObjectsStart } from '../../../saved_objects/public';
|
||||
|
||||
// Used only by the savedSheets service, usually no reason to change this
|
||||
export function createSavedSheetClass(
|
||||
services: SavedObjectKibanaServices,
|
||||
config: IUiSettingsClient
|
||||
) {
|
||||
const SavedObjectClass = createSavedObjectClass(services);
|
||||
|
||||
class SavedSheet extends SavedObjectClass {
|
||||
export function createSavedSheetClass(savedObjects: SavedObjectsStart, config: IUiSettingsClient) {
|
||||
class SavedSheet extends savedObjects.SavedObjectClass {
|
||||
static type = 'timelion-sheet';
|
||||
|
||||
// if type:sheet has no mapping, we push this mapping into ES
|
||||
|
|
|
@ -23,15 +23,7 @@ import { RenderDeps } from '../application';
|
|||
|
||||
export function initSavedSheetService(app: angular.IModule, deps: RenderDeps) {
|
||||
const savedObjectsClient = deps.core.savedObjects.client;
|
||||
const services = {
|
||||
savedObjectsClient,
|
||||
indexPatterns: deps.plugins.data.indexPatterns,
|
||||
search: deps.plugins.data.search,
|
||||
chrome: deps.core.chrome,
|
||||
overlays: deps.core.overlays,
|
||||
};
|
||||
|
||||
const SavedSheet = createSavedSheetClass(services, deps.core.uiSettings);
|
||||
const SavedSheet = createSavedSheetClass(deps.plugins.savedObjects, deps.core.uiSettings);
|
||||
|
||||
const savedSheetLoader = new SavedObjectLoader(SavedSheet, savedObjectsClient);
|
||||
savedSheetLoader.urlFor = (id) => `#/${encodeURIComponent(id)}`;
|
||||
|
|
|
@ -3,7 +3,14 @@
|
|||
"version": "kibana",
|
||||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["data", "expressions", "uiActions", "embeddable", "inspector" ],
|
||||
"requiredPlugins": [
|
||||
"data",
|
||||
"expressions",
|
||||
"uiActions",
|
||||
"embeddable",
|
||||
"inspector",
|
||||
"savedObjects"
|
||||
],
|
||||
"optionalPlugins": ["usageCollection"],
|
||||
"requiredBundles": ["kibanaUtils", "discover", "savedObjects"]
|
||||
"requiredBundles": ["kibanaUtils", "discover"]
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import { usageCollectionPluginMock } from '../../../plugins/usage_collection/pub
|
|||
import { uiActionsPluginMock } from '../../../plugins/ui_actions/public/mocks';
|
||||
import { inspectorPluginMock } from '../../../plugins/inspector/public/mocks';
|
||||
import { dashboardPluginMock } from '../../../plugins/dashboard/public/mocks';
|
||||
import { savedObjectsPluginMock } from '../../../plugins/saved_objects/public/mocks';
|
||||
|
||||
const createSetupContract = (): VisualizationsSetup => ({
|
||||
createBaseVisualization: jest.fn(),
|
||||
|
@ -73,6 +74,7 @@ const createInstance = async () => {
|
|||
dashboard: dashboardPluginMock.createStartContract(),
|
||||
getAttributeService: jest.fn(),
|
||||
savedObjectsClient: coreMock.createStart().savedObjects.client,
|
||||
savedObjects: savedObjectsPluginMock.createStartContract(),
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
@ -78,6 +78,7 @@ import {
|
|||
} from './saved_visualizations/_saved_vis';
|
||||
import { createSavedSearchesLoader } from '../../discover/public';
|
||||
import { DashboardStart } from '../../dashboard/public';
|
||||
import { SavedObjectsStart } from '../../saved_objects/public';
|
||||
|
||||
/**
|
||||
* Interface for this plugin's returned setup/start contracts.
|
||||
|
@ -113,6 +114,7 @@ export interface VisualizationsStartDeps {
|
|||
application: ApplicationStart;
|
||||
dashboard: DashboardStart;
|
||||
getAttributeService: EmbeddableStart['getAttributeService'];
|
||||
savedObjects: SavedObjectsStart;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
}
|
||||
|
||||
|
@ -160,7 +162,7 @@ export class VisualizationsPlugin
|
|||
|
||||
public start(
|
||||
core: CoreStart,
|
||||
{ data, expressions, uiActions, embeddable, dashboard }: VisualizationsStartDeps
|
||||
{ data, expressions, uiActions, embeddable, dashboard, savedObjects }: VisualizationsStartDeps
|
||||
): VisualizationsStart {
|
||||
const types = this.types.start();
|
||||
setI18n(core.i18n);
|
||||
|
@ -182,18 +184,13 @@ export class VisualizationsPlugin
|
|||
const savedVisualizationsLoader = createSavedVisLoader({
|
||||
savedObjectsClient: core.savedObjects.client,
|
||||
indexPatterns: data.indexPatterns,
|
||||
search: data.search,
|
||||
chrome: core.chrome,
|
||||
overlays: core.overlays,
|
||||
savedObjects,
|
||||
visualizationTypes: types,
|
||||
});
|
||||
setSavedVisualizationsLoader(savedVisualizationsLoader);
|
||||
const savedSearchLoader = createSavedSearchesLoader({
|
||||
savedObjectsClient: core.savedObjects.client,
|
||||
indexPatterns: data.indexPatterns,
|
||||
search: data.search,
|
||||
chrome: core.chrome,
|
||||
overlays: core.overlays,
|
||||
savedObjects,
|
||||
});
|
||||
setSavedSearchLoader(savedSearchLoader);
|
||||
return {
|
||||
|
|
|
@ -24,17 +24,20 @@
|
|||
*
|
||||
* NOTE: It's a type of SavedObject, but specific to visualizations.
|
||||
*/
|
||||
import {
|
||||
createSavedObjectClass,
|
||||
SavedObject,
|
||||
SavedObjectKibanaServices,
|
||||
} from '../../../../plugins/saved_objects/public';
|
||||
import { SavedObjectsStart, SavedObject } from '../../../../plugins/saved_objects/public';
|
||||
// @ts-ignore
|
||||
import { updateOldState } from '../legacy/vis_update_state';
|
||||
import { extractReferences, injectReferences } from './saved_visualization_references';
|
||||
import { IIndexPattern } from '../../../../plugins/data/public';
|
||||
import { IIndexPattern, IndexPatternsContract } from '../../../../plugins/data/public';
|
||||
import { ISavedVis, SerializedVis } from '../types';
|
||||
import { createSavedSearchesLoader } from '../../../discover/public';
|
||||
import { SavedObjectsClientContract } from '../../../../core/public';
|
||||
|
||||
export interface SavedVisServices {
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
savedObjects: SavedObjectsStart;
|
||||
indexPatterns: IndexPatternsContract;
|
||||
}
|
||||
|
||||
export const convertToSerializedVis = (savedVis: ISavedVis): SerializedVis => {
|
||||
const { id, title, description, visState, uiStateJSON, searchSourceFields } = savedVis;
|
||||
|
@ -73,11 +76,10 @@ export const convertFromSerializedVis = (vis: SerializedVis): ISavedVis => {
|
|||
};
|
||||
};
|
||||
|
||||
export function createSavedVisClass(services: SavedObjectKibanaServices) {
|
||||
const SavedObjectClass = createSavedObjectClass(services);
|
||||
export function createSavedVisClass(services: SavedVisServices) {
|
||||
const savedSearch = createSavedSearchesLoader(services);
|
||||
|
||||
class SavedVis extends SavedObjectClass {
|
||||
class SavedVis extends services.savedObjects.SavedObjectClass {
|
||||
public static type: string = 'visualization';
|
||||
public static mapping: Record<string, string> = {
|
||||
title: 'text',
|
||||
|
@ -130,5 +132,5 @@ export function createSavedVisClass(services: SavedObjectKibanaServices) {
|
|||
}
|
||||
}
|
||||
|
||||
return SavedVis as new (opts: Record<string, unknown> | string) => SavedObject;
|
||||
return (SavedVis as unknown) as new (opts: Record<string, unknown> | string) => SavedObject;
|
||||
}
|
||||
|
|
|
@ -16,19 +16,16 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import {
|
||||
SavedObjectLoader,
|
||||
SavedObjectKibanaServices,
|
||||
} from '../../../../plugins/saved_objects/public';
|
||||
import { SavedObjectLoader } from '../../../../plugins/saved_objects/public';
|
||||
import { findListItems } from './find_list_items';
|
||||
import { createSavedVisClass } from './_saved_vis';
|
||||
import { createSavedVisClass, SavedVisServices } from './_saved_vis';
|
||||
import { TypesStart } from '../vis_types';
|
||||
|
||||
export interface SavedObjectKibanaServicesWithVisualizations extends SavedObjectKibanaServices {
|
||||
export interface SavedVisServicesWithVisualizations extends SavedVisServices {
|
||||
visualizationTypes: TypesStart;
|
||||
}
|
||||
export type SavedVisualizationsLoader = ReturnType<typeof createSavedVisLoader>;
|
||||
export function createSavedVisLoader(services: SavedObjectKibanaServicesWithVisualizations) {
|
||||
export function createSavedVisLoader(services: SavedVisServicesWithVisualizations) {
|
||||
const { savedObjectsClient, visualizationTypes } = services;
|
||||
|
||||
class SavedObjectLoaderVisualize extends SavedObjectLoader {
|
||||
|
|
|
@ -35,7 +35,12 @@ const createVisualizeEmbeddableAndLinkSavedSearch = async (
|
|||
vis: Vis,
|
||||
visualizeServices: VisualizeServices
|
||||
) => {
|
||||
const { chrome, data, overlays, createVisEmbeddableFromObject, savedObjects } = visualizeServices;
|
||||
const {
|
||||
data,
|
||||
createVisEmbeddableFromObject,
|
||||
savedObjects,
|
||||
savedObjectsPublic,
|
||||
} = visualizeServices;
|
||||
const embeddableHandler = (await createVisEmbeddableFromObject(vis, {
|
||||
timeRange: data.query.timefilter.timefilter.getTime(),
|
||||
filters: data.query.filterManager.getFilters(),
|
||||
|
@ -55,10 +60,7 @@ const createVisualizeEmbeddableAndLinkSavedSearch = async (
|
|||
if (vis.data.savedSearchId) {
|
||||
savedSearch = await createSavedSearchesLoader({
|
||||
savedObjectsClient: savedObjects.client,
|
||||
indexPatterns: data.indexPatterns,
|
||||
search: data.search,
|
||||
chrome,
|
||||
overlays,
|
||||
savedObjects: savedObjectsPublic,
|
||||
}).get(vis.data.savedSearchId);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,16 +15,12 @@
|
|||
"embeddable",
|
||||
"mapsLegacy",
|
||||
"usageCollection",
|
||||
"savedObjects",
|
||||
"share"
|
||||
],
|
||||
"optionalPlugins": ["home"],
|
||||
"ui": true,
|
||||
"server": true,
|
||||
"extraPublicDirs": ["common/constants"],
|
||||
"requiredBundles": [
|
||||
"kibanaReact",
|
||||
"kibanaUtils",
|
||||
"savedObjects",
|
||||
"home"
|
||||
]
|
||||
"requiredBundles": ["kibanaReact", "kibanaUtils", "home"]
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ export const getVisualizeCapabilities = () => coreStart.application.capabilities
|
|||
export const getDocLinks = () => coreStart.docLinks;
|
||||
export const getCoreOverlays = () => coreStart.overlays;
|
||||
export const getData = () => pluginsStart.data;
|
||||
export const getSavedObjects = () => pluginsStart.savedObjects;
|
||||
export const getUiActions = () => pluginsStart.uiActions;
|
||||
export const getCore = () => coreStart;
|
||||
export const getNavigation = () => pluginsStart.navigation;
|
||||
|
|
|
@ -50,6 +50,7 @@ import { MapsLegacyConfig } from '../../../../src/plugins/maps_legacy/config';
|
|||
import { DataPublicPluginStart } from '../../../../src/plugins/data/public';
|
||||
import { LicensingPluginSetup, LicensingPluginStart } from '../../licensing/public';
|
||||
import { StartContract as FileUploadStartContract } from '../../file_upload/public';
|
||||
import { SavedObjectsStart } from '../../../../src/plugins/saved_objects/public';
|
||||
import { registerLicensedFeatures, setLicensingPluginStart } from './licensed_features';
|
||||
|
||||
export interface MapsPluginSetupDependencies {
|
||||
|
@ -71,6 +72,7 @@ export interface MapsPluginStartDependencies {
|
|||
navigation: NavigationPublicPluginStart;
|
||||
uiActions: UiActionsStart;
|
||||
share: SharePluginStart;
|
||||
savedObjects: SavedObjectsStart;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,23 +7,10 @@
|
|||
import _ from 'lodash';
|
||||
import { createSavedGisMapClass } from './saved_gis_map';
|
||||
import { SavedObjectLoader } from '../../../../../../../src/plugins/saved_objects/public';
|
||||
import {
|
||||
getCoreChrome,
|
||||
getSavedObjectsClient,
|
||||
getIndexPatternService,
|
||||
getCoreOverlays,
|
||||
getData,
|
||||
} from '../../../kibana_services';
|
||||
import { getSavedObjects, getSavedObjectsClient } from '../../../kibana_services';
|
||||
|
||||
export const getMapsSavedObjectLoader = _.once(function () {
|
||||
const services = {
|
||||
savedObjectsClient: getSavedObjectsClient(),
|
||||
indexPatterns: getIndexPatternService(),
|
||||
search: getData().search,
|
||||
chrome: getCoreChrome(),
|
||||
overlays: getCoreOverlays(),
|
||||
};
|
||||
const SavedGisMap = createSavedGisMapClass(services);
|
||||
const SavedGisMap = createSavedGisMapClass(getSavedObjects());
|
||||
|
||||
return new SavedObjectLoader(SavedGisMap, getSavedObjectsClient());
|
||||
});
|
||||
|
|
|
@ -8,9 +8,8 @@ import _ from 'lodash';
|
|||
import { SavedObjectReference } from 'kibana/public';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import {
|
||||
createSavedObjectClass,
|
||||
SavedObjectsStart,
|
||||
SavedObject,
|
||||
SavedObjectKibanaServices,
|
||||
} from '../../../../../../../src/plugins/saved_objects/public';
|
||||
import {
|
||||
getTimeFilters,
|
||||
|
@ -40,10 +39,8 @@ export interface ISavedGisMap extends SavedObject {
|
|||
syncWithStore(): void;
|
||||
}
|
||||
|
||||
export function createSavedGisMapClass(services: SavedObjectKibanaServices) {
|
||||
const SavedObjectClass = createSavedObjectClass(services);
|
||||
|
||||
class SavedGisMap extends SavedObjectClass implements ISavedGisMap {
|
||||
export function createSavedGisMapClass(savedObjects: SavedObjectsStart) {
|
||||
class SavedGisMap extends savedObjects.SavedObjectClass implements ISavedGisMap {
|
||||
public static type = MAP_SAVED_OBJECT_TYPE;
|
||||
|
||||
// Mappings are used to place object properties into saved object _source
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
"home",
|
||||
"licensing",
|
||||
"management",
|
||||
"features"
|
||||
"features",
|
||||
"savedObjects"
|
||||
],
|
||||
"optionalPlugins": [
|
||||
"security",
|
||||
|
@ -20,7 +21,6 @@
|
|||
"discover",
|
||||
"kibanaUtils",
|
||||
"kibanaReact",
|
||||
"savedObjects",
|
||||
"ml"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { CoreSetup, CoreStart } from 'src/core/public';
|
||||
import { DataPublicPluginStart } from 'src/plugins/data/public';
|
||||
import { SavedObjectsStart } from 'src/plugins/saved_objects/public';
|
||||
import { ScopedHistory } from 'kibana/public';
|
||||
|
||||
import { useKibana } from '../../../../../src/plugins/kibana_react/public';
|
||||
|
@ -25,6 +26,7 @@ export interface AppDependencies {
|
|||
storage: Storage;
|
||||
overlays: CoreStart['overlays'];
|
||||
history: ScopedHistory;
|
||||
savedObjectsPlugin: SavedObjectsStart;
|
||||
ml: GetMlSharedImportsReturnType;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,7 @@ export const useSearchItems = (defaultSavedObjectId: string | undefined) => {
|
|||
const savedObjectsClient = appDeps.savedObjects.client;
|
||||
const savedSearches = createSavedSearchesLoader({
|
||||
savedObjectsClient,
|
||||
indexPatterns,
|
||||
search: appDeps.data.search,
|
||||
chrome: appDeps.chrome,
|
||||
overlays: appDeps.overlays,
|
||||
savedObjects: appDeps.savedObjectsPlugin,
|
||||
});
|
||||
|
||||
const [searchItems, setSearchItems] = useState<SearchItems | undefined>(undefined);
|
||||
|
|
|
@ -48,6 +48,7 @@ export async function mountManagementSection(
|
|||
storage: localStorage,
|
||||
uiSettings,
|
||||
history,
|
||||
savedObjectsPlugin: plugins.savedObjects,
|
||||
ml: await getMlSharedImports(),
|
||||
};
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import { i18n as kbnI18n } from '@kbn/i18n';
|
|||
import { CoreSetup } from 'src/core/public';
|
||||
import { DataPublicPluginStart } from 'src/plugins/data/public';
|
||||
import { HomePublicPluginSetup } from 'src/plugins/home/public';
|
||||
import { SavedObjectsStart } from 'src/plugins/saved_objects/public';
|
||||
import { ManagementSetup } from '../../../../src/plugins/management/public';
|
||||
import { registerFeature } from './register_feature';
|
||||
|
||||
|
@ -15,6 +16,7 @@ export interface PluginsDependencies {
|
|||
data: DataPublicPluginStart;
|
||||
management: ManagementSetup;
|
||||
home: HomePublicPluginSetup;
|
||||
savedObjects: SavedObjectsStart;
|
||||
}
|
||||
|
||||
export class TransformUiPlugin {
|
||||
|
|
Loading…
Reference in a new issue