lbry-desktop/ui/js/component/errorModal/view.jsx

55 lines
1.6 KiB
React
Raw Normal View History

2017-04-07 07:15:22 +02:00
import React from 'react'
import lbry from 'lbry'
import {
ExpandableModal
} from 'component/modal'
class ErrorModal extends React.Component {
render() {
const {
modal,
closeModal,
2017-05-24 23:53:03 +02:00
error
2017-04-07 07:15:22 +02:00
} = this.props
2017-05-24 23:53:03 +02:00
const errorObj = typeof error === "string" ? { error: error } : error
const error_key_labels = {
connectionString: __('API connection string'),
method: __('Method'),
params: __('Parameters'),
code: __('Error code'),
message: __('Error message'),
data: __('Error data'),
2017-04-07 07:15:22 +02:00
}
2017-05-24 23:53:03 +02:00
2017-04-07 07:15:22 +02:00
const errorInfoList = []
for (let key of Object.keys(error)) {
let val = typeof error[key] == 'string' ? error[key] : JSON.stringify(error[key]);
2017-05-24 23:53:03 +02:00
let label = error_key_labels[key];
2017-04-07 07:15:22 +02:00
errorInfoList.push(<li key={key}><strong>{label}</strong>: <code>{val}</code></li>);
}
2017-05-24 23:53:03 +02:00
const errorInfo = <ul className="error-modal__error-list">{errorInfoList}</ul>
2017-04-07 07:15:22 +02:00
return(
<ExpandableModal
isOpen={modal == 'error'}
contentLabel={__("Error")} className="error-modal"
2017-04-07 07:15:22 +02:00
overlayClassName="error-modal-overlay"
onConfirmed={closeModal}
extraContent={errorInfo}
>
<h3 className="modal__header">{__("Error")}</h3>
2017-04-07 07:15:22 +02:00
<div className="error-modal__content">
<div><img className="error-modal__warning-symbol" src={lbry.imagePath('warning.png')} /></div>
<p>{__("We're sorry that LBRY has encountered an error. This has been reported and we will investigate the problem.")}</p>
2017-04-07 07:15:22 +02:00
</div>
</ExpandableModal>
)
}
}
export default ErrorModal