-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Improve styling of Error handling & add open log button
- Loading branch information
1 parent
b8243d0
commit 0920af4
Showing
2 changed files
with
50 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,41 @@ | ||
import React from 'react' | ||
import TextareaAutosize from '@material-ui/core/TextareaAutosize' | ||
import Dialog from '@material-ui/core/Dialog' | ||
import DialogContent from '@material-ui/core/DialogContent' | ||
import DialogActions from '@material-ui/core/DialogActions' | ||
import DialogTitle from '@material-ui/core/DialogTitle' | ||
import Button from '@material-ui/core/Button' | ||
import path from 'path' | ||
import { format } from 'date-fns' | ||
|
||
export default class ErrorDialog extends React.Component { | ||
render () { | ||
// TODO: escape this html for displaying newlines | ||
return ( | ||
<Dialog open={this.props.open} onClose={this.props.onClose}> | ||
<DialogTitle>Error</DialogTitle> | ||
<DialogContent> | ||
<textarea cols='20' rows='40' value={this.props.message} disabled /> | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
import { shell } from 'electron' | ||
import logger from '../../../logger' | ||
|
||
import { defineMessages, useIntl } from 'react-intl' | ||
|
||
const m = defineMessages({ | ||
openLog: 'Open log...', | ||
close: 'Close' | ||
}) | ||
|
||
export default ({ onClose, open, message }) => { | ||
const { formatMessage: t } = useIntl() | ||
|
||
const handleDownload = event => { | ||
var logfile = path.join(logger.dirname, format(Date.now(), 'yyyy-MM') + '.error.log') | ||
shell.openPath(logfile) | ||
} | ||
|
||
return ( | ||
<Dialog open={open} onClose={onClose}> | ||
<DialogTitle>Error</DialogTitle> | ||
<DialogContent> | ||
<TextareaAutosize rowsMin='5' rowsMax='30' cols='40' value={message} disabled /> | ||
<DialogActions> | ||
<Button onClick={handleDownload}>{t(m.openLog)}</Button> | ||
<Button variant='contained' color='primary' onClick={onClose}>{t(m.close)}</Button> | ||
</DialogActions> | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} |