-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/alerts/server/lib/get_alert_notify_when_type.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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 { getAlertNotifyWhenType } from './get_alert_notify_when_type'; | ||
|
||
test(`should return 'notifyWhen' value if value is set and throttle is null`, () => { | ||
expect(getAlertNotifyWhenType('onActionGroupChange', null)).toEqual('onActionGroupChange'); | ||
}); | ||
|
||
test(`should return 'notifyWhen' value if value is set and throttle is defined`, () => { | ||
expect(getAlertNotifyWhenType('onActionGroupChange', '10m')).toEqual('onActionGroupChange'); | ||
}); | ||
|
||
test(`should return 'onThrottleInterval' value if 'notifyWhen' is null and throttle is defined`, () => { | ||
expect(getAlertNotifyWhenType(null, '10m')).toEqual('onThrottleInterval'); | ||
}); | ||
|
||
test(`should return 'onActiveAlert' value if 'notifyWhen' is null and throttle is null`, () => { | ||
expect(getAlertNotifyWhenType(null, null)).toEqual('onActiveAlert'); | ||
}); |
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/alerts/server/lib/get_alert_notify_when_type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* 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 { AlertNotifyWhenType } from '../types'; | ||
|
||
export function getAlertNotifyWhenType( | ||
notifyWhen: AlertNotifyWhenType | null, | ||
throttle: string | null | ||
): AlertNotifyWhenType { | ||
// We allow notifyWhen to be null for backwards compatibility. If it is null, determine its | ||
// value based on whether the throttle is set to a value or null | ||
return notifyWhen ? notifyWhen! : throttle ? 'onThrottleInterval' : 'onActiveAlert'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters