mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Move lens saved object setup to Kibana platform (#61157)
This commit is contained in:
parent
11bcfae3a7
commit
b8e3ccb356
4 changed files with 68 additions and 53 deletions
|
@ -7,12 +7,7 @@
|
|||
import * as Joi from 'joi';
|
||||
import { resolve } from 'path';
|
||||
import { LegacyPluginInitializer } from 'src/legacy/types';
|
||||
import mappings from './mappings.json';
|
||||
import {
|
||||
PLUGIN_ID,
|
||||
getEditPath,
|
||||
NOT_INTERNATIONALIZED_PRODUCT_NAME,
|
||||
} from '../../../plugins/lens/common';
|
||||
import { PLUGIN_ID, NOT_INTERNATIONALIZED_PRODUCT_NAME } from '../../../plugins/lens/common';
|
||||
|
||||
export const lens: LegacyPluginInitializer = kibana => {
|
||||
return new kibana.Plugin({
|
||||
|
@ -32,18 +27,6 @@ export const lens: LegacyPluginInitializer = kibana => {
|
|||
visualize: [`plugins/${PLUGIN_ID}/legacy`],
|
||||
embeddableFactories: [`plugins/${PLUGIN_ID}/legacy`],
|
||||
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
|
||||
mappings,
|
||||
savedObjectsManagement: {
|
||||
lens: {
|
||||
defaultSearchField: 'title',
|
||||
isImportableAndExportable: true,
|
||||
getTitle: (obj: { attributes: { title: string } }) => obj.attributes.title,
|
||||
getInAppUrl: (obj: { id: string }) => ({
|
||||
path: getEditPath(obj.id),
|
||||
uiCapabilitiesPath: 'lens.show',
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
config: () => {
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
"lens": {
|
||||
"properties": {
|
||||
"title": {
|
||||
"type": "text"
|
||||
},
|
||||
"visualizationType": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"state": {
|
||||
"type": "flattened"
|
||||
},
|
||||
"expression": {
|
||||
"index": false,
|
||||
"type": "keyword"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lens-ui-telemetry": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"type": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"date": {
|
||||
"type": "date"
|
||||
},
|
||||
"count": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import {
|
|||
initializeLensTelemetry,
|
||||
scheduleLensTelemetry,
|
||||
} from './usage';
|
||||
import { setupSavedObjects } from './saved_objects';
|
||||
|
||||
export interface PluginSetupContract {
|
||||
usageCollection?: UsageCollectionSetup;
|
||||
|
@ -33,6 +34,7 @@ export class LensServerPlugin implements Plugin<{}, {}, {}, {}> {
|
|||
this.telemetryLogger = initializerContext.logger.get('telemetry');
|
||||
}
|
||||
setup(core: CoreSetup<PluginStartContract>, plugins: PluginSetupContract) {
|
||||
setupSavedObjects(core);
|
||||
setupRoutes(core);
|
||||
if (plugins.usageCollection && plugins.taskManager) {
|
||||
registerLensUsageCollector(
|
||||
|
|
65
x-pack/plugins/lens/server/saved_objects.ts
Normal file
65
x-pack/plugins/lens/server/saved_objects.ts
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { CoreSetup } from 'kibana/server';
|
||||
import { getEditPath } from '../common';
|
||||
|
||||
export function setupSavedObjects(core: CoreSetup) {
|
||||
core.savedObjects.registerType({
|
||||
name: 'lens',
|
||||
hidden: false,
|
||||
namespaceAgnostic: false,
|
||||
management: {
|
||||
icon: 'lensApp',
|
||||
defaultSearchField: 'title',
|
||||
importableAndExportable: true,
|
||||
getTitle: (obj: { attributes: { title: string } }) => obj.attributes.title,
|
||||
getInAppUrl: (obj: { id: string }) => ({
|
||||
path: getEditPath(obj.id),
|
||||
uiCapabilitiesPath: 'visualize.show',
|
||||
}),
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
title: {
|
||||
type: 'text',
|
||||
},
|
||||
visualizationType: {
|
||||
type: 'keyword',
|
||||
},
|
||||
state: {
|
||||
type: 'flattened',
|
||||
},
|
||||
expression: {
|
||||
index: false,
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
core.savedObjects.registerType({
|
||||
name: 'lens-ui-telemetry',
|
||||
hidden: false,
|
||||
namespaceAgnostic: false,
|
||||
mappings: {
|
||||
properties: {
|
||||
name: {
|
||||
type: 'keyword',
|
||||
},
|
||||
type: {
|
||||
type: 'keyword',
|
||||
},
|
||||
date: {
|
||||
type: 'date',
|
||||
},
|
||||
count: {
|
||||
type: 'integer',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue