Browse Source

fix connecting step and flash step

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

14
src/components/SettingsPage/RepairDeviceButton.js

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

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

@ -46,49 +46,48 @@ const DisclaimerStep = ({ desc }: { desc?: string }) => (
</ModalContent> </ModalContent>
) )
const ConnectStep = ({ t }: { t: * }) => ( const FlashStep = ({ progress, t }: { progress: number, t: * }) =>
<ModalContent> progress === 0 ? (
<Box mx={7}> <ModalContent>
<Text ff="Open Sans|Regular" align="center" color="smoke"> <Box mx={7}>
<Bullet>{'1.'}</Bullet> <Text ff="Open Sans|Regular" align="center" color="smoke">
{t('manager.modal.mcuFirst')} <Bullet>{'1.'}</Bullet>
</Text> {t('manager.modal.mcuFirst')}
<img </Text>
src={i('logos/unplugDevice.png')} <img
style={{ width: '100%', maxWidth: 368, marginTop: 30 }} src={i('logos/unplugDevice.png')}
alt={t('manager.modal.mcuFirst')} style={{ width: '100%', maxWidth: 368, marginTop: 30 }}
/> alt={t('manager.modal.mcuFirst')}
</Box> />
<Separator my={6} /> </Box>
<Box mx={7}> <Separator my={6} />
<Text ff="Open Sans|Regular" align="center" color="smoke"> <Box mx={7}>
<Bullet>{'2.'}</Bullet> <Text ff="Open Sans|Regular" align="center" color="smoke">
{t('manager.modal.mcuSecond')} <Bullet>{'2.'}</Bullet>
</Text> {t('manager.modal.mcuSecond')}
<img </Text>
src={i('logos/bootloaderMode.png')} <img
style={{ width: '100%', maxWidth: 368, marginTop: 30 }} src={i('logos/bootloaderMode.png')}
alt={t('manager.modal.mcuFirst')} style={{ width: '100%', maxWidth: 368, marginTop: 30 }}
/> alt={t('manager.modal.mcuFirst')}
</Box> />
</ModalContent> </Box>
) </ModalContent>
) : (
const FlashStep = ({ progress, t }: { progress: number, t: * }) => ( <ModalContent>
<ModalContent> <Box mx={7} align="center">
<Box mx={7} align="center"> <ProgressCircle size={64} progress={progress} />
<ProgressCircle size={64} progress={progress} /> </Box>
</Box> <Box mx={7} mt={3} mb={2} ff="Museo Sans|Regular" color="dark" textAlign="center">
<Box mx={7} mt={3} mb={2} ff="Museo Sans|Regular" color="dark" textAlign="center"> {t(`manager.modal.steps.flash`)}
{t(`manager.modal.steps.flash`)} </Box>
</Box> <Box mx={7} mt={2} mb={2}>
<Box mx={7} mt={2} mb={2}> <Text ff="Open Sans|Regular" align="center" color="graphite" fontSize={4}>
<Text ff="Open Sans|Regular" align="center" color="graphite" fontSize={4}> {t('manager.modal.mcuPin')}
{t('manager.modal.mcuPin')} </Text>
</Text> </Box>
</Box> </ModalContent>
</ModalContent> )
)
const ErrorStep = ({ error }: { error: Error }) => ( const ErrorStep = ({ error }: { error: Error }) => (
<ModalContent> <ModalContent>
@ -137,15 +136,9 @@ type Props = {
cancellable?: boolean, cancellable?: boolean,
progress: number, progress: number,
error?: Error, error?: Error,
confirmed: boolean,
setConfirm: Function,
}
type State = {
confirmed: boolean,
} }
class RepairModal extends PureComponent<Props, State> { class RepairModal extends PureComponent<Props> {
render() { render() {
const { const {
cancellable, cancellable,
@ -162,8 +155,6 @@ class RepairModal extends PureComponent<Props, State> {
analyticsName, analyticsName,
progress, progress,
error, error,
confirmed,
setConfirm,
...props ...props
} = this.props } = this.props
@ -182,28 +173,26 @@ class RepairModal extends PureComponent<Props, State> {
<ErrorStep error={error} /> <ErrorStep error={error} />
) : isLoading ? ( ) : isLoading ? (
<FlashStep t={t} progress={progress} /> <FlashStep t={t} progress={progress} />
) : confirmed ? (
<ConnectStep t={t} desc={desc} />
) : ( ) : (
<DisclaimerStep desc={desc} /> <DisclaimerStep desc={desc} />
)} )}
<ModalFooter horizontal align="center" justify="flex-end" flow={2}> {!isLoading ? (
{!isLoading && ( <ModalFooter horizontal align="center" justify="flex-end" flow={2}>
<Button onClick={onReject}>{t(`common.${error ? 'close' : 'cancel'}`)}</Button> <Button onClick={onReject}>{t(`common.${error ? 'close' : 'cancel'}`)}</Button>
)} {error ? null : (
{error ? null : ( <Button
<Button onClick={onConfirm}
onClick={confirmed ? onConfirm : setConfirm} primary={!isDanger}
primary={!isDanger} danger={isDanger}
danger={isDanger} isLoading={isLoading}
isLoading={isLoading} disabled={isLoading}
disabled={isLoading} >
> {realConfirmText}
{confirmed ? realConfirmText : t('common.confirm')} </Button>
</Button> )}
)} </ModalFooter>
</ModalFooter> ) : null}
</ModalBody> </ModalBody>
)} )}
/> />

Loading…
Cancel
Save