-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Service): Add error screen for services that failed to load
- Loading branch information
Showing
7 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
src/components/services/content/ErrorHandlers/WebviewErrorHandler.js
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { observer } from 'mobx-react'; | ||
import { defineMessages, intlShape } from 'react-intl'; | ||
import injectSheet from 'react-jss'; | ||
|
||
import Button from '../../../ui/Button'; | ||
|
||
import styles from './styles'; | ||
|
||
const messages = defineMessages({ | ||
headline: { | ||
id: 'service.errorHandler.headline', | ||
defaultMessage: '!!!Oh no!', | ||
}, | ||
text: { | ||
id: 'service.errorHandler.text', | ||
defaultMessage: '!!!{name} has failed to load.', | ||
}, | ||
action: { | ||
id: 'service.errorHandler.action', | ||
defaultMessage: '!!!Reload {name}', | ||
}, | ||
editAction: { | ||
id: 'service.errorHandler.editAction', | ||
defaultMessage: '!!!Edit {name}', | ||
}, | ||
errorMessage: { | ||
id: 'service.errorHandler.message', | ||
defaultMessage: '!!!Error: {error}', | ||
}, | ||
}); | ||
|
||
export default @injectSheet(styles) @observer class WebviewCrashHandler extends Component { | ||
static propTypes = { | ||
name: PropTypes.string.isRequired, | ||
reload: PropTypes.func.isRequired, | ||
edit: PropTypes.func.isRequired, | ||
errorMessage: PropTypes.string.isRequired, | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
static contextTypes = { | ||
intl: intlShape, | ||
}; | ||
|
||
render() { | ||
const { | ||
name, | ||
reload, | ||
edit, | ||
errorMessage, | ||
classes, | ||
} = this.props; | ||
const { intl } = this.context; | ||
|
||
return ( | ||
<div className={classes.component}> | ||
<h1>{intl.formatMessage(messages.headline)}</h1> | ||
<p>{intl.formatMessage(messages.text, { name })}</p> | ||
<p>{intl.formatMessage(messages.errorMessage, { | ||
error: errorMessage, | ||
})}</p> | ||
<div className={classes.buttonContainer}> | ||
<Button | ||
label={intl.formatMessage(messages.editAction, { name })} | ||
buttonType="inverted" | ||
onClick={() => edit()} | ||
/> | ||
<Button | ||
label={intl.formatMessage(messages.action, { name })} | ||
buttonType="inverted" | ||
onClick={() => reload()} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export default { | ||
component: { | ||
left: 0, | ||
position: 'absolute', | ||
top: 0, | ||
width: '100%', | ||
zIndex: 0, | ||
alignItems: 'center', | ||
// background: $theme-gray-lighter; | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
textAlign: 'center', | ||
}, | ||
buttonContainer: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
height: 'auto', | ||
margin: [40, 0, 20], | ||
|
||
'& button': { | ||
margin: [0, 10, 0, 10], | ||
}, | ||
}, | ||
}; |
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
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
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