1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-26 08:58:06 +00:00

discovery status css fix

- DiscoveryStatusWrapper css fix (wodth 100%)
- rewriten first condition
This commit is contained in:
Szymon Lesisz 2018-10-22 10:02:30 +02:00
parent 1f517733fc
commit a534830dff

View File

@ -78,7 +78,7 @@ const AddAccountIconWrapper = styled.div`
const DiscoveryStatusWrapper = styled.div` const DiscoveryStatusWrapper = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100%;
font-size: ${FONT_SIZE.SMALL}; font-size: ${FONT_SIZE.SMALL};
padding: ${LEFT_NAVIGATION_ROW.PADDING}; padding: ${LEFT_NAVIGATION_ROW.PADDING};
white-space: nowrap; white-space: nowrap;
@ -164,15 +164,34 @@ const AccountMenu = (props: Props) => {
let discoveryStatus = null; let discoveryStatus = null;
const discovery = props.discovery.find(d => d.deviceState === selected.state && d.network === location.state.network); const discovery = props.discovery.find(d => d.deviceState === selected.state && d.network === location.state.network);
if (discovery) { if (discovery && discovery.completed) {
if (discovery.completed) { // TODO: add only if last one is not empty
// TODO: add only if last one is not empty //if (selectedAccounts.length > 0 && selectedAccounts[selectedAccounts.length - 1])
//if (selectedAccounts.length > 0 && selectedAccounts[selectedAccounts.length - 1]) const lastAccount = deviceAccounts[deviceAccounts.length - 1];
const lastAccount = deviceAccounts[deviceAccounts.length - 1]; if (lastAccount && (new BigNumber(lastAccount.balance).greaterThan(0) || lastAccount.nonce > 0)) {
if (lastAccount && (new BigNumber(lastAccount.balance).greaterThan(0) || lastAccount.nonce > 0)) { discoveryStatus = (
discoveryStatus = ( <Row onClick={props.addAccount}>
<Row onClick={props.addAccount}> <RowAddAccountWrapper>
<RowAddAccountWrapper> <AddAccountIconWrapper>
<Icon
icon={ICONS.PLUS}
size={24}
color={colors.TEXT_SECONDARY}
/>
</AddAccountIconWrapper>
Add account
</RowAddAccountWrapper>
</Row>
);
} else {
discoveryStatus = (
<Tooltip
maxWidth={200}
content={<TooltipContent>To add a new account, last account must have some transactions.</TooltipContent>}
placement="bottom"
>
<Row>
<RowAddAccountWrapper disabled>
<AddAccountIconWrapper> <AddAccountIconWrapper>
<Icon <Icon
icon={ICONS.PLUS} icon={ICONS.PLUS}
@ -183,54 +202,34 @@ const AccountMenu = (props: Props) => {
Add account Add account
</RowAddAccountWrapper> </RowAddAccountWrapper>
</Row> </Row>
); </Tooltip>
} else {
discoveryStatus = (
<Tooltip
maxWidth={200}
content={<TooltipContent>To add a new account, last account must have some transactions.</TooltipContent>}
placement="bottom"
>
<Row>
<RowAddAccountWrapper disabled>
<AddAccountIconWrapper>
<Icon
icon={ICONS.PLUS}
size={24}
color={colors.TEXT_SECONDARY}
/>
</AddAccountIconWrapper>
Add account
</RowAddAccountWrapper>
</Row>
</Tooltip>
);
}
} else if (!selected.connected || !selected.available) {
discoveryStatus = (
<Row>
<DiscoveryStatusWrapper>
Accounts could not be loaded
<DiscoveryStatusText>
{`Connect ${selected.instanceLabel} device`}
</DiscoveryStatusText>
</DiscoveryStatusWrapper>
</Row>
);
} else {
discoveryStatus = (
<Row>
<DiscoveryLoadingWrapper>
<Loader size={20} />
<DiscoveryLoadingText>
Loading...
</DiscoveryLoadingText>
</DiscoveryLoadingWrapper>
</Row>
); );
} }
} else if (!selected.connected) {
discoveryStatus = (
<Row>
<DiscoveryStatusWrapper>
Accounts could not be loaded
<DiscoveryStatusText>
{`Connect ${selected.instanceLabel} device`}
</DiscoveryStatusText>
</DiscoveryStatusWrapper>
</Row>
);
} else {
discoveryStatus = (
<Row>
<DiscoveryLoadingWrapper>
<Loader size={20} />
<DiscoveryLoadingText>
Loading...
</DiscoveryLoadingText>
</DiscoveryLoadingWrapper>
</Row>
);
} }
return ( return (
<Wrapper> <Wrapper>
<NavLink to={baseUrl}> <NavLink to={baseUrl}>