mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-28 03:08:30 +00:00
devicemeuni while one of devices is in bootloader/not-initialized mode
This commit is contained in:
parent
41ced76a48
commit
cde9206f08
@ -43,7 +43,15 @@ const getStatusName = (deviceStatus) => {
|
|||||||
|
|
||||||
const isWebUSB = transport => !!((transport && transport.version.indexOf('webusb') >= 0));
|
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) => {
|
const getVersion = (device) => {
|
||||||
let version;
|
let version;
|
||||||
|
@ -21,7 +21,6 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
connect: state.connect,
|
connect: state.connect,
|
||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
router: state.router,
|
router: state.router,
|
||||||
deviceDropdownOpened: state.wallet.dropdownOpened,
|
|
||||||
fiat: state.fiat,
|
fiat: state.fiat,
|
||||||
localStorage: state.localStorage,
|
localStorage: state.localStorage,
|
||||||
discovery: state.discovery,
|
discovery: state.discovery,
|
||||||
|
@ -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() {
|
showClone() {
|
||||||
return this.props.device && this.props.device.features.passphrase_protection && this.props.device.connected && this.props.device.available;
|
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() {
|
render() {
|
||||||
|
if (!this.showDeviceMenu()) return null;
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Item onClick={() => this.onDeviceMenuClick('settings', this.props.device)}>
|
<Item onClick={() => this.onDeviceMenuClick('settings', this.props.device)}>
|
||||||
|
@ -8,7 +8,6 @@ export type StateProps = {
|
|||||||
connect: $ElementType<State, 'connect'>,
|
connect: $ElementType<State, 'connect'>,
|
||||||
accounts: $ElementType<State, 'accounts'>,
|
accounts: $ElementType<State, 'accounts'>,
|
||||||
router: $ElementType<State, 'router'>,
|
router: $ElementType<State, 'router'>,
|
||||||
deviceDropdownOpened: boolean,
|
|
||||||
fiat: $ElementType<State, 'fiat'>,
|
fiat: $ElementType<State, 'fiat'>,
|
||||||
localStorage: $ElementType<State, 'localStorage'>,
|
localStorage: $ElementType<State, 'localStorage'>,
|
||||||
discovery: $ElementType<State, 'discovery'>,
|
discovery: $ElementType<State, 'discovery'>,
|
||||||
|
@ -111,27 +111,22 @@ class LeftNavigation extends React.PureComponent<Props, State> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps: Props) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const { deviceDropdownOpened } = nextProps;
|
const { dropdownOpened, selectedDevice } = nextProps.wallet;
|
||||||
const { selectedDevice } = nextProps.wallet;
|
const hasNetwork = nextProps.location.state && nextProps.location.state.network;
|
||||||
const hasNetwork = nextProps.router.location.state && nextProps.router.location.state.network;
|
const hasFeatures = selectedDevice && selectedDevice.features;
|
||||||
const deviceReady = selectedDevice && selectedDevice.features && !selectedDevice.features.bootloader_mode && selectedDevice.features.initialized;
|
const deviceReady = hasFeatures && !selectedDevice.features.bootloader_mode && selectedDevice.features.initialized;
|
||||||
|
if (dropdownOpened) {
|
||||||
if (deviceDropdownOpened) {
|
|
||||||
this.setState({ shouldRenderDeviceSelection: true });
|
this.setState({ shouldRenderDeviceSelection: true });
|
||||||
} else if (hasNetwork) {
|
} else if (hasNetwork) {
|
||||||
this.setState({
|
this.setState({
|
||||||
shouldRenderDeviceSelection: false,
|
shouldRenderDeviceSelection: false,
|
||||||
animationType: 'slide-left',
|
animationType: 'slide-left',
|
||||||
});
|
});
|
||||||
} else if (deviceReady) {
|
} else {
|
||||||
this.setState({
|
|
||||||
shouldRenderDeviceSelection: false,
|
|
||||||
animationType: 'slide-right',
|
|
||||||
});
|
|
||||||
} else if (selectedDevice.features.bootloader_mode) {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
shouldRenderDeviceSelection: false,
|
shouldRenderDeviceSelection: false,
|
||||||
|
animationType: deviceReady ? 'slide-right' : null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,7 +143,7 @@ class LeftNavigation extends React.PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleOpen() {
|
handleOpen() {
|
||||||
this.props.toggleDeviceDropdown(!this.props.deviceDropdownOpened);
|
this.props.toggleDeviceDropdown(!this.props.wallet.dropdownOpened);
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldRenderCoins() {
|
shouldRenderCoins() {
|
||||||
@ -174,15 +169,15 @@ class LeftNavigation extends React.PureComponent<Props, State> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StickyContainer
|
<StickyContainer
|
||||||
location={this.props.router.location.pathname}
|
location={this.props.location.pathname}
|
||||||
deviceSelection={this.props.deviceDropdownOpened}
|
deviceSelection={this.props.wallet.dropdownOpened}
|
||||||
>
|
>
|
||||||
<Header
|
<Header
|
||||||
onClickWrapper={() => this.handleOpen()}
|
onClickWrapper={() => this.handleOpen()}
|
||||||
device={this.props.wallet.selectedDevice}
|
device={this.props.wallet.selectedDevice}
|
||||||
transport={this.props.connect.transport}
|
transport={this.props.connect.transport}
|
||||||
devices={this.props.devices}
|
devices={this.props.devices}
|
||||||
isOpen={this.props.deviceDropdownOpened}
|
isOpen={this.props.wallet.dropdownOpened}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
/>
|
/>
|
||||||
<Body>
|
<Body>
|
||||||
@ -209,7 +204,6 @@ LeftNavigation.propTypes = {
|
|||||||
connect: PropTypes.object,
|
connect: PropTypes.object,
|
||||||
accounts: PropTypes.array,
|
accounts: PropTypes.array,
|
||||||
router: PropTypes.object,
|
router: PropTypes.object,
|
||||||
deviceDropdownOpened: PropTypes.bool,
|
|
||||||
fiat: PropTypes.array,
|
fiat: PropTypes.array,
|
||||||
localStorage: PropTypes.object,
|
localStorage: PropTypes.object,
|
||||||
discovery: PropTypes.array,
|
discovery: PropTypes.array,
|
||||||
@ -218,6 +212,7 @@ LeftNavigation.propTypes = {
|
|||||||
pending: PropTypes.array,
|
pending: PropTypes.array,
|
||||||
|
|
||||||
toggleDeviceDropdown: PropTypes.func,
|
toggleDeviceDropdown: PropTypes.func,
|
||||||
|
selectedDevice: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user