You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.0 KiB
104 lines
3.0 KiB
8 years ago
|
import React from 'react'
|
||
|
import PropTypes from 'prop-types'
|
||
8 years ago
|
import { TiPlus } from 'react-icons/lib/ti'
|
||
7 years ago
|
import ChannelModal from './ChannelModal'
|
||
|
import ChannelForm from './ChannelForm'
|
||
|
import Channel from './Channel'
|
||
|
import OpenPendingChannel from './OpenPendingChannel'
|
||
|
import ClosedPendingChannel from './ClosedPendingChannel'
|
||
8 years ago
|
import styles from './Channels.scss'
|
||
|
|
||
8 years ago
|
const Channels = ({
|
||
8 years ago
|
ticker,
|
||
|
peers,
|
||
|
channelsLoading,
|
||
|
modalChannel,
|
||
|
setChannel,
|
||
|
channelModalOpen,
|
||
|
channelForm,
|
||
|
setChannelForm,
|
||
|
allChannels,
|
||
7 years ago
|
openChannel,
|
||
7 years ago
|
closeChannel,
|
||
7 years ago
|
currentTicker,
|
||
|
explorerLinkBase
|
||
8 years ago
|
}) => (
|
||
|
<div className={styles.channels}>
|
||
7 years ago
|
<ChannelModal
|
||
|
isOpen={channelModalOpen}
|
||
|
resetChannel={setChannel}
|
||
|
channel={modalChannel}
|
||
|
explorerLinkBase={explorerLinkBase}
|
||
|
closeChannel={closeChannel}
|
||
|
/>
|
||
7 years ago
|
<ChannelForm form={channelForm} setForm={setChannelForm} ticker={ticker} peers={peers} openChannel={openChannel} currentTicker={currentTicker} />
|
||
8 years ago
|
<div className={styles.header}>
|
||
|
<h3>Channels</h3>
|
||
|
<div
|
||
|
className={`${styles.openChannel} hint--top`}
|
||
|
data-hint='Open a channel'
|
||
|
onClick={() => setChannelForm({ isOpen: true })}
|
||
|
>
|
||
8 years ago
|
<TiPlus />
|
||
8 years ago
|
</div>
|
||
|
</div>
|
||
|
<ul>
|
||
|
{
|
||
8 years ago
|
!channelsLoading ?
|
||
8 years ago
|
allChannels.map((channel, index) => {
|
||
8 years ago
|
if (Object.prototype.hasOwnProperty.call(channel, 'blocks_till_open')) {
|
||
8 years ago
|
return (
|
||
7 years ago
|
<OpenPendingChannel
|
||
|
key={index}
|
||
|
channel={channel}
|
||
|
ticker={ticker}
|
||
|
currentTicker={currentTicker}
|
||
7 years ago
|
explorerLinkBase={explorerLinkBase}
|
||
7 years ago
|
/>
|
||
8 years ago
|
)
|
||
8 years ago
|
} else if (Object.prototype.hasOwnProperty.call(channel, 'closing_txid')) {
|
||
8 years ago
|
return (
|
||
7 years ago
|
<ClosedPendingChannel
|
||
|
key={index}
|
||
|
channel={channel}
|
||
|
ticker={ticker}
|
||
|
currentTicker={currentTicker}
|
||
7 years ago
|
explorerLinkBase={explorerLinkBase}
|
||
7 years ago
|
/>
|
||
8 years ago
|
)
|
||
|
}
|
||
8 years ago
|
return (
|
||
|
<Channel
|
||
|
key={channel.chan_id}
|
||
|
ticker={ticker}
|
||
|
channel={channel}
|
||
|
setChannel={setChannel}
|
||
7 years ago
|
currentTicker={currentTicker}
|
||
8 years ago
|
/>
|
||
|
)
|
||
8 years ago
|
})
|
||
8 years ago
|
:
|
||
8 years ago
|
'Loading...'
|
||
8 years ago
|
}
|
||
8 years ago
|
</ul>
|
||
|
</div>
|
||
|
)
|
||
8 years ago
|
|
||
8 years ago
|
Channels.propTypes = {
|
||
|
ticker: PropTypes.object.isRequired,
|
||
|
peers: PropTypes.array.isRequired,
|
||
|
channelsLoading: PropTypes.bool.isRequired,
|
||
|
modalChannel: PropTypes.object,
|
||
|
setChannel: PropTypes.func.isRequired,
|
||
|
channelModalOpen: PropTypes.bool.isRequired,
|
||
|
channelForm: PropTypes.object.isRequired,
|
||
|
setChannelForm: PropTypes.func.isRequired,
|
||
|
allChannels: PropTypes.array.isRequired,
|
||
7 years ago
|
openChannel: PropTypes.func.isRequired,
|
||
7 years ago
|
closeChannel: PropTypes.func.isRequired,
|
||
7 years ago
|
currentTicker: PropTypes.object.isRequired,
|
||
|
explorerLinkBase: PropTypes.string.isRequired
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
export default Channels
|