diff --git a/openbis_ng_ui/src/js/components/common/dialog/Dialog.jsx b/openbis_ng_ui/src/js/components/common/dialog/Dialog.jsx index 4ab5730a722c12d33a8cc2feac1c79de7e4a316c..a489844f0ae2e69404cef3a6679241c0db17d6c5 100644 --- a/openbis_ng_ui/src/js/components/common/dialog/Dialog.jsx +++ b/openbis_ng_ui/src/js/components/common/dialog/Dialog.jsx @@ -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> diff --git a/openbis_ng_ui/src/js/components/common/dialog/ErrorDialog.jsx b/openbis_ng_ui/src/js/components/common/dialog/ErrorDialog.jsx index 50dedec2ce8f27e040685e6f91c5f8f0851f0e9f..a8fc180ea44dd85a49929a1d48bddd91b269794c 100644 --- a/openbis_ng_ui/src/js/components/common/dialog/ErrorDialog.jsx +++ b/openbis_ng_ui/src/js/components/common/dialog/ErrorDialog.jsx @@ -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)