mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
This commit is contained in:
parent
7e0e77b4b6
commit
85c65427b9
2 changed files with 29 additions and 2 deletions
|
@ -29,6 +29,19 @@ describe('settings module', () => {
|
|||
describe('when upstream JSON contains a configured action type', () => {
|
||||
it('returns the correct Settings instance', () => {
|
||||
const upstreamJson = {
|
||||
persistent: {
|
||||
xpack: {
|
||||
notification: {
|
||||
email: {
|
||||
account: {
|
||||
foo: {},
|
||||
bar: {}
|
||||
},
|
||||
default_account: 'bar'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
xpack: {
|
||||
notification: {
|
||||
|
@ -49,6 +62,8 @@ describe('settings module', () => {
|
|||
expect(actionTypes.email.enabled).to.be(true);
|
||||
expect(actionTypes.email.accounts.scooby.default).to.be(true);
|
||||
expect(actionTypes.email.accounts.scrappy).to.be.an('object');
|
||||
expect(actionTypes.email.accounts.foo).to.be.an('object');
|
||||
expect(actionTypes.email.accounts.bar).to.be.an('object');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { get } from 'lodash';
|
||||
import { merge } from 'lodash';
|
||||
import { ACTION_TYPES } from '../../../common/constants';
|
||||
|
||||
function isEnabledByDefault(actionType) {
|
||||
|
@ -47,9 +47,21 @@ function getAccounts({ account, default_account: defaultAccount }) {
|
|||
}, {});
|
||||
}
|
||||
|
||||
function getNotifications(json) {
|
||||
if (!json) {
|
||||
return {};
|
||||
}
|
||||
return Object.values(json).reduce((accum, value) => {
|
||||
if (value.hasOwnProperty('xpack') && value.xpack.hasOwnProperty('notification')) {
|
||||
accum = merge(accum, value.xpack.notification);
|
||||
}
|
||||
return accum;
|
||||
}, {});
|
||||
}
|
||||
|
||||
|
||||
function getActionTypesSettings(upstreamJson) {
|
||||
const upstreamActionTypes = get(upstreamJson, 'defaults.xpack.notification', {});
|
||||
const upstreamActionTypes = getNotifications(upstreamJson);
|
||||
|
||||
// Initialize settings for known action types
|
||||
const actionTypes = Object.keys(ACTION_TYPES).reduce((types, typeName) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue