Browse Source

feature(close channel): allow capability to close channel

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
e827d4f2c1
  1. 122
      app/components/Channels/Channel.js
  2. 30
      app/components/Channels/Channel.scss
  3. 2
      app/reducers/channels.js
  4. 3
      app/routes/channels/components/Channels.js
  5. 2
      app/routes/channels/containers/ChannelsContainer.js

122
app/components/Channels/Channel.js

@ -4,68 +4,80 @@ import { FaCircle } from 'react-icons/lib/fa'
import { btc } from 'utils' import { btc } from 'utils'
import styles from './Channel.scss' import styles from './Channel.scss'
const Channel = ({ ticker, channel, setChannel, currentTicker }) => ( const Channel = ({ ticker, channel, closeChannel, currentTicker }) => (
<li className={styles.channel} onClick={() => setChannel(channel)}> <li className={styles.channel} onClick={() => setChannel(channel)}>
<header> <header className={styles.header}>
<span className={styles.status}>Open</span> <div>
{ <span className={styles.status}>Open</span>
channel.active ? {
<span className={styles.active}> channel.active ?
<FaCircle /> <span className={styles.active}>
<i>Active</i> <FaCircle />
</span> <i>Active</i>
: </span>
<span className={styles.notactive}> :
<FaCircle /> <span className={styles.notactive}>
<i>Not Active</i> <FaCircle />
</span> <i>Not Active</i>
} </span>
}
</div>
<div>
<p
className={styles.close}
onClick={() => closeChannel({ channel_point: channel.channel_point })}
>
Close channel
</p>
</div>
</header> </header>
<div className={styles.left}> <div className={styles.content}>
<section className={styles.remotePubkey}> <div className={styles.left}>
<span>Remote Pubkey</span> <section className={styles.remotePubkey}>
<h4>{channel.remote_pubkey}</h4> <span>Remote Pubkey</span>
</section> <h4>{channel.remote_pubkey}</h4>
<section className={styles.channelPoint}>
<span>Channel Point</span>
<h4>{channel.channel_point}</h4>
</section>
</div>
<div className={styles.right}>
<section className={styles.capacity}>
<span>Capacity</span>
<h2>
{
ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.capacity)
:
btc.satoshisToUsd(channel.capacity, currentTicker.price_usd)
}
</h2>
</section>
<div className={styles.balances}>
<section>
<span>Local</span>
<h4>
{
ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.local_balance)
:
btc.satoshisToUsd(channel.local_balance, currentTicker.price_usd)
}
</h4>
</section> </section>
<section> <section className={styles.channelPoint}>
<span>Remote</span> <span>Channel Point</span>
<h4> <h4>{channel.channel_point}</h4>
</section>
</div>
<div className={styles.right}>
<section className={styles.capacity}>
<span>Capacity</span>
<h2>
{ {
ticker.currency === 'btc' ? ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.remote_balance) btc.satoshisToBtc(channel.capacity)
: :
btc.satoshisToUsd(channel.remote_balance, currentTicker.price_usd) btc.satoshisToUsd(channel.capacity, currentTicker.price_usd)
} }
</h4> </h2>
</section> </section>
<div className={styles.balances}>
<section>
<span>Local</span>
<h4>
{
ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.local_balance)
:
btc.satoshisToUsd(channel.local_balance, currentTicker.price_usd)
}
</h4>
</section>
<section>
<span>Remote</span>
<h4>
{
ticker.currency === 'btc' ?
btc.satoshisToBtc(channel.remote_balance)
:
btc.satoshisToUsd(channel.remote_balance, currentTicker.price_usd)
}
</h4>
</section>
</div>
</div> </div>
</div> </div>
</li> </li>
@ -74,7 +86,7 @@ const Channel = ({ ticker, channel, setChannel, currentTicker }) => (
Channel.propTypes = { Channel.propTypes = {
ticker: PropTypes.object.isRequired, ticker: PropTypes.object.isRequired,
channel: PropTypes.object.isRequired, channel: PropTypes.object.isRequired,
setChannel: PropTypes.func.isRequired, closeChannel: PropTypes.func.isRequired,
currentTicker: PropTypes.object.isRequired currentTicker: PropTypes.object.isRequired
} }

30
app/components/Channels/Channel.scss

@ -5,9 +5,6 @@
background: $lightgrey; background: $lightgrey;
margin: 5px 0; margin: 5px 0;
padding: 10px; padding: 10px;
display: flex;
flex-direction: row;
justify-content: space-between;
border-top: 1px solid $white; border-top: 1px solid $white;
cursor: pointer; cursor: pointer;
transition: all 0.25s; transition: all 0.25s;
@ -20,10 +17,10 @@
border: none; border: none;
} }
header { .header {
position: absolute; display: flex;
top: 10px; flex-direction: row;
left: 10px; justify-content: space-between;
.status, .active, .notactive { .status, .active, .notactive {
padding: 10px; padding: 10px;
@ -47,6 +44,25 @@
.notactive { .notactive {
color: $red; color: $red;
} }
.close {
padding: 10px;
font-size: 10px;
text-transform: uppercase;
color: $red;
cursor: pointer;
&:hover {
color: lighten($red, 10%);
text-decoration: underline;
}
}
}
.content {
display: flex;
flex-direction: row;
justify-content: space-between;
} }

2
app/reducers/channels.js

@ -206,7 +206,7 @@ const ACTION_HANDLERS = {
[GET_CHANNELS]: state => ({ ...state, channelsLoading: true }), [GET_CHANNELS]: state => ({ ...state, channelsLoading: true }),
[RECEIVE_CHANNELS]: (state, { channels, pendingChannels }) => ( [RECEIVE_CHANNELS]: (state, { channels, pendingChannels }) => (
{ ...state, channelsLoading: false, channels, pendingChannels: state.pendingChannels } { ...state, channelsLoading: false, channels, pendingChannels }
), ),
[OPENING_CHANNEL]: state => ({ ...state, openingChannel: true }), [OPENING_CHANNEL]: state => ({ ...state, openingChannel: true }),

3
app/routes/channels/components/Channels.js

@ -24,6 +24,7 @@ class Channels extends Component {
render() { render() {
const { const {
fetchChannels, fetchChannels,
closeChannel,
channels: { channels: {
searchQuery, searchQuery,
filterPulldown, filterPulldown,
@ -157,7 +158,7 @@ class Channels extends Component {
key={index} key={index}
ticker={ticker} ticker={ticker}
channel={channel} channel={channel}
setChannel={() => {}} closeChannel={closeChannel}
currentTicker={currentTicker} currentTicker={currentTicker}
/> />
) )

2
app/routes/channels/containers/ChannelsContainer.js

@ -4,6 +4,7 @@ import { connect } from 'react-redux'
import { import {
fetchChannels, fetchChannels,
openChannel, openChannel,
closeChannel,
updateChannelSearchQuery, updateChannelSearchQuery,
setViewType, setViewType,
currentChannels, currentChannels,
@ -35,6 +36,7 @@ import Channels from '../components/Channels'
const mapDispatchToProps = { const mapDispatchToProps = {
fetchChannels, fetchChannels,
openChannel, openChannel,
closeChannel,
updateChannelSearchQuery, updateChannelSearchQuery,
setViewType, setViewType,
toggleFilterPulldown, toggleFilterPulldown,

Loading…
Cancel
Save