From 0ace530bdbe059d1abcf5864270f5fd1f545e9df Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Fri, 5 Jun 2020 11:25:46 +0100 Subject: [PATCH] use alerts privileges in the alertsExample feature --- examples/alerting_example/kibana.json | 2 +- examples/alerting_example/server/plugin.ts | 36 +++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/examples/alerting_example/kibana.json b/examples/alerting_example/kibana.json index 2b6389649cef9..aa5b0dd45895e 100644 --- a/examples/alerting_example/kibana.json +++ b/examples/alerting_example/kibana.json @@ -4,6 +4,6 @@ "kibanaVersion": "kibana", "server": true, "ui": true, - "requiredPlugins": ["triggers_actions_ui", "charts", "data", "alerts", "actions"], + "requiredPlugins": ["triggers_actions_ui", "charts", "data", "alerts", "actions", "features"], "optionalPlugins": [] } diff --git a/examples/alerting_example/server/plugin.ts b/examples/alerting_example/server/plugin.ts index cdb005feca35c..9128281fb72e5 100644 --- a/examples/alerting_example/server/plugin.ts +++ b/examples/alerting_example/server/plugin.ts @@ -19,6 +19,7 @@ import { Plugin, CoreSetup } from 'kibana/server'; import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerts/server'; +import { PluginSetupContract as FeaturesPluginSetup } from '../../../x-pack/plugins/features/server'; import { alertType as alwaysFiringAlert } from './alert_types/always_firing'; import { alertType as peopleInSpaceAlert } from './alert_types/astros'; @@ -26,12 +27,45 @@ import { alertType as peopleInSpaceAlert } from './alert_types/astros'; // this plugin's dependendencies export interface AlertingExampleDeps { alerts: AlertingSetup; + features: FeaturesPluginSetup; } export class AlertingExamplePlugin implements Plugin { - public setup(core: CoreSetup, { alerts }: AlertingExampleDeps) { + public setup(core: CoreSetup, { alerts, features }: AlertingExampleDeps) { alerts.registerType(alwaysFiringAlert); alerts.registerType(peopleInSpaceAlert); + + features.registerFeature({ + id: 'alertsExample', + name: 'alertsExample', + app: [], + privileges: { + all: { + alerting: { + globally: { + all: [alwaysFiringAlert.id, peopleInSpaceAlert.id], + }, + }, + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + read: { + alerting: { + globally: { + read: [alwaysFiringAlert.id, peopleInSpaceAlert.id], + }, + }, + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + }, + }); } public start() {}