UNPKG

@intuitionrobotics/bug-report

Version:
84 lines 4.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BugReport = void 0; const React = require("react"); const BugReportModule_1 = require("../modules/BugReportModule"); const frontend_1 = require("@intuitionrobotics/thunderstorm/frontend"); const ts_common_1 = require("@intuitionrobotics/ts-common"); const api_1 = require("../../shared/api"); const style = { cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", position: "fixed", width: "50px", height: "50px", bottom: "30px", right: "10px", backgroundColor: "#5b7bd6", color: "white", borderRadius: "50%", borderColor: 'transparent' }; class BugReport extends React.Component { constructor(props) { super(props); this.showAppConfirmationDialogExample = () => { const title = "Bug Report"; const onSubmit = () => { if (!this.state.subject) return frontend_1.ToastModule.toastError('you must first add a subject'); if (!this.state.description) return frontend_1.ToastModule.toastError('you must first add a description'); BugReportModule_1.BugReportModule.sendBugReport(this.state.subject, this.state.description || '', [api_1.Platform_Jira]); this.setState({ subject: undefined, description: undefined }); frontend_1.DialogModule.close(); }; const content = React.createElement("div", { className: 'll_v_c' }, React.createElement("div", { style: { border: `1px solid darkslategray`, marginBottom: "5px", width: "91%", margin: "8px" } }, React.createElement(frontend_1.TS_Input, { id: "bug-report-subject", type: "text", value: this.state.subject || '', placeholder: "type bug name here", name: (0, ts_common_1.generateHex)(8), onChange: (subject) => this.setState({ subject }) })), React.createElement(frontend_1.TS_TextArea, { id: "bug-report-description", type: "text", style: { height: "110px", margin: "8px", width: "100%", outline: "none" }, value: this.state.description || '', placeholder: "type bug description here", onChange: (description) => this.setState({ description }) })); new frontend_1.Dialog_Builder(content) .setTitle(title) .addButton((0, frontend_1.DialogButton_Cancel)(() => { this.setState({ description: undefined, subject: undefined }); frontend_1.DialogModule.close(); })) .addButton((0, frontend_1.DialogButton_Submit)(() => onSubmit(), 'Submit')) .setOverlayColor("rgba(102, 255, 255, 0.4)") .show(); }; this.state = {}; } componentDidCatch(error, errorInfo) { BugReportModule_1.BugReportModule.sendBugReport("Automatic submission", "these logs were triggered by a UI failure", [api_1.Platform_Slack]); this.setState({ error: error, errorInfo: errorInfo }); } render() { if (this.state.errorInfo) { return (React.createElement("div", null, React.createElement("h2", null, "Something went wrong."), React.createElement("details", { style: { whiteSpace: 'pre-wrap' } }, this.state.error && this.state.error.toString(), React.createElement("br", null), this.state.errorInfo.componentStack), React.createElement("button", { style: style, onClick: () => window.location.reload() }, "reload!"))); } return (React.createElement(React.Fragment, null, this.props.children, React.createElement("div", { onClick: this.showAppConfirmationDialogExample }, this.props.component || React.createElement("button", { style: style }, "+")))); } } exports.BugReport = BugReport; ; //# sourceMappingURL=BugReport.js.map