|
|
@ -22,7 +22,6 @@ type State = { |
|
|
|
isLoading: boolean, |
|
|
|
error: ?Error, |
|
|
|
progress: number, |
|
|
|
confirmed: boolean, |
|
|
|
} |
|
|
|
|
|
|
|
class RepairDeviceButton extends PureComponent<Props, State> { |
|
|
@ -31,18 +30,15 @@ class RepairDeviceButton extends PureComponent<Props, State> { |
|
|
|
isLoading: false, |
|
|
|
error: null, |
|
|
|
progress: 0, |
|
|
|
confirmed: false, |
|
|
|
} |
|
|
|
|
|
|
|
open = () => this.setState({ opened: true, error: null }) |
|
|
|
|
|
|
|
setConfirm = () => this.setState({ confirmed: true }) |
|
|
|
|
|
|
|
sub: * |
|
|
|
|
|
|
|
close = () => { |
|
|
|
if (this.sub) this.sub.unsubscribe() |
|
|
|
this.setState({ opened: false, isLoading: false, error: null, confirmed: false }) |
|
|
|
this.setState({ opened: false, isLoading: false, error: null, progress: 0 }) |
|
|
|
} |
|
|
|
|
|
|
|
action = () => { |
|
|
@ -54,10 +50,10 @@ class RepairDeviceButton extends PureComponent<Props, State> { |
|
|
|
this.setState(patch) |
|
|
|
}, |
|
|
|
error: error => { |
|
|
|
this.setState({ error, isLoading: false, confirmed: false }) |
|
|
|
this.setState({ error, isLoading: false, progress: 0 }) |
|
|
|
}, |
|
|
|
complete: () => { |
|
|
|
this.setState({ opened: false, isLoading: false, confirmed: false }, () => { |
|
|
|
this.setState({ opened: false, isLoading: false, progress: 0 }, () => { |
|
|
|
push('/manager') |
|
|
|
}) |
|
|
|
}, |
|
|
@ -66,7 +62,7 @@ class RepairDeviceButton extends PureComponent<Props, State> { |
|
|
|
|
|
|
|
render() { |
|
|
|
const { t } = this.props |
|
|
|
const { opened, isLoading, error, progress, confirmed } = this.state |
|
|
|
const { opened, isLoading, error, progress } = this.state |
|
|
|
|
|
|
|
return ( |
|
|
|
<Fragment> |
|
|
@ -87,8 +83,6 @@ class RepairDeviceButton extends PureComponent<Props, State> { |
|
|
|
confirmText={t('settings.repairDevice.button')} |
|
|
|
progress={progress} |
|
|
|
error={error} |
|
|
|
setConfirm={this.setConfirm} |
|
|
|
confirmed={confirmed} |
|
|
|
/> |
|
|
|
</Fragment> |
|
|
|
) |
|
|
|