From a9313ec197841a9211da941f0ddd8f94fdc75f93 Mon Sep 17 00:00:00 2001 From: meriadec Date: Wed, 20 Jun 2018 11:19:25 +0200 Subject: [PATCH 1/3] Improve crash screen design and behaviour --- src/components/RenderError.js | 73 ++++++++++++++++++---------------- static/i18n/en/app.yml | 6 ++- static/images/crash-screen.svg | 1 + 3 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 static/images/crash-screen.svg diff --git a/src/components/RenderError.js b/src/components/RenderError.js index f8fb8a42..23034422 100644 --- a/src/components/RenderError.js +++ b/src/components/RenderError.js @@ -1,20 +1,20 @@ // @flow import React, { PureComponent } from 'react' -import styled from 'styled-components' import { shell, remote } from 'electron' import qs from 'querystring' import { translate } from 'react-i18next' -import { rgba } from 'styles/helpers' -import db from 'helpers/db' +import { i } from 'helpers/staticPath' +import hardReset from 'helpers/hardReset' import type { T } from 'types/common' import ExportLogsBtn from 'components/ExportLogsBtn' import Box from 'components/base/Box' +import Space from 'components/base/Space' import Button from 'components/base/Button' -import TranslatedError from './TranslatedError' +// import TranslatedError from './TranslatedError' type Props = { error: Error, @@ -23,25 +23,11 @@ type Props = { children?: *, } -const Container = styled(Box).attrs({ - grow: true, - align: 'center', - justify: 'center', - bg: 'lightGraphite', - color: 'alertRed', - ff: 'Museo Sans|Bold', - flow: 2, -})`` - -const Inner = styled(Box).attrs({ - p: 2, - bg: p => rgba(p.theme.colors.alertRed, 0.05), - borderRadius: 1, -})` - border: ${p => `1px solid ${rgba(p.theme.colors.alertRed, 0.1)}`}; -` +class RenderError extends PureComponent { + state = { + isHardResetting: false, + } -class RenderError extends PureComponent { handleCreateIssue = () => { const { error } = this.props if (!error) { @@ -60,27 +46,45 @@ ${error.stack} } handleRestart = () => { - remote.app.relaunch() - remote.app.exit() + remote.getCurrentWindow().webContents.reloadIgnoringCache() } - handleReset = () => { - db.resetAll() - this.handleRestart() + handleHardReset = async () => { + this.setState({ isHardResetting: true }) + try { + await hardReset() + remote.getCurrentWindow().webContents.reloadIgnoringCache() + } catch (err) { + this.setState({ isHardResetting: false }) + } } render() { - const { error, t, disableExport, children } = this.props + const { t, disableExport, children } = this.props + const { isHardResetting } = this.state return ( - - - - + + + + + {t('app:crash.oops')} + + + + {t('app:crash.uselessText')} + + - {!disableExport ? : null} @@ -89,9 +93,10 @@ ${error.stack} {children} - + ) } } +// export default translate()(RenderError) diff --git a/static/i18n/en/app.yml b/static/i18n/en/app.yml index 606a568f..ce8efa1c 100644 --- a/static/i18n/en/app.yml +++ b/static/i18n/en/app.yml @@ -368,6 +368,8 @@ update: newVersionReady: A new update is available. relaunch: Update now crash: + oops: Oops, something went wrong. + uselessText: You may try again by restarting Ledger Live. Please export your logs and contact Ledger Support if the problem persists. restart: Restart app - reset: Reset app files - createTicket: Create ticket + reset: Hard reset + createTicket: Create issue diff --git a/static/images/crash-screen.svg b/static/images/crash-screen.svg new file mode 100644 index 00000000..39fbc9a7 --- /dev/null +++ b/static/images/crash-screen.svg @@ -0,0 +1 @@ +Fichier 2 \ No newline at end of file From 7d5f29140ea24ae2fe5ca86352465285599671da Mon Sep 17 00:00:00 2001 From: meriadec Date: Wed, 20 Jun 2018 12:04:46 +0200 Subject: [PATCH 2/3] Display error and translated error inside crash screen --- src/components/RenderError.js | 37 +++++++++++++++++++++++++++++++---- static/i18n/en/app.yml | 2 ++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/components/RenderError.js b/src/components/RenderError.js index 23034422..bb2d05e8 100644 --- a/src/components/RenderError.js +++ b/src/components/RenderError.js @@ -10,11 +10,12 @@ import hardReset from 'helpers/hardReset' import type { T } from 'types/common' +import Spoiler from 'components/base/Spoiler' import ExportLogsBtn from 'components/ExportLogsBtn' import Box from 'components/base/Box' import Space from 'components/base/Space' import Button from 'components/base/Button' -// import TranslatedError from './TranslatedError' +import TranslatedError from './TranslatedError' type Props = { error: Error, @@ -60,10 +61,11 @@ ${error.stack} } render() { - const { t, disableExport, children } = this.props + const { error, t, disableExport, children } = this.props const { isHardResetting } = this.state return ( - + + @@ -92,11 +94,38 @@ ${error.stack} {t('app:crash.createTicket')} + + + + + + + + + {error.stack} + + {children} ) } } -// + +const ErrContainer = ({ children }: { children: any }) => ( +
+    {children}
+  
+) export default translate()(RenderError) diff --git a/static/i18n/en/app.yml b/static/i18n/en/app.yml index ce8efa1c..eb9db936 100644 --- a/static/i18n/en/app.yml +++ b/static/i18n/en/app.yml @@ -373,3 +373,5 @@ crash: restart: Restart app reset: Hard reset createTicket: Create issue + showDetails: Show details + showError: Show error From ddebe97455aa6d80226ade1b03e533ec86089542 Mon Sep 17 00:00:00 2001 From: meriadec Date: Wed, 20 Jun 2018 12:07:01 +0200 Subject: [PATCH 3/3] Change buttons order in crash screen --- src/components/RenderError.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/RenderError.js b/src/components/RenderError.js index bb2d05e8..1ffa1b80 100644 --- a/src/components/RenderError.js +++ b/src/components/RenderError.js @@ -86,13 +86,13 @@ ${error.stack} - {!disableExport ? : null} +