forked from eyra/feldspar
-
Notifications
You must be signed in to change notification settings - Fork 14
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 #6 from d3i-infra/error-screen
error page is now back, pyodide errors are caught and shown to the user
- Loading branch information
Showing
4 changed files
with
98 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Weak } from '../../../../helpers' | ||
import { PropsUIPageError } from '../../../../types/pages' | ||
import { ReactFactoryContext } from '../../factory' | ||
import { Page } from './templates/page' | ||
import TextBundle from '../../../../text_bundle' | ||
import { Translator } from '../../../../translator' | ||
import { BodyLarge, Title1 } from '../elements/text' | ||
|
||
type Props = Weak<PropsUIPageError> & ReactFactoryContext | ||
|
||
export const ErrorPage = (props: Props): JSX.Element => { | ||
// render to top of the page on reload | ||
window.scrollTo(0, 0) | ||
|
||
const { stacktrace } = props | ||
const { title, text } = prepareCopy(props) | ||
|
||
const body: JSX.Element = ( | ||
<> | ||
<Title1 text={title} /> | ||
<BodyLarge text={text} /> | ||
<BodyLarge text={stacktrace} /> | ||
</> | ||
) | ||
|
||
return ( | ||
<Page | ||
body={body} | ||
/> | ||
) | ||
} | ||
|
||
interface Copy { | ||
title: string | ||
text: string | ||
} | ||
|
||
function prepareCopy ({ locale }: Props): Copy { | ||
return { | ||
title: Translator.translate(title, locale), | ||
text: Translator.translate(text, locale) | ||
} | ||
} | ||
|
||
const title = new TextBundle() | ||
.add('en', 'Error, not your fault!') | ||
.add('nl', 'Foutje, niet jouw schuld!') | ||
|
||
const text = new TextBundle() | ||
.add('en', 'Consult the researcher, or close the page') | ||
.add('nl', 'Raadpleeg de onderzoeker of sluit de pagina') |