File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
x-pack/plugins/alerts/public Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 55 */
66
77import { HttpSetup } from 'kibana/public' ;
8- import { findFirst } from 'fp-ts/lib/Array' ;
9- import { isNone } from 'fp-ts/lib/Option' ;
10-
118import { i18n } from '@kbn/i18n' ;
129import { BASE_ALERT_API_PATH } from '../common' ;
13- import { Alert , AlertType } from '../common' ;
10+ import type { Alert , AlertType } from '../common' ;
1411
1512export async function loadAlertTypes ( { http } : { http : HttpSetup } ) : Promise < AlertType [ ] > {
1613 return await http . get ( `${ BASE_ALERT_API_PATH } /list_alert_types` ) ;
@@ -23,10 +20,10 @@ export async function loadAlertType({
2320 http : HttpSetup ;
2421 id : AlertType [ 'id' ] ;
2522} ) : Promise < AlertType > {
26- const maybeAlertType = findFirst < AlertType > ( ( type ) => type . id === id ) (
27- await http . get ( `${ BASE_ALERT_API_PATH } /list_alert_types` )
28- ) ;
29- if ( isNone ( maybeAlertType ) ) {
23+ const maybeAlertType = ( ( await http . get (
24+ `${ BASE_ALERT_API_PATH } /list_alert_types`
25+ ) ) as AlertType [ ] ) . find ( ( type ) => type . id === id ) ;
26+ if ( ! maybeAlertType ) {
3027 throw new Error (
3128 i18n . translate ( 'xpack.alerts.loadAlertType.missingAlertTypeError' , {
3229 defaultMessage : 'Alert type "{id}" is not registered.' ,
@@ -36,7 +33,7 @@ export async function loadAlertType({
3633 } )
3734 ) ;
3835 }
39- return maybeAlertType . value ;
36+ return maybeAlertType ;
4037}
4138
4239export async function loadAlert ( {
You can’t perform that action at this time.
0 commit comments