Skip to content

Commit

Permalink
Merge branch 'master' into ml_rules_ml_admins
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored May 11, 2020
2 parents 553234e + 4174bab commit 9b5e47b
Show file tree
Hide file tree
Showing 34 changed files with 345 additions and 311 deletions.
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;
};
};
}
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 @@ -1884,6 +1884,7 @@ export interface SavedObjectsCoreFieldMapping {
fields?: {
[subfield: string]: {
type: string;
ignore_above?: number;
};
};
// (undocumented)
Expand Down
30 changes: 0 additions & 30 deletions src/legacy/core_plugins/ui_metric/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/legacy/core_plugins/ui_metric/package.json

This file was deleted.

21 changes: 0 additions & 21 deletions src/legacy/core_plugins/ui_metric/public/index.ts

This file was deleted.

This file was deleted.

44 changes: 0 additions & 44 deletions src/plugins/usage_collection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,41 +126,6 @@ export function registerMyPluginUsageCollector(
}
```

### Migrating to NP from Legacy Plugins

Pass `usageCollection` to the setup NP plugin setup function under plugins. Inside the `setup` function call the `registerCollector` like what you'd do in the NP example above.

```js
// index.js
export const myPlugin = (kibana: any) => {
return new kibana.Plugin({
init: async function (server) {
const { usageCollection } = server.newPlatform.setup.plugins;
const plugins = {
usageCollection,
};
plugin(initializerContext).setup(core, plugins);
}
});
}
```

### Legacy Plugins

Typically, a plugin will create the collector object and register it with the Telemetry service from the `init` method of the plugin definition, or a helper module called from `init`.

```js
// index.js
export const myPlugin = (kibana: any) => {
return new kibana.Plugin({
init: async function (server) {
const { usageCollection } = server.newPlatform.setup.plugins;
registerMyPluginUsageCollector(usageCollection);
}
});
}
```

## Update the telemetry payload and telemetry cluster field mappings

There is a module in the telemetry service that creates the payload of data that gets sent up to the telemetry cluster.
Expand Down Expand Up @@ -239,15 +204,6 @@ To track a user interaction, use the `reportUiStats` method exposed by the plugi
}
```
Alternatively, in the Legacy world you can still import the `createUiStatsReporter` helper function from UI Metric app:
```js
import { createUiStatsReporter, METRIC_TYPE } from 'relative/path/to/src/legacy/core_plugins/ui_metric/public';
const trackMetric = createUiStatsReporter(`<AppName>`);
trackMetric(METRIC_TYPE.CLICK, `<EventName>`);
trackMetric('click', `<EventName>`);
```
Metric Types:
- `METRIC_TYPE.CLICK` for tracking clicks `trackMetric(METRIC_TYPE.CLICK, 'my_button_clicked');`
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);

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;
}
5 changes: 5 additions & 0 deletions x-pack/plugins/ingest_manager/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { first } from 'rxjs/operators';
import {
CoreSetup,
CoreStart,
Logger,
Plugin,
PluginInitializerContext,
SavedObjectsServiceStart,
Expand Down Expand Up @@ -73,6 +74,7 @@ export interface IngestManagerAppContext {
isProductionMode: boolean;
kibanaVersion: string;
cloud?: CloudSetup;
logger?: Logger;
httpSetup?: HttpServiceSetup;
}

Expand Down Expand Up @@ -108,6 +110,7 @@ export class IngestManagerPlugin
private config$: Observable<IngestManagerConfigType>;
private security: SecurityPluginSetup | undefined;
private cloud: CloudSetup | undefined;
private logger: Logger | undefined;

private isProductionMode: boolean;
private kibanaVersion: string;
Expand All @@ -117,6 +120,7 @@ export class IngestManagerPlugin
this.config$ = this.initializerContext.config.create<IngestManagerConfigType>();
this.isProductionMode = this.initializerContext.env.mode.prod;
this.kibanaVersion = this.initializerContext.env.packageInfo.version;
this.logger = this.initializerContext.logger.get();
}

public async setup(core: CoreSetup, deps: IngestManagerSetupDeps) {
Expand Down Expand Up @@ -208,6 +212,7 @@ export class IngestManagerPlugin
kibanaVersion: this.kibanaVersion,
httpSetup: this.httpSetup,
cloud: this.cloud,
logger: this.logger,
});
licenseService.start(this.licensing$);
return {
Expand Down
8 changes: 7 additions & 1 deletion x-pack/plugins/ingest_manager/server/services/app_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { BehaviorSubject, Observable } from 'rxjs';
import { first } from 'rxjs/operators';
import { SavedObjectsServiceStart, HttpServiceSetup } from 'src/core/server';
import { SavedObjectsServiceStart, HttpServiceSetup, Logger } from 'src/core/server';
import { EncryptedSavedObjectsPluginStart } from '../../../encrypted_saved_objects/server';
import { SecurityPluginSetup } from '../../../security/server';
import { IngestManagerConfigType } from '../../common';
Expand All @@ -21,6 +21,7 @@ class AppContextService {
private isProductionMode: boolean = false;
private kibanaVersion: string | undefined;
private cloud?: CloudSetup;
private logger?: Logger;
private httpSetup?: HttpServiceSetup;

public async start(appContext: IngestManagerAppContext) {
Expand All @@ -29,6 +30,7 @@ class AppContextService {
this.savedObjects = appContext.savedObjects;
this.isProductionMode = appContext.isProductionMode;
this.cloud = appContext.cloud;
this.logger = appContext.logger;
this.kibanaVersion = appContext.kibanaVersion;
this.httpSetup = appContext.httpSetup;

Expand Down Expand Up @@ -60,6 +62,10 @@ class AppContextService {
return this.cloud;
}

public getLogger() {
return this.logger;
}

public getConfig() {
return this.configSubject$?.value;
}
Expand Down
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) {}
}
Loading

0 comments on commit 9b5e47b

Please sign in to comment.