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

don't register any features in LP. #65611

Merged
merged 10 commits into from
May 11, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
};
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -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> | |
Expand Down
1 change: 1 addition & 0 deletions src/core/server/saved_objects/mappings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export interface SavedObjectsCoreFieldMapping {
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
Comment on lines 139 to +140
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be only used in a test plugin and could probably be removed from the mapping instead (even if I did not try to launch the test suite with the mapping modified). But I guess it doesn't hurt to still add it.

};
};
}
Expand Down
1 change: 1 addition & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,7 @@ export interface SavedObjectsCoreFieldMapping {
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
};
};
// (undocumented)
Expand Down
34 changes: 1 addition & 33 deletions x-pack/legacy/plugins/maps/server/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment on lines -25 to 26
Copy link
Contributor

Choose a reason for hiding this comment

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

Are 3rd party plugins meant to be used with a licensed version of Kibana supposed to be able to use x-pack features/apis?

If so, should we add a dev doc or anything to warn that registerFeature is no longer usable from legacy plugins?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will do. just in case


const setPluginStatus = () => {
Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/xpack_main/server/xpack_main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ export { XPackFeature } from './lib/xpack_info';
export interface XPackMainPlugin {
info: XPackInfo;
getFeatures(): Feature[];
registerFeature(feature: FeatureConfig): void;
}
6 changes: 4 additions & 2 deletions x-pack/plugins/maps/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"kibanaVersion": "kibana",
"configPath": ["xpack", "maps"],
"requiredPlugins": [
"inspector",
"licensing",
"features",
"inspector",
"home",
"data",
"fileUpload",
Expand All @@ -15,5 +16,6 @@
"embeddable",
"mapsLegacy"
],
"ui": true
"ui": true,
"server": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
52 changes: 52 additions & 0 deletions x-pack/plugins/maps/server/plugin.ts
Original file line number Diff line number Diff line change
@@ -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) {}
}

This file was deleted.

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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elastic/kibana-platform that's another big thing to get rid of LP: to make all tests KP-compatible. we should have done it as a part of the plugin migration effort 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Even if they are small, there is a lot of test legacy plugins we will still need to migrate to get rid of legacy...

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() {}
}

This file was deleted.

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

This file was deleted.

Loading