Skip to content
Snippets Groups Projects
Commit acaeb70f authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

SSDM-7583 : ObjectTypeForm - show error stack trace in the error dialog +...

SSDM-7583 : ObjectTypeForm - show error stack trace in the error dialog + properly encode all parts of mailto href
parent 8ba68e0b
No related branches found
No related tags found
No related merge requests found
......@@ -16,9 +16,7 @@ const styles = theme => ({
zIndex: '20000 !important'
},
actions: {
marginLeft: theme.spacing(2),
marginRight: theme.spacing(2),
marginBottom: theme.spacing(1)
margin: theme.spacing(1)
}
})
......@@ -48,7 +46,7 @@ class DialogWindow extends React.Component {
>
<DialogTitle>{_.isFunction(title) ? title(this) : title}</DialogTitle>
<DialogContent>
<DialogContentText>
<DialogContentText component='div'>
{_.isFunction(content) ? content(this) : content}
</DialogContentText>
</DialogContent>
......
......@@ -21,19 +21,28 @@ class ErrorDialog extends React.Component {
const { error, onClose } = this.props
const content = error && error.message ? error.message : error
return (
<Dialog
open={!!error}
onClose={onClose}
title={'Error'}
content={content || ''}
content={this.renderContent()}
actions={this.renderButtons()}
/>
)
}
renderContent() {
const message = this.getErrorMessage()
const stack = this.getErrorStack()
return (
<div>
<div>{message}</div>
<pre>{stack}</pre>
</div>
)
}
renderButtons() {
const { onClose, classes } = this.props
return (
......@@ -59,32 +68,62 @@ class ErrorDialog extends React.Component {
}
getErrorMailtoHref() {
const message = this.getErrorMessage()
const stack = this.getErrorStack()
let report =
'agent: ' +
navigator.userAgent +
'%0D%0A' +
'\n' +
'domain: ' +
location.hostname +
'%0D%0A' +
'\n' +
'timestamp: ' +
new Date() +
'%0D%0A' +
'\n' +
'href: ' +
location.href.replace(new RegExp('&', 'g'), ' - ') +
'%0D%0A' +
location.href +
'\n' +
'error: ' +
JSON.stringify(this.props.error)
(message ? message : '') +
'\n' +
'stack: ' +
(stack ? stack : '')
let href =
'mailto:' +
profile.devEmail +
'?subject=openBIS Error Report [' +
location.hostname +
']' +
'?subject=' +
encodeURIComponent('openBIS Error Report [' + location.hostname + ']') +
'&body=' +
report
encodeURIComponent(report)
return href
}
getErrorMessage() {
const { error } = this.props
if (error) {
if (error.message) {
return error.message
} else {
return error
}
} else {
return null
}
}
getErrorStack() {
const { error } = this.props
if (error && error.stack) {
return error.stack
} else {
return null
}
}
}
export default withStyles(styles)(ErrorDialog)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment