66
77import React , { useMemo , useState } from 'react' ;
88import { i18n } from '@kbn/i18n' ;
9- import { EuiSearchBar , EuiSpacer , Query } from '@elastic/eui' ;
9+ import { EuiSearchBar , EuiSpacer , EuiEmptyPrompt , EuiButton , Query } from '@elastic/eui' ;
1010import { useProcessList } from '../../../../hooks/use_process_list' ;
1111import { TabContent , TabProps } from '../shared' ;
1212import { STATE_NAMES } from './states' ;
@@ -17,17 +17,44 @@ const TabComponent = ({ currentTime, node, nodeType, options }: TabProps) => {
1717 const [ searchFilter , setSearchFilter ] = useState < Query > ( EuiSearchBar . Query . MATCH_ALL ) ;
1818
1919 const hostTerm = useMemo ( ( ) => {
20- const field = options . fields [ nodeType ] ;
20+ const field =
21+ options . fields && Reflect . has ( options . fields , nodeType )
22+ ? Reflect . get ( options . fields , nodeType )
23+ : nodeType ;
2124 return { [ field ] : node . name } ;
2225 } , [ options , node , nodeType ] ) ;
2326
24- const { loading, error, response } = useProcessList (
27+ const { loading, error, response, makeRequest : reload } = useProcessList (
2528 hostTerm ,
2629 'metricbeat-*' ,
27- options . fields ? .timestamp ,
30+ options . fields ! . timestamp ,
2831 currentTime
2932 ) ;
3033
34+ if ( error ) {
35+ return (
36+ < TabContent >
37+ < EuiEmptyPrompt
38+ iconType = "tableDensityNormal"
39+ title = {
40+ < h4 >
41+ { i18n . translate ( 'xpack.infra.metrics.nodeDetails.processListError' , {
42+ defaultMessage : 'Unable to show process data' ,
43+ } ) }
44+ </ h4 >
45+ }
46+ actions = {
47+ < EuiButton color = "primary" fill onClick = { reload } >
48+ { i18n . translate ( 'xpack.infra.metrics.nodeDetails.processListRetry' , {
49+ defaultMessage : 'Try again' ,
50+ } ) }
51+ </ EuiButton >
52+ }
53+ />
54+ </ TabContent >
55+ ) ;
56+ }
57+
3158 return (
3259 < TabContent >
3360 < SummaryTable isLoading = { loading } processList = { response ?? [ ] } />
0 commit comments