UNPKG

sws-frontend

Version:

sws frontend project

92 lines 3.76 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); require("./errormodal.css"); var react_bootstrap_1 = require("react-bootstrap"); exports.makeError = function (error) { return ({ title: "" + (error.name ? error.name : 'Error'), subtitle: error.message, details: (error.stack ? error.stack : undefined) || (error.stacktrace ? error.stacktrace : undefined) }); }; exports.errorBuilder = function (title, subtitle, details, onHide) { if (title === void 0) { title = exports.defaultError.title; } if (subtitle === void 0) { subtitle = exports.defaultError.subtitle; } var report = { title: title, subtitle: subtitle, details: details, onHide: onHide }; return report; }; /** something is wrong, no much more. */ exports.defaultError = { title: "Well, this was totally unexpected.", subtitle: "Sadly, causes are still unknown at this time.", details: "Check the connectivity" }; var ErrorModal = (function (_super) { __extends(ErrorModal, _super); function ErrorModal(props) { var _this = _super.call(this, props) || this; _this.state = { showDetails: false }; return _this; } ErrorModal.prototype.toggleDetails = function () { this.setState({ showDetails: !this.state.showDetails }); }; ErrorModal.prototype.render = function () { var _this = this; var error = this.props.error; var toggle = function () { return _this.toggleDetails(); }; return (error && React.createElement(react_bootstrap_1.Modal.Dialog, { className: "errormodal" }, React.createElement(react_bootstrap_1.Modal.Header, null, "Ooops, it's an error."), React.createElement("div", { className: "modal-body-wrapper" }, React.createElement(react_bootstrap_1.Modal.Body, null, React.createElement("div", null, React.createElement("h4", null, error.title)), React.createElement("div", null, error.subtitle)), this.state.showDetails ? React.createElement(react_bootstrap_1.Well, { "data-smaller": true, className: "details" }, error.details) : null), React.createElement(react_bootstrap_1.Modal.Footer, null, error.details ? React.createElement(react_bootstrap_1.Button, { onClick: toggle }, " Details") : null, React.createElement(react_bootstrap_1.Button, { onClick: error.onHide ? error.onHide : function () { return undefined; } }, " Ok")))); }; return ErrorModal; }(React.Component)); exports.default = ErrorModal; /** wraps the view into a stateful container. */ // // import { connect } from "react-redux" // import select from "../../state/state" // import * as actions from "../../state/commonactions" // // const props = state => ({ // // error : select.error(state) // // }) // // // connect() : to the global store. // export default connect(props,{ // // onHide : actions.clearError // // })(ErrorModal) //# sourceMappingURL=errormodal.js.map