@@ -8,6 +8,8 @@ import React, { Component, Fragment } from 'react';
88import { get } from 'lodash' ;
99import { i18n } from '@kbn/i18n' ;
1010import { FormattedMessage } from '@kbn/i18n/react' ;
11+ import { ApplicationStart } from 'kibana/public' ;
12+
1113import {
1214 EuiLink ,
1315 EuiSelect ,
@@ -26,9 +28,25 @@ import {
2628import { loadPolicies , addLifecyclePolicyToIndex } from '../../application/services/api' ;
2729import { showApiError } from '../../application/services/api_errors' ;
2830import { toasts } from '../../application/services/notification' ;
31+ import { PolicyFromES } from '../../application/services/policies/types' ;
32+
33+ interface Props {
34+ indexName : string ;
35+ closeModal : ( ) => void ;
36+ index : any ;
37+ reloadIndices : ( ) => void ;
38+ getUrlForApp : ApplicationStart [ 'getUrlForApp' ] ;
39+ }
40+
41+ interface State {
42+ selectedPolicyName : string ;
43+ selectedAlias : string ;
44+ policies : PolicyFromES [ ] ;
45+ policyError ?: string ;
46+ }
2947
30- export class AddLifecyclePolicyConfirmModal extends Component {
31- constructor ( props ) {
48+ export class AddLifecyclePolicyConfirmModal extends Component < Props , State > {
49+ constructor ( props : Props ) {
3250 super ( props ) ;
3351 this . state = {
3452 policies : [ ] ,
@@ -81,7 +99,7 @@ export class AddLifecyclePolicyConfirmModal extends Component {
8199 ) ;
82100 }
83101 } ;
84- renderAliasFormElement = ( selectedPolicy ) => {
102+ renderAliasFormElement = ( selectedPolicy ?: PolicyFromES ) => {
85103 const { selectedAlias } = this . state ;
86104 const { index } = this . props ;
87105 const showAliasSelect =
@@ -109,15 +127,15 @@ export class AddLifecyclePolicyConfirmModal extends Component {
109127 defaultMessage = "Policy {policyName} is configured for rollover,
110128 but index {indexName} does not have an alias, which is required for rollover."
111129 values = { {
112- policyName : selectedPolicy . name ,
130+ policyName : selectedPolicy ? .name ,
113131 indexName : index . name ,
114132 } }
115133 />
116134 </ EuiCallOut >
117135 </ Fragment >
118136 ) ;
119137 }
120- const aliasOptions = aliases . map ( ( alias ) => {
138+ const aliasOptions = aliases . map ( ( alias : string ) => {
121139 return {
122140 text : alias ,
123141 value : alias ,
@@ -155,7 +173,7 @@ export class AddLifecyclePolicyConfirmModal extends Component {
155173 const { policies, selectedPolicyName, policyError } = this . state ;
156174 const selectedPolicy = selectedPolicyName
157175 ? policies . find ( ( policy ) => policy . name === selectedPolicyName )
158- : null ;
176+ : undefined ;
159177
160178 const options = policies . map ( ( { name } ) => {
161179 return {
@@ -188,7 +206,7 @@ export class AddLifecyclePolicyConfirmModal extends Component {
188206 options = { options }
189207 value = { selectedPolicyName }
190208 onChange = { ( e ) => {
191- this . setState ( { policyError : null , selectedPolicyName : e . target . value } ) ;
209+ this . setState ( { policyError : undefined , selectedPolicyName : e . target . value } ) ;
192210 } }
193211 />
194212 </ EuiFormRow >
@@ -198,7 +216,7 @@ export class AddLifecyclePolicyConfirmModal extends Component {
198216 }
199217 async componentDidMount ( ) {
200218 try {
201- const policies = await loadPolicies ( false , this . props . httpClient ) ;
219+ const policies = await loadPolicies ( false ) ;
202220 this . setState ( { policies } ) ;
203221 } catch ( err ) {
204222 showApiError (
0 commit comments