don't register any features in LP. (#65611)

* don't register any features in LP. breaks features value reading in KP

* move test plugin to NP

* fix mappings

* update docs

* migrate another test

* use contstants file for BWC with original code

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Mikhail Shustov 2020-05-11 18:43:45 +02:00 committed by GitHub
parent a1a157dc87
commit 4912153ce6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 215 additions and 175 deletions

View file

@ -10,6 +10,7 @@
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
};
};
```

View file

@ -17,7 +17,7 @@ export interface SavedObjectsCoreFieldMapping
| Property | Type | Description |
| --- | --- | --- |
| [enabled](./kibana-plugin-core-server.savedobjectscorefieldmapping.enabled.md) | <code>boolean</code> | |
| [fields](./kibana-plugin-core-server.savedobjectscorefieldmapping.fields.md) | <code>{</code><br/><code> [subfield: string]: {</code><br/><code> type: string;</code><br/><code> };</code><br/><code> }</code> | |
| [fields](./kibana-plugin-core-server.savedobjectscorefieldmapping.fields.md) | <code>{</code><br/><code> [subfield: string]: {</code><br/><code> type: string;</code><br/><code> ignore_above?: number;</code><br/><code> };</code><br/><code> }</code> | |
| [index](./kibana-plugin-core-server.savedobjectscorefieldmapping.index.md) | <code>boolean</code> | |
| [null\_value](./kibana-plugin-core-server.savedobjectscorefieldmapping.null_value.md) | <code>number &#124; boolean &#124; string</code> | |
| [type](./kibana-plugin-core-server.savedobjectscorefieldmapping.type.md) | <code>string</code> | |

View file

@ -137,6 +137,7 @@ export interface SavedObjectsCoreFieldMapping {
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
};
};
}

View file

@ -1884,6 +1884,7 @@ export interface SavedObjectsCoreFieldMapping {
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
};
};
// (undocumented)

View file

@ -19,42 +19,10 @@ import { emsBoundariesSpecProvider } from './tutorials/ems';
export class MapPlugin {
setup(core, plugins, __LEGACY) {
const { featuresPlugin, home, licensing, usageCollection, mapsLegacy } = plugins;
const { home, licensing, usageCollection, mapsLegacy } = plugins;
let routesInitialized = false;
const mapConfig = mapsLegacy.config;
featuresPlugin.registerFeature({
id: APP_ID,
name: i18n.translate('xpack.maps.featureRegistry.mapsFeatureName', {
defaultMessage: 'Maps',
}),
order: 600,
icon: APP_ICON,
navLinkId: APP_ID,
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
privileges: {
all: {
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
savedObject: {
all: [MAP_SAVED_OBJECT_TYPE, 'query'],
read: ['index-pattern'],
},
ui: ['save', 'show', 'saveQuery'],
},
read: {
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
savedObject: {
all: [],
read: [MAP_SAVED_OBJECT_TYPE, 'index-pattern', 'query'],
},
ui: ['show'],
},
},
});
licensing.license$.subscribe(license => {
const { state } = license.check('maps', 'basic');
if (state === 'valid' && !routesInitialized) {

View file

@ -22,8 +22,7 @@ export function setupXPackMain(server) {
server.ext('onPreResponse', (request, h) => injectXPackInfoSignature(info, request, h));
const { registerFeature, getFeatures } = server.newPlatform.setup.plugins.features;
server.expose('registerFeature', registerFeature);
const { getFeatures } = server.newPlatform.setup.plugins.features;
server.expose('getFeatures', getFeatures);
const setPluginStatus = () => {

View file

@ -12,5 +12,4 @@ export { XPackFeature } from './lib/xpack_info';
export interface XPackMainPlugin {
info: XPackInfo;
getFeatures(): Feature[];
registerFeature(feature: FeatureConfig): void;
}

View file

@ -4,8 +4,9 @@
"kibanaVersion": "kibana",
"configPath": ["xpack", "maps"],
"requiredPlugins": [
"inspector",
"licensing",
"features",
"inspector",
"home",
"data",
"fileUpload",
@ -15,5 +16,6 @@
"embeddable",
"mapsLegacy"
],
"ui": true
"ui": true,
"server": true
}

View file

@ -3,3 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { PluginInitializerContext } from 'src/core/server';
import { MapsPlugin } from './plugin';
export const plugin = (initializerContext: PluginInitializerContext) =>
new MapsPlugin(initializerContext);

View file

@ -0,0 +1,52 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/server';
import { PluginSetupContract as FeaturesPluginSetupContract } from '../../features/server';
import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE } from '../common/constants';
interface SetupDeps {
features: FeaturesPluginSetupContract;
}
export class MapsPlugin implements Plugin {
constructor(initializerContext: PluginInitializerContext) {}
setup(core: CoreSetup, plugins: SetupDeps) {
plugins.features.registerFeature({
id: APP_ID,
name: i18n.translate('xpack.maps.featureRegistry.mapsFeatureName', {
defaultMessage: 'Maps',
}),
order: 600,
icon: APP_ICON,
navLinkId: APP_ID,
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
privileges: {
all: {
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
savedObject: {
all: [MAP_SAVED_OBJECT_TYPE, 'query'],
read: ['index-pattern'],
},
ui: ['save', 'show', 'saveQuery'],
},
read: {
app: [APP_ID, 'kibana'],
catalogue: [APP_ID],
savedObject: {
all: [],
read: [MAP_SAVED_OBJECT_TYPE, 'index-pattern', 'query'],
},
ui: ['show'],
},
},
});
}
start(core: CoreStart) {}
}

View file

@ -1,55 +0,0 @@
/*
* 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 mappings from './mappings.json';
export default function(kibana) {
return new kibana.Plugin({
require: ['kibana', 'elasticsearch', 'xpack_main'],
name: 'namespace_agnostic_type_plugin',
uiExports: {
savedObjectsManagement: {
globaltype: {
isImportableAndExportable: true,
},
},
savedObjectSchemas: {
globaltype: {
isNamespaceAgnostic: true,
},
},
mappings,
},
config() {},
init(server) {
server.plugins.xpack_main.registerFeature({
id: 'namespace_agnostic_type_plugin',
name: 'namespace_agnostic_type_plugin',
icon: 'upArrow',
navLinkId: 'namespace_agnostic_type_plugin',
app: [],
privileges: {
all: {
savedObject: {
all: ['globaltype'],
read: [],
},
ui: [],
},
read: {
savedObject: {
all: [],
read: ['globaltype'],
},
ui: [],
},
},
});
},
});
}

View file

@ -0,0 +1,8 @@
{
"id": "namespace_agnostic_type_plugin",
"version": "1.0.0",
"kibanaVersion": "kibana",
"requiredPlugins": ["features"],
"server": true,
"ui": false
}

View file

@ -1,15 +0,0 @@
{
"globaltype": {
"properties": {
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 2048
}
}
}
}
}
}

View file

@ -1,7 +0,0 @@
{
"name": "namespace_agnostic_type_plugin",
"version": "0.0.0",
"kibana": {
"version": "kibana"
}
}

View file

@ -0,0 +1,64 @@
/*
* 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, Plugin } from 'src/core/server';
import { PluginSetupContract as FeaturesPluginSetupContract } from '../../../../../../plugins/features/server';
export const plugin = () => new NamespaceAgnosticTypePlugin();
interface SetupDeps {
features: FeaturesPluginSetupContract;
}
class NamespaceAgnosticTypePlugin implements Plugin {
setup(core: CoreSetup, plugins: SetupDeps) {
core.savedObjects.registerType({
name: 'globaltype',
hidden: false,
namespaceType: 'agnostic',
management: {
importableAndExportable: true,
},
mappings: {
properties: {
title: {
type: 'text',
fields: {
keyword: {
type: 'keyword',
ignore_above: 2048,
},
},
},
},
},
});
plugins.features.registerFeature({
id: 'namespace_agnostic_type_plugin',
name: 'namespace_agnostic_type_plugin',
icon: 'upArrow',
navLinkId: 'namespace_agnostic_type_plugin',
app: [],
privileges: {
all: {
savedObject: {
all: ['globaltype'],
read: [],
},
ui: [],
},
read: {
savedObject: {
all: [],
read: ['globaltype'],
},
ui: [],
},
},
});
}
start() {}
}

View file

@ -1,52 +0,0 @@
/*
* 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.
*/
export default function(kibana) {
return new kibana.Plugin({
require: ['kibana', 'elasticsearch', 'xpack_main'],
name: 'foo',
uiExports: {
app: {
title: 'Foo',
order: 1000,
euiIconType: 'uiArray',
description: 'Foo app',
main: 'plugins/foo_plugin/app',
},
},
init(server) {
server.plugins.xpack_main.registerFeature({
id: 'foo',
name: 'Foo',
icon: 'upArrow',
navLinkId: 'foo_plugin',
app: ['kibana'],
catalogue: ['foo'],
privileges: {
all: {
app: ['kibana'],
catalogue: ['foo'],
savedObject: {
all: ['foo'],
read: ['index-pattern'],
},
ui: ['create', 'edit', 'delete', 'show'],
},
read: {
app: ['kibana'],
catalogue: ['foo'],
savedObject: {
all: [],
read: ['foo', 'index-pattern'],
},
ui: ['show'],
},
},
});
},
});
}

View file

@ -0,0 +1,8 @@
{
"id": "foo_plugin",
"version": "1.0.0",
"kibanaVersion": "kibana",
"requiredPlugins": ["features"],
"server": true,
"ui": true
}

View file

@ -1,7 +0,0 @@
{
"name": "foo_plugin",
"version": "0.0.0",
"kibana": {
"version": "kibana"
}
}

View file

@ -0,0 +1,21 @@
/*
* 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, Plugin } from 'src/core/public';
export const plugin = () => new FooPlugin();
class FooPlugin implements Plugin {
setup(core: CoreSetup) {
core.application.register({
id: 'foo',
title: 'Foo app',
euiIconType: 'uiArray',
mount() {
return () => null;
},
});
}
start() {}
}

View file

@ -0,0 +1,47 @@
/*
* 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, Plugin } from 'src/core/server';
import { PluginSetupContract as FeaturesPluginSetupContract } from '../../../../../../../plugins/features/server';
export const plugin = () => new FooPlugin();
interface SetupDeps {
features: FeaturesPluginSetupContract;
}
class FooPlugin implements Plugin {
setup(core: CoreSetup, plugins: SetupDeps) {
plugins.features.registerFeature({
id: 'foo',
name: 'Foo',
icon: 'upArrow',
navLinkId: 'foo_plugin',
app: ['kibana'],
catalogue: ['foo'],
privileges: {
all: {
app: ['kibana'],
catalogue: ['foo'],
savedObject: {
all: ['foo'],
read: ['index-pattern'],
},
ui: ['create', 'edit', 'delete', 'show'],
},
read: {
app: ['kibana'],
catalogue: ['foo'],
savedObject: {
all: [],
read: ['foo', 'index-pattern'],
},
ui: ['show'],
},
},
});
}
start() {}
}