UNPKG

@talend/react-cmf

Version:

A framework built on top of best react libraries

58 lines (57 loc) 1.7 kB
import { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import onError from '../../onError'; /** * reload is an event handler. It will reload the current page */ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime"; function reload() { location.reload(true); } function ErrorPanel({ error = {} }) { const [url, setURL] = useState(); useEffect(() => { const newUrl = onError.createObjectURL(error); setURL(newUrl); return () => { onError.revokeObjectURL(newUrl); }; }, [error]); const HAS_REPORT = onError.hasReportFeature(); return /*#__PURE__*/_jsxs("div", { children: [/*#__PURE__*/_jsxs("p", { className: "error-title", children: [error.name, ": ", error.message] }), HAS_REPORT && /*#__PURE__*/_jsx("p", { children: "The error report has been sent." }), /*#__PURE__*/_jsx("p", { children: "From here you can either refresh or contact the support." }), /*#__PURE__*/_jsx("button", { className: "btn btn-danger btn-inverse", onClick: reload, "data-feature": "refresh-on-error", style: { margin: 20 }, children: "Refresh" }), !HAS_REPORT && /*#__PURE__*/_jsx("a", { className: "btn btn-primary btn-inverse", href: url, download: "report.json", "data-feature": "download-on-error-details", children: "Download details" })] }); } ErrorPanel.displayName = 'ErrorPanel'; ErrorPanel.propTypes = { error: PropTypes.shape({ name: PropTypes.string, message: PropTypes.string, stack: PropTypes.string }).isRequired }; export default ErrorPanel; //# sourceMappingURL=ErrorPanel.component.js.map