import React , { Component } from 'react' ; import PropTypes from 'prop-types' ; import { EuiCodeBlock } from '@elastic/eui' ; import { Request } from '../../../../../common/adapters/request/types' ; import { RequestDetailsProps } from '../types' ; export class RequestDetailsResponse extends Component < RequestDetailsProps > { static propTypes = { request : PropTypes . object . isRequired , } ; static shouldShow = ( request ) => Boolean ( RequestDetailsResponse . getResponseJson ( request ) ) ; static getResponseJson = ( request ) => ( request . response ? request . response . json : null ) ; render ( ) { const responseJSON = RequestDetailsResponse . getResponseJson ( this . props . request ) ; if ( ! responseJSON ) { return null ; } return ( < EuiCodeBlock language = "json" paddingSize = "s" isCopyable data - test - subj = "inspectorResponseBody" > { JSON . stringify ( responseJSON , null , 2 ) } < /EuiCodeBlock>); } }