2017-06-06 23:19:12 +02:00
|
|
|
import React from "react";
|
|
|
|
import lbry from "lbry";
|
|
|
|
import { ExpandableModal } from "component/modal";
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-06-08 06:42:19 +02:00
|
|
|
class ErrorModal extends React.PureComponent {
|
2017-04-07 07:15:22 +02:00
|
|
|
render() {
|
2017-06-06 23:19:12 +02:00
|
|
|
const { modal, closeModal, error } = this.props;
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
const errorObj = typeof error === "string" ? { error: error } : error;
|
2017-05-24 23:53:03 +02:00
|
|
|
|
|
|
|
const error_key_labels = {
|
2017-06-06 23:19:12 +02:00
|
|
|
connectionString: __("API connection string"),
|
|
|
|
method: __("Method"),
|
|
|
|
params: __("Parameters"),
|
|
|
|
code: __("Error code"),
|
|
|
|
message: __("Error message"),
|
|
|
|
data: __("Error data"),
|
|
|
|
};
|
2017-06-06 06:21:55 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
const errorInfoList = [];
|
2017-04-07 07:15:22 +02:00
|
|
|
for (let key of Object.keys(error)) {
|
2017-06-06 23:19:12 +02:00
|
|
|
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-06-06 23:19:12 +02:00
|
|
|
errorInfoList.push(
|
|
|
|
<li key={key}><strong>{label}</strong>: <code>{val}</code></li>
|
|
|
|
);
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
2017-06-06 23:19:12 +02:00
|
|
|
const errorInfo = (
|
|
|
|
<ul className="error-modal__error-list">{errorInfoList}</ul>
|
|
|
|
);
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
return (
|
2017-04-07 07:15:22 +02:00
|
|
|
<ExpandableModal
|
2017-06-06 23:19:12 +02:00
|
|
|
isOpen={modal == "error"}
|
|
|
|
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">
|
2017-06-06 23:19:12 +02:00
|
|
|
<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>
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default ErrorModal;
|