Browse Source

fixes on modal ui and navigate to manager when repair is finished

gre-patch-1
Valentin D. Pinkman 6 years ago
parent
commit
228d2dfeed
No known key found for this signature in database GPG Key ID: E7D110669FFB8D3E
  1. 24
      src/components/SettingsPage/RepairDeviceButton.js
  2. 14
      src/components/base/Modal/RepairModal.js

24
src/components/SettingsPage/RepairDeviceButton.js

@ -1,7 +1,12 @@
// @flow
import React, { Fragment, PureComponent } from 'react'
import { compose } from 'redux'
import { connect } from 'react-redux'
import { withRouter } from 'react-router'
import { translate } from 'react-i18next'
import { push } from 'react-router-redux'
import type { T } from 'types/common'
import firmwareRepair from 'commands/firmwareRepair'
import Button from 'components/base/Button'
@ -9,6 +14,7 @@ import { RepairModal } from 'components/base/Modal'
type Props = {
t: T,
push: Function,
}
type State = {
@ -37,6 +43,7 @@ class RepairDeviceButton extends PureComponent<Props, State> {
action = () => {
if (this.state.isLoading) return
const { push } = this.props
this.setState({ isLoading: true })
this.sub = firmwareRepair.send().subscribe({
next: patch => {
@ -46,7 +53,9 @@ class RepairDeviceButton extends PureComponent<Props, State> {
this.setState({ error, isLoading: false })
},
complete: () => {
this.setState({ opened: false, isLoading: false })
this.setState({ opened: false, isLoading: false }, () => {
push('/manager')
})
},
})
}
@ -80,4 +89,15 @@ class RepairDeviceButton extends PureComponent<Props, State> {
}
}
export default translate()(RepairDeviceButton)
const mapDispatchToProps = {
push,
}
export default compose(
translate(),
withRouter,
connect(
null,
mapDispatchToProps,
),
)(RepairDeviceButton)

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

@ -63,7 +63,7 @@ const ConnectStep = ({ t, desc }: { t: *, desc?: string }) => (
)
const FlashStep = ({ progress, t }: { progress: number, t: * }) => (
<>
<ModalContent>
<Box mx={7} align="center">
<ProgressCircle size={64} progress={progress} />
</Box>
@ -77,13 +77,15 @@ const FlashStep = ({ progress, t }: { progress: number, t: * }) => (
{t('manager.modal.mcuPin')}
</Text>
</Box>
</>
</ModalContent>
)
const ErrorStep = ({ error }: { error: Error }) => (
<Box mx={7} mt={4} mb={6} align="center">
<TranslatedError error={error} />
</Box>
<ModalContent>
<Box mx={7} mt={4} mb={6} align="center">
<TranslatedError error={error} />
</Box>
</ModalContent>
)
type Props = {
@ -136,7 +138,7 @@ class RepairModal extends PureComponent<Props> {
<ModalBody onClose={!cancellable && isLoading ? undefined : onClose}>
<TrackPage category="Modal" name={analyticsName} />
<ModalTitle>{title}</ModalTitle>
{isLoading && progress > 0 ? (
{isLoading ? (
<FlashStep t={t} progress={progress} />
) : error ? (
<ErrorStep error={error} />

Loading…
Cancel
Save