1
0
mirror of https://github.com/trezor/trezor-wallet synced 2025-02-22 21:12:04 +00:00

devicemeuni while one of devices is in bootloader/not-initialized mode

This commit is contained in:
Szymon Lesisz 2018-09-21 10:37:19 +02:00
parent 54603f62a1
commit 6fc69f00c8
5 changed files with 22 additions and 17 deletions

View File

@ -43,7 +43,15 @@ const getStatusName = (deviceStatus) => {
const isWebUSB = transport => !!((transport && transport.version.indexOf('webusb') >= 0));
const isDisabled = (selectedDevice, devices, transport) => (devices.length < 1 && !isWebUSB(transport)) || (devices.length === 1 && !selectedDevice.features && !isWebUSB(transport));
const isDisabled = (selectedDevice, devices, transport) => {
if (isWebUSB(transport)) return false; // always enabled if webusb
if (devices.length < 1) return true; // no devices
if (devices.length === 1) {
if (!selectedDevice.features) return true; // unacquired, unreadable
if (selectedDevice.features.bootloader_mode || !selectedDevice.features.initialized) return true; // bootlader, not initialized
}
return false; // default
}
const getVersion = (device) => {
let version;

View File

@ -20,7 +20,6 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
connect: state.connect,
accounts: state.accounts,
router: state.router,
deviceDropdownOpened: state.wallet.dropdownOpened,
fiat: state.fiat,
localStorage: state.localStorage,
discovery: state.discovery,

View File

@ -41,6 +41,11 @@ class MenuItems extends Component {
}
}
showDeviceMenu() {
const device = this.props.device;
return device && device.features && !device.features.bootloader_mode && device.features.initialized;
}
showClone() {
return this.props.device && this.props.device.features.passphrase_protection && this.props.device.connected && this.props.device.available;
}
@ -50,6 +55,7 @@ class MenuItems extends Component {
}
render() {
if (!this.showDeviceMenu()) return null;
return (
<Wrapper>
<Item onClick={() => this.onDeviceMenuClick('settings', this.props.device)}>

View File

@ -7,7 +7,6 @@ export type StateProps = {
connect: $ElementType<State, 'connect'>,
accounts: $ElementType<State, 'accounts'>,
router: $ElementType<State, 'router'>,
deviceDropdownOpened: boolean,
fiat: $ElementType<State, 'fiat'>,
localStorage: $ElementType<State, 'localStorage'>,
discovery: $ElementType<State, 'discovery'>,

View File

@ -75,27 +75,21 @@ class LeftNavigation extends Component {
}
componentWillReceiveProps(nextProps) {
const { deviceDropdownOpened } = nextProps;
const { selectedDevice } = nextProps.wallet;
const { dropdownOpened, selectedDevice } = nextProps.wallet;
const hasNetwork = nextProps.location.state && nextProps.location.state.network;
const hasFeatures = selectedDevice && selectedDevice.features;
const deviceReady = hasFeatures && !selectedDevice.features.bootloader_mode && selectedDevice.features.initialized;
if (deviceDropdownOpened) {
if (dropdownOpened) {
this.setState({ shouldRenderDeviceSelection: true });
} else if (hasNetwork) {
this.setState({
shouldRenderDeviceSelection: false,
animationType: 'slide-left',
});
} else if (deviceReady) {
this.setState({
shouldRenderDeviceSelection: false,
animationType: 'slide-right',
});
} else if (selectedDevice.features.bootloader_mode) {
} else {
this.setState({
shouldRenderDeviceSelection: false,
animationType: deviceReady ? 'slide-right' : null,
});
}
}
@ -134,7 +128,7 @@ class LeftNavigation extends Component {
}
handleOpen() {
this.props.toggleDeviceDropdown(!this.props.deviceDropdownOpened);
this.props.toggleDeviceDropdown(!this.props.wallet.dropdownOpened);
}
shouldRenderCoins() {
@ -145,14 +139,14 @@ class LeftNavigation extends Component {
return (
<StickyContainer
location={this.props.location.pathname}
deviceSelection={this.props.deviceDropdownOpened}
deviceSelection={this.props.wallet.dropdownOpened}
>
<Header
onClickWrapper={() => this.handleOpen()}
device={this.props.wallet.selectedDevice}
transport={this.props.connect.transport}
devices={this.props.devices}
isOpen={this.props.deviceDropdownOpened}
isOpen={this.props.wallet.dropdownOpened}
{...this.props}
/>
<Body>
@ -179,7 +173,6 @@ class LeftNavigation extends Component {
LeftNavigation.propTypes = {
selectedDevice: PropTypes.object,
wallet: PropTypes.object,
deviceDropdownOpened: PropTypes.bool,
};