-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from PublicHealthEngland/development
Essential updates and general improvements No conflict detected.
- Loading branch information
Showing
32 changed files
with
420 additions
and
377 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
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
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 |
---|---|---|
|
@@ -2,32 +2,65 @@ | |
|
||
import React from 'react'; | ||
|
||
type Props = { | ||
children: any, | ||
}; | ||
import PageTitle from 'components/PageTitle'; | ||
import type { Props } from './ErrorBoundary.types'; | ||
import * as Styles from './ErrorBoundary.styles'; | ||
|
||
type State = { | ||
hasError: boolean | ||
}; | ||
|
||
export default class ErrorBoundary extends React.Component<Props, State> { | ||
props: Props; | ||
state: State = { | ||
hasError: false, | ||
props: Props; | ||
state: State = { | ||
error: null, | ||
errorInfo: null | ||
}; | ||
|
||
componentDidCatch() { | ||
this.setState({ | ||
hasError: true, | ||
}); | ||
componentDidCatch(error, errorInfo) { | ||
// Catch errors in any components below and re-render with error message | ||
this.setState({ | ||
error: error, | ||
errorInfo: errorInfo | ||
}) | ||
// You can also log error messages to an error reporting service here | ||
} | ||
|
||
render() { | ||
const { hasError } = this.state; | ||
if (this.state.errorInfo) { | ||
|
||
if (hasError) { | ||
return null; | ||
// Error path | ||
return <Styles.Container className="govuk-width-container" role="main"> | ||
<PageTitle title={"Something went wrong"} /> | ||
|
||
<p className="govuk-body"> | ||
There was an error. Please try again later. | ||
</p> | ||
<p className="govuk-body"> | ||
If the problem persists, contact us via <a href="mailto:[email protected]" className="govuk-link">[email protected]</a> and include: | ||
</p> | ||
<ul className="govuk-list govuk-list--bullet"> | ||
<li>details of what you were trying to do that caused the problem</li> | ||
<li>your operating system (such as Windows, Mac OS, Android, iOS) and its version if possible</li> | ||
<li>your platform (such as mobile, tablet, computer)</li> | ||
<li>your browser (such as Chrome, Edge, Firefox, Internet Explorer)</li> | ||
<li>the technical details quoted below</li> | ||
</ul> | ||
<details className="govuk-details" data-module="govuk-details"> | ||
<summary className="govuk-details__summary"> | ||
<span className="govuk-details__summary-text"> | ||
Technical details | ||
</span> | ||
</summary> | ||
<Styles.DetailsBody className="govuk-details__text"> | ||
{this.state.error && this.state.error.toString()} | ||
<br/> | ||
{this.state.errorInfo.componentStack} | ||
</Styles.DetailsBody> | ||
</details> | ||
|
||
</Styles.Container> | ||
|
||
} | ||
// Normally, just render children | ||
return this.props.children; | ||
} | ||
return this.props.children; | ||
} | ||
|
||
} |
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,19 @@ | ||
// @flow | ||
|
||
import styled from 'styled-components'; | ||
import type { ComponentType } from 'react'; | ||
|
||
export const Container: ComponentType<*> = (() => { | ||
return styled.main ` | ||
display: flex; | ||
flex-direction: column; | ||
margin-top: 45px; | ||
margin-bottom: 120px; | ||
`; | ||
})(); | ||
|
||
export const DetailsBody: ComponentType<*> = (() => { | ||
return styled.div ` | ||
white-space: pre-wrap; | ||
`; | ||
})(); |
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,3 @@ | ||
// @flow | ||
|
||
export type Props = {||}; |
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
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
Oops, something went wrong.