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

Fixed bootloader menu

This commit is contained in:
Vladimir Volek 2018-10-03 15:50:24 +02:00
parent 9d9340732f
commit e0f3bb4477
3 changed files with 23 additions and 7 deletions

View File

@ -42,7 +42,7 @@ const ClickWrapper = styled.div`
cursor: pointer; cursor: pointer;
${props => props.disabled && css` ${props => props.disabled && css`
cursor: not-allowed; cursor: default;
`} `}
`; `;
@ -93,7 +93,14 @@ const Dot = styled.div`
const DeviceHeader = ({ const DeviceHeader = ({
isOpen, icon, device, isHoverable = true, onClickWrapper, disabled = false, isSelected = false, isOpen,
icon,
device,
isHoverable = true,
onClickWrapper,
isBootloader = false,
disabled = false,
isSelected = false,
}) => { }) => {
const status = getStatus(device); const status = getStatus(device);
return ( return (
@ -116,7 +123,7 @@ const DeviceHeader = ({
<Status>{getStatusName(status)}</Status> <Status>{getStatusName(status)}</Status>
</LabelWrapper> </LabelWrapper>
<IconWrapper> <IconWrapper>
{icon && !disabled && icon} {icon && !disabled && !isBootloader && icon}
</IconWrapper> </IconWrapper>
</ClickWrapper> </ClickWrapper>
</Wrapper> </Wrapper>
@ -124,6 +131,7 @@ const DeviceHeader = ({
}; };
DeviceHeader.propTypes = { DeviceHeader.propTypes = {
isBootloader: PropTypes.bool,
device: PropTypes.object, device: PropTypes.object,
icon: PropTypes.element, icon: PropTypes.element,
isHoverable: PropTypes.bool, isHoverable: PropTypes.bool,

View File

@ -4,6 +4,7 @@ import Icon from 'components/Icon';
import DeviceHeader from 'components/DeviceHeader'; import DeviceHeader from 'components/DeviceHeader';
import icons from 'config/icons'; import icons from 'config/icons';
import colors from 'config/colors'; import colors from 'config/colors';
import { withRouter } from 'react-router-dom';
const Wrapper = styled.div``; const Wrapper = styled.div``;
const IconClick = styled.div``; const IconClick = styled.div``;
@ -14,6 +15,10 @@ class DeviceList extends Component {
return a.instance > b.instance ? 1 : -1; return a.instance > b.instance ? 1 : -1;
} }
redirectToBootloader(selectedDevice) {
this.props.history.push(`/device/${selectedDevice.features.device_id}/bootloader`);
}
render() { render() {
const { const {
devices, selectedDevice, onSelectDevice, forgetDevice, devices, selectedDevice, onSelectDevice, forgetDevice,
@ -26,10 +31,12 @@ class DeviceList extends Component {
device !== selectedDevice && ( device !== selectedDevice && (
<DeviceHeader <DeviceHeader
key={device.state || device.path} key={device.state || device.path}
disabled={device.features && device.features.bootloader_mode} isBootloader={device.features.bootloader_mode}
onClickWrapper={() => { onClickWrapper={() => {
if (device.features if (device.features) {
&& !device.features.bootloader_mode) { if (device.features.bootloader_mode) {
this.redirectToBootloader(selectedDevice);
}
onSelectDevice(device); onSelectDevice(device);
} }
}} }}
@ -62,4 +69,4 @@ class DeviceList extends Component {
} }
} }
export default DeviceList; export default withRouter(DeviceList);

View File

@ -187,6 +187,7 @@ class LeftNavigation extends React.PureComponent<Props, State> {
> >
<Header <Header
isSelected isSelected
isHoverable={false}
onClickWrapper={() => { onClickWrapper={() => {
if (!isDeviceInBootloader || this.props.devices.length > 1) { if (!isDeviceInBootloader || this.props.devices.length > 1) {
this.handleOpen(); this.handleOpen();