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

[Alerting] Adds navigation by consumer and alert type to alerting #58997

Merged
merged 62 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b7f1b47
added registration of navigation by consumer and alert type
gmmorris Mar 2, 2020
fd0aa63
removed unused prop
gmmorris Mar 2, 2020
73111e5
use unique identifiers for i18n
gmmorris Mar 2, 2020
62036f3
removed consumer from api route
gmmorris Mar 2, 2020
ed5946c
cleaned up types
gmmorris Mar 2, 2020
5184196
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 3, 2020
2b49b71
plug in View in App button on details page
gmmorris Mar 3, 2020
9ff010f
fixed deps in tests
gmmorris Mar 3, 2020
f703330
added basic example plugin using alerting and navigation
gmmorris Mar 4, 2020
826faf6
removed unused param
gmmorris Mar 9, 2020
57d5b4f
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 9, 2020
f540a78
moved registerNavigation and getNavigation apis to client side
gmmorris Mar 9, 2020
5e41363
added missing deps in test mocks
gmmorris Mar 9, 2020
0afbcd5
fixed tests in alert details
gmmorris Mar 9, 2020
e5a17ff
fixed tsconfig in example app
gmmorris Mar 9, 2020
9024c40
removed nav registration as tests have been removed
gmmorris Mar 9, 2020
d5c4293
migrated fixture in alerting functional test to NP
gmmorris Mar 10, 2020
0363764
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 10, 2020
ac843b8
added flag for json import uin event log
gmmorris Mar 10, 2020
8616036
use path navigartion in place of state
gmmorris Mar 10, 2020
dd5ae27
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 10, 2020
ff30bf8
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 11, 2020
0f16e3c
fixed extension
gmmorris Mar 11, 2020
fc39b77
use flyout instead of button
gmmorris Mar 11, 2020
00ec6ae
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 11, 2020
15575a9
cleaned up generic view for alert
gmmorris Mar 11, 2020
3e8777f
added people in space alert
gmmorris Mar 12, 2020
fb1cee9
added view specific for people in space
gmmorris Mar 12, 2020
0da9e64
Added default handler for consumer navigation
gmmorris Mar 12, 2020
2d48a31
added integration test for view in app
gmmorris Mar 12, 2020
fc5b17c
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 12, 2020
e39436b
test enabled view in app link
gmmorris Mar 12, 2020
62c10f8
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 12, 2020
8c40563
cleaned up code
gmmorris Mar 13, 2020
b0010da
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 13, 2020
5a11334
removed unneeded navigation imports
gmmorris Mar 13, 2020
a4c9f1f
Merge branch 'master' into alerting/view-in-app
elasticmachine Mar 16, 2020
8fb42a2
aded build config to fixture plugin
gmmorris Mar 16, 2020
170bf37
Merge branch 'alerting/view-in-app' of github.com:gmmorris/kibana int…
gmmorris Mar 16, 2020
9877845
removed package fomr kbn/pm
gmmorris Mar 16, 2020
5d3a7ef
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 16, 2020
9992d84
Revert "removed package fomr kbn/pm"
gmmorris Mar 16, 2020
e479641
applied changes t odist of kbn/pm
gmmorris Mar 16, 2020
cd49220
removed unneccesery ts project
gmmorris Mar 16, 2020
6895704
include fixtuire in plugin platform
gmmorris Mar 16, 2020
104f2af
added documentation
gmmorris Mar 16, 2020
670af1c
Simplify unit test
gmmorris Mar 17, 2020
8cc2e84
typo
gmmorris Mar 17, 2020
a1fbe71
typo
gmmorris Mar 17, 2020
23590f3
typo
gmmorris Mar 17, 2020
6482459
moves alerting to potional plugins
gmmorris Mar 17, 2020
4564004
Merge branch 'alerting/view-in-app' of github.com:gmmorris/kibana int…
gmmorris Mar 17, 2020
186b31e
handle optional alerting plugin
gmmorris Mar 17, 2020
3c7bea5
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 17, 2020
2b8c90c
fixed typo
gmmorris Mar 17, 2020
baadf60
fixed missing smicollon
gmmorris Mar 17, 2020
ff45d00
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 18, 2020
4584654
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 18, 2020
02b6be3
Merge branch 'master' into alerting/view-in-app
gmmorris Mar 18, 2020
fcdd2bb
fixed await for click on view in app
gmmorris Mar 18, 2020
1fc7f16
reverted change in test
gmmorris Mar 18, 2020
7365d28
skipping test to see if it gets it to pass
gmmorris Mar 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/alerting_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Alerting Example

This example plugin shows you how to create a custom Alert Type, create alerts based on that type and corresponding UI for viewing the details of all the alerts within the custom plugin.

To run this example, use the command `yarn start --run-examples`.
34 changes: 34 additions & 0 deletions examples/alerting_example/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export const ALERTING_EXAMPLE_APP_ID = 'AlertingExample';

// always firing
export const DEFAULT_INSTANCES_TO_GENERATE = 5;

// Astros
export enum Craft {
OuterSpace = 'Outer Space',
ISS = 'ISS',
}
export enum Operator {
AreAbove = 'Are above',
AreBelow = 'Are below',
AreExactly = 'Are exactly',
}
10 changes: 10 additions & 0 deletions examples/alerting_example/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "alertingExample",
"version": "0.0.1",
"kibanaVersion": "kibana",
"configPath": ["alerting_example"],
"server": true,
"ui": true,
"requiredPlugins": ["triggers_actions_ui", "charts", "data", "alerting", "actions"],
"optionalPlugins": []
}
17 changes: 17 additions & 0 deletions examples/alerting_example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "alerting_example",
"version": "1.0.0",
"main": "target/examples/alerting_example",
"kibana": {
"version": "kibana",
"templateVersion": "1.0.0"
},
"license": "Apache-2.0",
"scripts": {
"kbn": "node ../../scripts/kbn.js",
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
}
}
82 changes: 82 additions & 0 deletions examples/alerting_example/public/alert_types/always_firing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { Fragment } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiFieldNumber, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AlertTypeModel } from '../../../../x-pack/plugins/triggers_actions_ui/public';
import { DEFAULT_INSTANCES_TO_GENERATE } from '../../common/constants';

interface AlwaysFiringParamsProps {
alertParams: { instances?: number };
setAlertParams: (property: string, value: any) => void;
errors: { [key: string]: string[] };
}

export function getAlertType(): AlertTypeModel {
return {
id: 'example.always-firing',
name: 'Always Fires',
iconClass: 'bolt',
alertParamsExpression: AlwaysFiringExpression,
validate: (alertParams: AlwaysFiringParamsProps['alertParams']) => {
const { instances } = alertParams;
const validationResult = {
errors: {
instances: new Array<string>(),
},
};
if (instances && instances < 0) {
validationResult.errors.instances.push(
i18n.translate('AlertingExample.addAlert.error.invalidRandomInstances', {
defaultMessage: 'instances must be equal or greater than zero.',
})
);
}
return validationResult;
},
};
}

export const AlwaysFiringExpression: React.FunctionComponent<AlwaysFiringParamsProps> = ({
alertParams,
setAlertParams,
}) => {
const { instances = DEFAULT_INSTANCES_TO_GENERATE } = alertParams;
return (
<Fragment>
<EuiFlexGroup gutterSize="s" wrap direction="column">
<EuiFlexItem grow={true}>
<EuiFormRow
label="Random Instances to generate"
helpText="How many randomly generated Alert Instances do you wish to activate on each alert run?"
>
<EuiFieldNumber
name="instances"
value={instances}
onChange={event => {
setAlertParams('instances', event.target.valueAsNumber);
}}
/>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
</Fragment>
);
};
Loading