@@ -4,6 +4,7 @@ import { styled, css } from 'styled-components';
4
4
import { FaExclamationTriangle } from 'react-icons/fa' ;
5
5
import { Column } from './Row' ;
6
6
import { CodeBlock } from './CodeBlock' ;
7
+ import { Button } from './Button' ;
7
8
8
9
export const errorLookStyle = css `
9
10
color: ${ props => props . theme . colors . alert } ;
@@ -20,6 +21,43 @@ export interface ErrorBlockProps {
20
21
showTrace ?: boolean ;
21
22
}
22
23
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
+
23
61
export function ErrorBlock ( { error, showTrace } : ErrorBlockProps ) : JSX . Element {
24
62
return (
25
63
< ErrorLookBig >
@@ -48,14 +86,6 @@ const ErrorLookBig = styled.div`
48
86
background-color: ${ p => p . theme . colors . bg } ;
49
87
` ;
50
88
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
-
59
89
const BiggerText = styled . p `
60
90
color: ${ p => p . theme . colors . alert } ;
61
91
font-size: 1.3rem;
0 commit comments