Skip to content

Commit

Permalink
use alerts privileges in the alertsExample feature
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Jun 5, 2020
1 parent ade2c4c commit 0ace530
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/alerting_example/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
36 changes: 35 additions & 1 deletion examples/alerting_example/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,53 @@

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';

// this plugin's dependendencies
export interface AlertingExampleDeps {
alerts: AlertingSetup;
features: FeaturesPluginSetup;
}

export class AlertingExamplePlugin implements Plugin<void, void, AlertingExampleDeps> {
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() {}
Expand Down

0 comments on commit 0ace530

Please sign in to comment.