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 => ({ ...@@ -16,9 +16,7 @@ const styles = theme => ({
zIndex: '20000 !important' zIndex: '20000 !important'
}, },
actions: { actions: {
marginLeft: theme.spacing(2), margin: theme.spacing(1)
marginRight: theme.spacing(2),
marginBottom: theme.spacing(1)
} }
}) })
...@@ -48,7 +46,7 @@ class DialogWindow extends React.Component { ...@@ -48,7 +46,7 @@ class DialogWindow extends React.Component {
> >
<DialogTitle>{_.isFunction(title) ? title(this) : title}</DialogTitle> <DialogTitle>{_.isFunction(title) ? title(this) : title}</DialogTitle>
<DialogContent> <DialogContent>
<DialogContentText> <DialogContentText component='div'>
{_.isFunction(content) ? content(this) : content} {_.isFunction(content) ? content(this) : content}
</DialogContentText> </DialogContentText>
</DialogContent> </DialogContent>
......
...@@ -21,19 +21,28 @@ class ErrorDialog extends React.Component { ...@@ -21,19 +21,28 @@ class ErrorDialog extends React.Component {
const { error, onClose } = this.props const { error, onClose } = this.props
const content = error && error.message ? error.message : error
return ( return (
<Dialog <Dialog
open={!!error} open={!!error}
onClose={onClose} onClose={onClose}
title={'Error'} title={'Error'}
content={content || ''} content={this.renderContent()}
actions={this.renderButtons()} actions={this.renderButtons()}
/> />
) )
} }
renderContent() {
const message = this.getErrorMessage()
const stack = this.getErrorStack()
return (
<div>
<div>{message}</div>
<pre>{stack}</pre>
</div>
)
}
renderButtons() { renderButtons() {
const { onClose, classes } = this.props const { onClose, classes } = this.props
return ( return (
...@@ -59,32 +68,62 @@ class ErrorDialog extends React.Component { ...@@ -59,32 +68,62 @@ class ErrorDialog extends React.Component {
} }
getErrorMailtoHref() { getErrorMailtoHref() {
const message = this.getErrorMessage()
const stack = this.getErrorStack()
let report = let report =
'agent: ' + 'agent: ' +
navigator.userAgent + navigator.userAgent +
'%0D%0A' + '\n' +
'domain: ' + 'domain: ' +
location.hostname + location.hostname +
'%0D%0A' + '\n' +
'timestamp: ' + 'timestamp: ' +
new Date() + new Date() +
'%0D%0A' + '\n' +
'href: ' + 'href: ' +
location.href.replace(new RegExp('&', 'g'), ' - ') + location.href +
'%0D%0A' + '\n' +
'error: ' + 'error: ' +
JSON.stringify(this.props.error) (message ? message : '') +
'\n' +
'stack: ' +
(stack ? stack : '')
let href = let href =
'mailto:' + 'mailto:' +
profile.devEmail + profile.devEmail +
'?subject=openBIS Error Report [' + '?subject=' +
location.hostname + encodeURIComponent('openBIS Error Report [' + location.hostname + ']') +
']' +
'&body=' + '&body=' +
report encodeURIComponent(report)
return href 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) 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