Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Watch Only): add watch only balance to separate section of balan…
…ce dropdown
- Loading branch information
plondon
committed
May 31, 2018
1 parent
93da3bd
commit 65e72a9
Showing
15 changed files
with
201 additions
and
9 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...kchain-wallet-v4-frontend/src/layouts/Wallet/MenuTop/Balance/BtcWatchOnlyBalance/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { connect } from 'react-redux' | ||
import { bindActionCreators } from 'redux' | ||
|
||
import { Remote } from 'blockchain-wallet-v4/src' | ||
import { actions } from 'data' | ||
import { getData } from './selectors' | ||
import Error from './template.error' | ||
import Loading from './template.loading' | ||
import Success from './template.success' | ||
|
||
class BtcBalance extends React.PureComponent { | ||
constructor (props) { | ||
super(props) | ||
this.handleRefresh = this.handleRefresh.bind(this) | ||
} | ||
|
||
componentWillMount () { | ||
if (Remote.NotAsked.is(this.props.data)) { | ||
this.props.actions.fetchUnspendableBalance(this.props.context) | ||
} | ||
} | ||
|
||
handleRefresh () { | ||
this.props.actions.fetchUnspendableBalance(this.props.context) | ||
} | ||
|
||
render () { | ||
const { data, large } = this.props | ||
|
||
return data.cata({ | ||
Success: (value) => <Success balance={value} large={large} />, | ||
Failure: (message) => <Error onRefresh={this.handleRefresh} />, | ||
Loading: () => <Loading />, | ||
NotAsked: () => <Loading /> | ||
}) | ||
} | ||
} | ||
|
||
BtcBalance.propTypes = { | ||
context: PropTypes.string.isRequired | ||
} | ||
|
||
const mapStateToProps = (state) => ({ | ||
data: getData(state) | ||
}) | ||
|
||
const mapDispatchToProps = (dispatch) => ({ | ||
actions: bindActionCreators(actions.core.data.bitcoin, dispatch) | ||
}) | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(BtcBalance) |
3 changes: 3 additions & 0 deletions
3
...in-wallet-v4-frontend/src/layouts/Wallet/MenuTop/Balance/BtcWatchOnlyBalance/selectors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { selectors } from 'data' | ||
|
||
export const getData = selectors.core.data.bitcoin.getUnspendableBalance |
22 changes: 22 additions & 0 deletions
22
...llet-v4-frontend/src/layouts/Wallet/MenuTop/Balance/BtcWatchOnlyBalance/template.error.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import { FormattedMessage } from 'react-intl' | ||
import { Link } from 'blockchain-info-components' | ||
|
||
const Wrapper = styled.div` | ||
display: flex; | ||
box-sizing: border-box; | ||
justify-content: flex-end; | ||
padding-right: 25px; | ||
` | ||
const ErrorLink = styled(Link)` | ||
text-decoration: underline; | ||
` | ||
|
||
export default (props) => ( | ||
<Wrapper> | ||
<ErrorLink size='12px' weight={300} onClick={() => props.onRefresh()}> | ||
<FormattedMessage id='wallet.menutop.balance.refresh' defaultMessage='Refresh {curr} data' values={{curr: 'Watch Only Bitcoin'}} /> | ||
</ErrorLink> | ||
</Wrapper> | ||
) |
21 changes: 21 additions & 0 deletions
21
...et-v4-frontend/src/layouts/Wallet/MenuTop/Balance/BtcWatchOnlyBalance/template.loading.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
import { FlatLoader } from 'blockchain-info-components' | ||
|
||
const Wrapper = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 5px; | ||
box-sizing: border-box; | ||
` | ||
|
||
export default (props) => { | ||
return ( | ||
<Wrapper> | ||
<FlatLoader width='50px' height='14px' /> | ||
</Wrapper> | ||
) | ||
} |
46 changes: 46 additions & 0 deletions
46
...et-v4-frontend/src/layouts/Wallet/MenuTop/Balance/BtcWatchOnlyBalance/template.success.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import styled from 'styled-components' | ||
import FiatDisplay from 'components/Display/FiatDisplay' | ||
import { LinkContainer } from 'react-router-bootstrap' | ||
import { FormattedMessage } from 'react-intl' | ||
import { Banner, Text } from 'blockchain-info-components' | ||
|
||
const Wrapper = styled.div` | ||
display: inline-flex; | ||
flex-direction: row; | ||
align-items: center; | ||
padding-left: 5px; | ||
margin-bottom: 10px; | ||
padding-right: ${props => props.large ? '15px' : '25px'}; | ||
> div:last-child { | ||
margin-left: 10px; | ||
> div { | ||
color: ${props => props.theme['gray-3']} | ||
} | ||
} | ||
` | ||
|
||
const Success = props => { | ||
const { balance } = props | ||
|
||
return ( | ||
<LinkContainer to='/btc/transactions'> | ||
<Wrapper> | ||
<Text size='10px' weight={300}>BTC</Text> | ||
<Banner inline type='informational'> | ||
<FiatDisplay coin='BTC' cursor='pointer' size='10px' weight={300}>{balance}</FiatDisplay> | ||
<Text size='10px' weight={300}> | ||
<FormattedMessage id='scenes.wallet.menutop.balance.watchonlybtcbalance' defaultMessage=' Non-Spendable' /> | ||
</Text> | ||
</Banner> | ||
</Wrapper> | ||
</LinkContainer> | ||
) | ||
} | ||
|
||
Success.propTypes = { | ||
balance: PropTypes.number.isRequired | ||
} | ||
|
||
export default Success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters