Browse Source

More generic UI to handle more cases

gre-patch-1
Gaëtan Renaudeau 6 years ago
parent
commit
b2552cf7af
No known key found for this signature in database GPG Key ID: 7B66B85F042E5451
  1. 62
      src/components/base/Modal/RepairModal.js
  2. 6
      static/i18n/en/app.json
  3. 8
      yarn.lock

62
src/components/base/Modal/RepairModal.js

@ -11,6 +11,7 @@ import TrackPage from 'analytics/TrackPage'
import Button from 'components/base/Button' import Button from 'components/base/Button'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import Text from 'components/base/Text' import Text from 'components/base/Text'
import Select from 'components/base/Select'
import ProgressCircle from 'components/ProgressCircle' import ProgressCircle from 'components/ProgressCircle'
import TranslatedError from 'components/TranslatedError' import TranslatedError from 'components/TranslatedError'
import ExclamationCircleThin from 'icons/ExclamationCircleThin' import ExclamationCircleThin from 'icons/ExclamationCircleThin'
@ -129,7 +130,7 @@ type Props = {
confirmText?: string, confirmText?: string,
cancelText?: string, cancelText?: string,
onReject: Function, onReject: Function,
repair: ?string=>*, repair: (?string) => *,
t: T, t: T,
isLoading?: boolean, isLoading?: boolean,
analyticsName: string, analyticsName: string,
@ -138,7 +139,22 @@ type Props = {
error?: Error, error?: Error,
} }
class RepairModal extends PureComponent<Props> { const options = [{ value: 'generic' }, { value: '0_8' }, { value: '0_9' }]
class RepairModal extends PureComponent<Props, *> {
state = {
selectedOption: options[0],
}
onChange = selectedOption => {
this.setState({ selectedOption })
}
renderOption = option => (option && this.props.t(`settings.repairDevice.${option.value}`)) || null
renderValue = option =>
(option && this.props.t(`settings.repairDevice.${option.data.value}`)) || null
render() { render() {
const { const {
cancellable, cancellable,
@ -157,6 +173,7 @@ class RepairModal extends PureComponent<Props> {
error, error,
...props ...props
} = this.props } = this.props
const { selectedOption } = this.state
return ( return (
<Modal <Modal
@ -175,37 +192,36 @@ class RepairModal extends PureComponent<Props> {
<DisclaimerStep desc={desc} /> <DisclaimerStep desc={desc} />
)} )}
{!isLoading && !error ? (
<Box py={2} px={4}>
<Select
value={selectedOption}
onChange={this.onChange}
autoFocus
options={options}
renderOption={this.renderOption}
renderValue={this.renderValue}
/>
</Box>
) : null}
{!isLoading ? ( {!isLoading ? (
<ModalFooter horizontal align="center" justify="space-between" flow={2}> <ModalFooter horizontal align="center" justify="flex-end" flow={2}>
{error ? <Button onClick={onReject}>{t(`common.close`)}</Button> : null} {error ? <Button onClick={onReject}>{t(`common.close`)}</Button> : null}
{error ? null : ( {error ? null : (
<> <>
<Button <Button
onClick={() => repair()} onClick={() =>
primary={!isDanger} repair(
danger={isDanger} selectedOption.value === 'generic' ? undefined : selectedOption.value,
isLoading={isLoading} )
disabled={isLoading} }
>
{t('settings.repairDevice.generic')}
</Button>
<Button
onClick={() => repair("0.8")}
primary={!isDanger}
danger={isDanger}
isLoading={isLoading}
disabled={isLoading}
>
{t('settings.repairDevice.0_8')}
</Button>
<Button
onClick={() => repair("0.9")}
primary={!isDanger} primary={!isDanger}
danger={isDanger} danger={isDanger}
isLoading={isLoading} isLoading={isLoading}
disabled={isLoading} disabled={isLoading}
> >
{t('settings.repairDevice.0_9')} {t('settings.repairDevice.button')}
</Button> </Button>
</> </>
)} )}

6
static/i18n/en/app.json

@ -453,9 +453,9 @@
"title": "Repair your Ledger device", "title": "Repair your Ledger device",
"desc": "If you encountered some issue while updating your Ledger Nano S and cannot resume the update process, you can try this option to repair your device.", "desc": "If you encountered some issue while updating your Ledger Nano S and cannot resume the update process, you can try this option to repair your device.",
"button": "Repair", "button": "Repair",
"generic": "'Bootloader'", "generic": "Stuck in 'Bootloader'",
"0_8": "'MCU not genuine'", "0_8": "Stuck in 'MCU not genuine'",
"0_9": "'follow repair instruction'" "0_9": "Stuck in 'follow repair instruction'"
}, },
"exportLogs": { "exportLogs": {
"title": "Export logs", "title": "Export logs",

8
yarn.lock

@ -1725,10 +1725,10 @@
bindings "^1.3.0" bindings "^1.3.0"
nan "^2.6.2" nan "^2.6.2"
"@ledgerhq/live-common@4.10.0": "@ledgerhq/live-common@4.10.1":
version "4.10.0" version "4.10.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-4.10.0.tgz#4f34679cebf51cf98123c5b072a948e72ff4f566" resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-4.10.1.tgz#34aa77b692a0aff268b6ef741c2e9ecc1bfcc9c0"
integrity sha512-ui/v3IWsNvih6BSnpL+65K+R92QVGR/myza9QGuyvCWChy79b2vWXYYQpydgyogUkUY+oyENvpvAiM+AnPV8fw== integrity sha512-G5oKHfb0aV+xPOC2+X6xYquvViR+u9iSRTRnC2h82koHnQujbqkI+Lt1hpeEvEwpsaunxqlT/0JV6q/ORNVbtw==
dependencies: dependencies:
"@aeternity/ledger-app-api" "0.0.4" "@aeternity/ledger-app-api" "0.0.4"
"@ledgerhq/hw-app-btc" "^4.32.0" "@ledgerhq/hw-app-btc" "^4.32.0"

Loading…
Cancel
Save