Valentin D. Pinkman
6 years ago
No known key found for this signature in database
GPG Key ID: E7D110669FFB8D3E
6 changed files with
46 additions and
28 deletions
package.json
src/commands/firmwareRepair.js
src/components/SettingsPage/RepairDeviceButton.js
src/components/base/Modal/RepairModal.js
static/i18n/en/app.json
yarn.lock
@ -41,7 +41,7 @@
"@ledgerhq/hw-transport" : "^4.32.0" ,
"@ledgerhq/hw-transport-node-hid" : "^4.32.0" ,
"@ledgerhq/ledger-core" : "2.0.0-rc.14" ,
"@ledgerhq/live-common" : "4.8.1 " ,
"@ledgerhq/live-common" : "4.10.0 " ,
"animated" : "^0.2.2" ,
"async" : "^2.6.1" ,
"axios" : "^0.18.0" ,
@ -3,12 +3,15 @@
import repair from '@ledgerhq/live-common/lib/hw/firmwareUpdate-repair'
import { createCommand , Command } from 'helpers/ipc'
type Input = void
type Input = {
version : ? string ,
}
type Result = { progress : number }
const cmd : Command < Input , Result > = createCommand (
'firmwareRepair' ,
( ) => repair ( '' ) , // devicePath='' HACK to not depend on a devicePath because it's dynamic
( { version } ) => repair ( '' ) , // devicePath='' HACK to not depend on a devicePath because it's dynamic
)
export default cmd
@ -41,11 +41,11 @@ class RepairDeviceButton extends PureComponent<Props, State> {
this . setState ( { opened : false , isLoading : false , error : null , progress : 0 } )
}
action = ( ) => {
repair = ( version = null ) => {
if ( this . state . isLoading ) return
const { push } = this . props
this . setState ( { isLoading : true } )
this . sub = firmwareRepair . send ( ) . subscribe ( {
this . sub = firmwareRepair . send ( { version } ) . subscribe ( {
next : patch => {
this . setState ( patch )
} ,
@ -60,6 +60,8 @@ class RepairDeviceButton extends PureComponent<Props, State> {
} )
}
repairMcu = ( ) => this . repair ( '0.8' )
render ( ) {
const { t } = this . props
const { opened , isLoading , error , progress } = this . state
@ -76,11 +78,11 @@ class RepairDeviceButton extends PureComponent<Props, State> {
isOpened = { opened }
onClose = { this . close }
onReject = { this . close }
onConfirm = { this . action }
onRepair = { this . repair }
onRepairMCU = { this . repair }
isLoading = { isLoading }
title = { t ( 'settings.repairDevice.title' ) }
desc = { t ( 'settings.repairDevice.desc' ) }
confirmText = { t ( 'settings.repairDevice.button' ) }
progress = { progress }
error = { error }
/ >
@ -129,7 +129,8 @@ type Props = {
confirmText ? : string ,
cancelText ? : string ,
onReject : Function ,
onConfirm : Function ,
onRepair : Function ,
onRepairMCU : Function ,
t : T ,
isLoading ? : boolean ,
analyticsName : string ,
@ -148,7 +149,8 @@ class RepairModal extends PureComponent<Props> {
confirmText ,
isDanger ,
onReject ,
onConfirm ,
onRepair ,
onRepairMCU ,
isLoading ,
renderIcon ,
t ,
@ -158,8 +160,6 @@ class RepairModal extends PureComponent<Props> {
... props
} = this . props
const realConfirmText = confirmText || t ( 'common.confirm' )
return (
< Modal
isOpened = { isOpened }
@ -178,18 +178,29 @@ class RepairModal extends PureComponent<Props> {
) }
{ ! isLoading ? (
< ModalFooter horizontal align = "center" justify = "flex-end " flow = { 2 } >
< Button onClick = { onReject } > { t ( ` common. ${ error ? 'close' : 'cancel' } ` ) } < / B u t t o n >
< ModalFooter horizontal align = "center" justify = "space-between " flow = { 2 } >
{ error ? < Button onClick = { onReject } > { t ( ` common.close ` ) } < / B u t t o n > : n u l l }
{ error ? null : (
< Button
onClick = { onConfirm }
primary = { ! isDanger }
danger = { isDanger }
isLoading = { isLoading }
disabled = { isLoading }
>
{ realConfirmText }
< / B u t t o n >
< >
< Button
onClick = { onRepair }
primary = { ! isDanger }
danger = { isDanger }
isLoading = { isLoading }
disabled = { isLoading }
>
{ t ( 'settings.repairDevice.repair' ) }
< / B u t t o n >
< Button
onClick = { onRepair }
primary = { ! isDanger }
danger = { isDanger }
isLoading = { isLoading }
disabled = { isLoading }
>
{ t ( 'settings.repairDevice.mcu' ) }
< / B u t t o n >
< / >
) }
< / M o d a l F o o t e r >
) : null }
@ -451,8 +451,10 @@
} ,
"repairDevice" : {
"title" : "Repair your Ledger device" ,
"desc" : "If you encountered some issue while updating your device and cannot resume the update process, you can try this option to repair your device." ,
"button" : "Repair"
"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" ,
"repair" : "Stuck in 'Bootloader'" ,
"mcu" : "Stuck in 'MCU not genuine'"
} ,
"exportLogs" : {
"title" : "Export logs" ,
@ -1725,10 +1725,10 @@
bindings "^1.3.0"
nan "^2.6.2"
"@ledgerhq/live-common@4.8.1 ":
version "4.8.1 "
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-4.8.1.tgz#3327b438d18ab02f54fed08756439d7637a631a0 "
integrity sha512-5Bw74PCPMpMny4/Ro0t/Pi6lYj5bMkcF/1tzX+l++RMkiwvE3+gP7gqW5Vk3waU7i6FOUk22aMMgFYDcQx7O+g ==
"@ledgerhq/live-common@4.10.0 ":
version "4.10.0 "
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-4.10.0.tgz#4f34679cebf51cf98123c5b072a948e72ff4f566 "
integrity sha512-ui/v3IWsNvih6BSnpL+65K+R92QVGR/myza9QGuyvCWChy79b2vWXYYQpydgyogUkUY+oyENvpvAiM+AnPV8fw ==
dependencies:
"@aeternity/ledger-app-api" "0.0.4"
"@ledgerhq/hw-app-btc" "^4.32.0"