From 7d5b08aa3bfde979fefcd9093ee9dc4f84ce4729 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Wed, 17 Apr 2019 16:20:14 +0200 Subject: [PATCH] hide and show menu parts according to visible coins --- .../components/CoinMenu/index.js | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/views/Wallet/components/LeftNavigation/components/CoinMenu/index.js b/src/views/Wallet/components/LeftNavigation/components/CoinMenu/index.js index b8dfdc11..1162a5d7 100644 --- a/src/views/Wallet/components/LeftNavigation/components/CoinMenu/index.js +++ b/src/views/Wallet/components/LeftNavigation/components/CoinMenu/index.js @@ -26,13 +26,21 @@ const StyledLink = styled(Link)` } `; -const Empty = styled.div` +const Empty = styled.span` display: flex; justify-content: center; align-items: center; min-height: 50px; `; +const StyledLinkEmpty = styled(Link)` + padding: 0 5px; +`; + +const Gray = styled.span` + color: ${colors.TEXT_SECONDARY}; +`; + class CoinMenu extends PureComponent { getBaseUrl() { const { selectedDevice } = this.props.wallet; @@ -85,22 +93,36 @@ class CoinMenu extends PureComponent { }); } - isEmpty(networks) { - const numberOfVisibleNetworks = networks + isTopMenuEmpty() { + const numberOfVisibleNetworks = this.props.localStorage.config.networks .filter(item => !item.isHidden) // hide coins globally in config .filter(item => this.props.wallet.hiddenCoins.includes(item.shortcut)); return numberOfVisibleNetworks.length <= 0; } + isBottomMenuEmpty() { + const { hiddenCoins } = this.props.wallet; + const numberOfVisibleNetworks = coins + .filter(item => !item.isHidden) + .filter(item => hiddenCoins.includes(item.id)); + + return numberOfVisibleNetworks.length <= 0; + } + + isMenuEmpty() { + return this.isTopMenuEmpty() && this.isBottomMenuEmpty(); + } + render() { const { hiddenCoins } = this.props.wallet; const { config } = this.props.localStorage; return ( - {this.isEmpty(config.networks) && ( + {this.isMenuEmpty() && ( - Please select a coin in application settings + Select a coin + in application settings )} {config.networks @@ -120,11 +142,13 @@ class CoinMenu extends PureComponent { /> ))} - } - hasBorder - /> + {!this.isBottomMenuEmpty() && ( + } + hasBorder + /> + )} {this.getOtherCoins()} );