FirmwareUpdate: notification button click + "cancel" action conditionally

pull/127/head
Szymon Lesisz 6 years ago
parent a84abda5ae
commit 3512c271e2

@ -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`));
};
/*

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

@ -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>
<StyledNavLink to="/">
Ill do that later.
</StyledNavLink>
{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);

Loading…
Cancel
Save