import React, {PureComponent} from 'react'; import autobind from 'autobind-decorator'; import jq from 'jsonpath'; import RequestSettingsModal from '../modals/request-settings-modal'; import Modal from '../base/modal'; import ModalBody from '../base/modal-body'; import ModalHeader from '../base/modal-header'; import {showModal} from './index'; import Link from '../base/link'; @autobind class RequestRenderErrorModal extends PureComponent { constructor (props) { super(props); this.state = { error: null }; } _setModalRef (n) { this.modal = n; } _handleShowRequestSettings () { this.hide(); showModal(RequestSettingsModal, this.state.request); } show ({request, error}) { this.modal.show(); this.setState({request, error}); } hide () { this.modal.hide(); } renderModalBody (request, error) { const fullPath = `Request.${error.path}`; const result = jq.query(request, `$.${error.path}`); const template = (result && result.length) ? result[0] : null; const locationLabel = template.includes('\n') ? `line ${error.location.line} of` : null; return (
Failed to render {fullPath} prior to sending
Render error
{error.message}
Caused by the following field
{locationLabel} {fullPath}