@@ -4,6 +4,7 @@ import { styled, css } from 'styled-components';
44import { FaExclamationTriangle } from 'react-icons/fa' ;
55import { Column } from './Row' ;
66import { CodeBlock } from './CodeBlock' ;
7+ import { Button } from './Button' ;
78
89export const errorLookStyle = css `
910 color: ${ props => props . theme . colors . alert } ;
@@ -20,6 +21,43 @@ export interface ErrorBlockProps {
2021 showTrace ?: boolean ;
2122}
2223
24+ const githubIssueTemplate = (
25+ message ,
26+ stack ,
27+ ) => `**Describe what you did to produce the bug**
28+
29+ ## Error message
30+ \`\`\`
31+ ${ message }
32+ \`\`\`
33+
34+ ## Stack trace
35+ \`\`\`
36+ ${ stack }
37+ \`\`\`
38+ ` ;
39+
40+ /** Returns github URL for new bugs */
41+ export function createGithubIssueLink ( error : Error ) : string {
42+ const url = new URL (
43+ 'https://github.com/atomicdata-dev/atomic-server/issues/new' ,
44+ ) ;
45+ url . searchParams . set ( 'body' , githubIssueTemplate ( error . message , error . stack ) ) ;
46+ url . searchParams . set ( 'labels' , 'bug' ) ;
47+
48+ console . log ( 'opening' , url ) ;
49+
50+ return url . href ;
51+ }
52+
53+ export function GitHubIssueButton ( { error } ) {
54+ return (
55+ < Button onClick = { ( ) => window . open ( createGithubIssueLink ( error ) , '_blank' ) } >
56+ Report on Github
57+ </ Button >
58+ ) ;
59+ }
60+
2361export function ErrorBlock ( { error, showTrace } : ErrorBlockProps ) : JSX . Element {
2462 return (
2563 < ErrorLookBig >
@@ -48,14 +86,6 @@ const ErrorLookBig = styled.div`
4886 background-color: ${ p => p . theme . colors . bg } ;
4987` ;
5088
51- const Pre = styled . pre `
52- white-space: pre-wrap;
53- border-radius: ${ p => p . theme . radius } ;
54- padding: ${ p => p . theme . margin } rem;
55- background-color: ${ p => p . theme . colors . bg } ;
56- font-size: 0.9rem;
57- ` ;
58-
5989const BiggerText = styled . p `
6090 color: ${ p => p . theme . colors . alert } ;
6191 font-size: 1.3rem;
0 commit comments