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 = {
|
2017-05-26 02:16:25 +02:00
|
|
|
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'}
|
2017-05-26 02:16:25 +02:00
|
|
|
contentLabel={__("Error")} className="error-modal"
|
2017-04-07 07:15:22 +02:00
|
|
|
overlayClassName="error-modal-overlay"
|
|
|
|
onConfirmed={closeModal}
|
|
|
|
extraContent={errorInfo}
|
|
|
|
>
|
2017-05-26 02:16:25 +02:00
|
|
|
<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>
|
2017-05-26 02:16:25 +02:00
|
|
|
<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
|