1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 09:18:09 +00:00

FirmwareUpdate: notification button click + "cancel" action conditionally

This commit is contained in:
Szymon Lesisz 2018-10-05 09:03:51 +02:00
parent a84abda5ae
commit 3512c271e2
3 changed files with 43 additions and 13 deletions

View File

@ -320,9 +320,13 @@ export const gotoBridgeUpdate = (): ThunkAction => (dispatch: Dispatch): void =>
/*
* Go to UpdateFirmware page
* Called from App notification
*/
export const gotoFirmwareUpdate = (): ThunkAction => (dispatch: Dispatch): void => {
dispatch(goto('/firmware-update'));
export const gotoFirmwareUpdate = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
const { selectedDevice } = getState().wallet;
if (!selectedDevice || !selectedDevice.features) return;
const devUrl: string = `${selectedDevice.features.device_id}${selectedDevice.instance ? `:${selectedDevice.instance}` : ''}`;
dispatch(goto(`/device/${devUrl}/firmware-update`));
};
/*

View File

@ -14,10 +14,8 @@ export default (props: Props) => {
title="Firmware update"
actions={
[{
label: 'Read more',
callback: async () => {
},
label: 'Update',
callback: props.routerActions.gotoFirmwareUpdate,
}]
}
/>

View File

@ -1,13 +1,32 @@
/* @flow */
import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { NavLink } from 'react-router-dom';
import styled from 'styled-components';
import { H1 } from 'components/Heading';
import P from 'components/Paragraph';
import colors from 'config/colors';
import Link from 'components/Link';
import Button from 'components/Button';
import { connect } from 'react-redux';
import { NavLink } from 'react-router-dom';
import { FONT_SIZE } from 'config/variables';
import * as deviceUtils from 'utils/device';
import * as RouterActions from 'actions/RouterActions';
import type {
TrezorDevice,
State,
Dispatch,
} from 'flowtype';
type Props = {
device: ?TrezorDevice;
cancel: typeof RouterActions.selectFirstAvailableDevice,
}
const Wrapper = styled.section`
display: flex;
@ -31,7 +50,7 @@ const StyledP = styled(P)`
padding: 0 0 15px 0;
`;
const FirmwareUpdate = () => (
const FirmwareUpdate = (props: Props) => (
<Wrapper>
<Image>
<svg width="181px" height="134px" viewBox="0 0 181 134" version="1.1" xmlns="http://www.w3.org/2000/svg">
@ -114,10 +133,19 @@ const FirmwareUpdate = () => (
<Link href="https://wallet.trezor.io" target="_blank">
<Button>Take me to the old wallet</Button>
</Link>
{deviceUtils.isDeviceAccessible(props.device) && (
<StyledNavLink to="/">
Ill do that later.
</StyledNavLink>
)}
</Wrapper>
);
export default connect(null, null)(FirmwareUpdate);
export default connect(
(state: State) => ({
device: state.wallet.selectedDevice,
}),
(dispatch: Dispatch) => ({
cancel: bindActionCreators(RouterActions.selectFirstAvailableDevice, dispatch),
}),
)(FirmwareUpdate);