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

Move Lens saved object setup to Kibana platform #61157

Merged
merged 1 commit into from
Mar 25, 2020
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
19 changes: 1 addition & 18 deletions x-pack/legacy/plugins/lens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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: () => {
Expand Down
35 changes: 0 additions & 35 deletions x-pack/legacy/plugins/lens/mappings.json

This file was deleted.

2 changes: 2 additions & 0 deletions x-pack/plugins/lens/server/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
initializeLensTelemetry,
scheduleLensTelemetry,
} from './usage';
import { setupSavedObjects } from './saved_objects';

export interface PluginSetupContract {
usageCollection?: UsageCollectionSetup;
Expand All @@ -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(
Expand Down
65 changes: 65 additions & 0 deletions x-pack/plugins/lens/server/saved_objects.ts
Original file line number Diff line number Diff line change
@@ -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',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ We used before this move lens.show here, which was wrong, since there is no lens.show uiCapabilities. We decided that time to use the visualize uiCapability for Lens, it seemed just this place always returned the wrong capability.

}),
},
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',
},
},
},
});
}