@intuitionrobotics/bug-report
Version:
80 lines • 3.85 kB
JavaScript
import * as React from "react";
import { BugReportModule } from "../modules/BugReportModule.js";
import { Dialog_Builder, DialogButton_Cancel, DialogButton_Submit, DialogModule, ToastModule, TS_Input, TS_TextArea } from "@intuitionrobotics/thunderstorm/frontend";
import { generateHex } from "@intuitionrobotics/ts-common";
import { Platform_Jira, Platform_Slack } from "../../shared/api.js";
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'
};
export class BugReport extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
componentDidCatch(error, errorInfo) {
BugReportModule.sendBugReport("Automatic submission", "these logs were triggered by a UI failure", [Platform_Slack]);
this.setState({
error: error,
errorInfo: errorInfo
});
}
showAppConfirmationDialogExample = () => {
const title = "Bug Report";
const onSubmit = () => {
if (!this.state.subject)
return ToastModule.toastError('you must first add a subject');
if (!this.state.description)
return ToastModule.toastError('you must first add a description');
BugReportModule.sendBugReport(this.state.subject, this.state.description || '', [Platform_Jira]);
this.setState({ subject: undefined, description: undefined });
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(TS_Input, { id: "bug-report-subject", type: "text", value: this.state.subject || '', placeholder: "type bug name here", name: generateHex(8), onChange: (subject) => this.setState({ subject }) })),
React.createElement(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 Dialog_Builder(content)
.setTitle(title)
.addButton(DialogButton_Cancel(() => {
this.setState({ description: undefined, subject: undefined });
DialogModule.close();
}))
.addButton(DialogButton_Submit(() => onSubmit(), 'Submit'))
.setOverlayColor("rgba(102, 255, 255, 0.4)")
.show();
};
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 }, "+"))));
}
}
;
//# sourceMappingURL=BugReport.js.map