mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
Removed old selected device
This commit is contained in:
parent
a4d88fb919
commit
bc094c42a1
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import styled, { keyframes } from 'styled-components';
|
import styled, { keyframes } from 'styled-components';
|
||||||
|
|
||||||
|
// TODO: make animation of icons better
|
||||||
const rotate180up = keyframes`
|
const rotate180up = keyframes`
|
||||||
from {
|
from {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
|
@ -14,6 +14,19 @@ const Wrapper = styled.div`
|
|||||||
width: 320px;
|
width: 320px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
background: ${colors.WHITE};
|
||||||
|
border-bottom: 1px solid ${colors.DIVIDER};
|
||||||
|
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
${props => props.isOpen && css`
|
||||||
|
border-bottom: 1px solid ${colors.WHITE};
|
||||||
|
box-shadow: none;
|
||||||
|
`}
|
||||||
|
|
||||||
|
${props => props.disabled && css`
|
||||||
|
cursor: initial;
|
||||||
|
`}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ClickWrapper = styled.div`
|
const ClickWrapper = styled.div`
|
||||||
@ -23,6 +36,10 @@ const ClickWrapper = styled.div`
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
${props => props.disabled && css`
|
||||||
|
cursor: initial;
|
||||||
|
`}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const LabelWrapper = styled.div`
|
const LabelWrapper = styled.div`
|
||||||
@ -98,13 +115,12 @@ class DeviceHeader extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log('cananitem', this.state.clicked);
|
|
||||||
const {
|
const {
|
||||||
status, label, deviceCount, isOpen, trezorModel,
|
status, label, deviceCount, isOpen, trezorModel, disabled,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper isOpen={isOpen} disabled={disabled}>
|
||||||
<ClickWrapper onClick={() => this.handleClick()}>
|
<ClickWrapper disabled={disabled} onClick={() => this.handleClick()}>
|
||||||
<ImageWrapper>
|
<ImageWrapper>
|
||||||
<Dot color={getStatusColor(status)} />
|
<Dot color={getStatusColor(status)} />
|
||||||
<TrezorImage status={status} model={trezorModel} />
|
<TrezorImage status={status} model={trezorModel} />
|
||||||
@ -115,14 +131,16 @@ class DeviceHeader extends Component {
|
|||||||
</LabelWrapper>
|
</LabelWrapper>
|
||||||
<IconWrapper>
|
<IconWrapper>
|
||||||
{deviceCount > 1 && <Counter>{deviceCount}</Counter>}
|
{deviceCount > 1 && <Counter>{deviceCount}</Counter>}
|
||||||
|
{!disabled && (
|
||||||
<Icon
|
<Icon
|
||||||
canAnimate={this.state.clicked === true}
|
canAnimate={this.state.clicked === true}
|
||||||
isActive={isOpen}
|
isActive={isOpen}
|
||||||
size={25}
|
size={25}
|
||||||
color={colors.TEXT_SECONDARY}
|
color={colors.TEXT_SECONDARY}
|
||||||
icon={icons.ARROW_DOWN}
|
icon={icons.ARROW_DOWN}
|
||||||
rotateOnActive
|
|
||||||
/>
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
</IconWrapper>
|
</IconWrapper>
|
||||||
</ClickWrapper>
|
</ClickWrapper>
|
||||||
</Wrapper>
|
</Wrapper>
|
@ -3,9 +3,10 @@ import React, { Component } from 'react';
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import TrezorConnect from 'trezor-connect';
|
import TrezorConnect from 'trezor-connect';
|
||||||
import type { TrezorDevice } from 'flowtype';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
import DeviceHeader from 'components/DeviceHeader';
|
|
||||||
import { getStatus, getVersion } from 'utils/device';
|
import { getStatus, getVersion } from 'utils/device';
|
||||||
|
|
||||||
|
import DeviceHeader from './components/DeviceHeader';
|
||||||
|
|
||||||
// import DeviceList from './components/DeviceList';
|
// import DeviceList from './components/DeviceList';
|
||||||
import type { Props } from '../common';
|
import type { Props } from '../common';
|
||||||
|
|
||||||
@ -17,66 +18,24 @@ const Wrapper = styled.div``;
|
|||||||
export const DeviceSelect = (props: Props) => {
|
export const DeviceSelect = (props: Props) => {
|
||||||
const { devices } = props;
|
const { devices } = props;
|
||||||
const { transport } = props.connect;
|
const { transport } = props.connect;
|
||||||
|
const { selectedDevice } = props.wallet;
|
||||||
const selected: ?TrezorDevice = props.wallet.selectedDevice;
|
|
||||||
if (!selected) return null;
|
|
||||||
|
|
||||||
let deviceStatus: string = 'Connected';
|
|
||||||
let css: string = 'device-select device';
|
|
||||||
if (props.deviceDropdownOpened) css += ' opened';
|
|
||||||
|
|
||||||
if (!selected.connected) {
|
|
||||||
css += ' disconnected';
|
|
||||||
deviceStatus = 'Disconnected';
|
|
||||||
} else if (!selected.available) {
|
|
||||||
css += ' unavailable';
|
|
||||||
deviceStatus = 'Unavailable';
|
|
||||||
} else if (selected.type === 'acquired') {
|
|
||||||
if (selected.status === 'occupied') {
|
|
||||||
css += ' used-elsewhere';
|
|
||||||
deviceStatus = 'Used in other window';
|
|
||||||
} else if (selected.status === 'used') {
|
|
||||||
css += ' reload-features';
|
|
||||||
}
|
|
||||||
} else if (selected.type === 'unacquired') {
|
|
||||||
css += ' unacquired';
|
|
||||||
deviceStatus = 'Used in other window';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selected.features && selected.features.major_version > 1) {
|
|
||||||
css += ' trezor-t';
|
|
||||||
}
|
|
||||||
|
|
||||||
const deviceCount = devices.length;
|
|
||||||
const webusb: boolean = !!((transport && transport.version.indexOf('webusb') >= 0));
|
const webusb: boolean = !!((transport && transport.version.indexOf('webusb') >= 0));
|
||||||
const disabled: boolean = (devices.length < 1 && !webusb) || (devices.length === 1 && !selected.features && !webusb);
|
const disabled: boolean = (devices.length < 1 && !webusb) || (devices.length === 1 && !selectedDevice.features && !webusb);
|
||||||
if (disabled) {
|
|
||||||
css += ' disabled';
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleOpen = () => {
|
const handleOpen = () => {
|
||||||
props.toggleDeviceDropdown(!props.deviceDropdownOpened);
|
props.toggleDeviceDropdown(!props.deviceDropdownOpened);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
|
||||||
<DeviceHeader
|
<DeviceHeader
|
||||||
handleOpen={handleOpen}
|
handleOpen={handleOpen}
|
||||||
label={selected.instanceLabel}
|
disabled={disabled}
|
||||||
status={getStatus(selected)}
|
label={selectedDevice.instanceLabel}
|
||||||
|
status={getStatus(selectedDevice)}
|
||||||
deviceCount={devices.length}
|
deviceCount={devices.length}
|
||||||
isOpen={props.deviceDropdownOpened}
|
isOpen={props.deviceDropdownOpened}
|
||||||
trezorModel={getVersion(selected)}
|
trezorModel={getVersion(selectedDevice)}
|
||||||
/>
|
/>
|
||||||
<div className={css} onClick={!disabled ? handleOpen : null}>
|
|
||||||
<div className="label-container">
|
|
||||||
<span className="label">{selected.instanceLabel}</span>
|
|
||||||
<span className="status">{deviceStatus}</span>
|
|
||||||
</div>
|
|
||||||
{deviceCount > 1 ? <div className="counter">{deviceCount}</div> : null}
|
|
||||||
<div className="arrow" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,12 +144,13 @@ class LeftNavigation extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { selectedDevice } = this.props.wallet;
|
||||||
return (
|
return (
|
||||||
<StickyContainer
|
<StickyContainer
|
||||||
location={this.props.location.pathname}
|
location={this.props.location.pathname}
|
||||||
deviceSelection={this.props.deviceDropdownOpened}
|
deviceSelection={this.props.deviceDropdownOpened}
|
||||||
>
|
>
|
||||||
<DeviceSelect {...this.props} />
|
{selectedDevice && <DeviceSelect {...this.props} />}
|
||||||
<MenuWrapper>
|
<MenuWrapper>
|
||||||
{this.state.shouldRenderDeviceSelection && <DeviceDropdown {...this.props} />}
|
{this.state.shouldRenderDeviceSelection && <DeviceDropdown {...this.props} />}
|
||||||
{this.shouldRenderAccounts() && this.getMenuTransition(<AccountMenu {...this.props} />)}
|
{this.shouldRenderAccounts() && this.getMenuTransition(<AccountMenu {...this.props} />)}
|
||||||
|
Loading…
Reference in New Issue
Block a user