Browse Source

feature(suggested-peers): hook up suggested peers form

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
f01924f2a2
  1. 1
      app/components/Contacts/AddChannel.js
  2. 5
      app/components/Contacts/Network.js
  3. 2
      app/components/Contacts/SubmitChannelForm.js
  4. 14
      app/components/Contacts/SuggestedNodes.js
  5. 6
      app/components/Contacts/SuggestedNodes.scss
  6. 5
      app/routes/app/containers/AppContainer.js

1
app/components/Contacts/AddChannel.js

@ -68,6 +68,7 @@ const AddChannel = ({
<span <span
className={styles.connect} className={styles.connect}
onClick={() => { onClick={() => {
console.log('node: ', node)
// set the node public key for the submit form // set the node public key for the submit form
setNode(node) setNode(node)
// open the submit form // open the submit form

5
app/components/Contacts/Network.js

@ -54,6 +54,7 @@ class Network extends Component {
suggestedNodesProps suggestedNodesProps
} = this.props } = this.props
console.log('currentChannels: ', currentChannels)
const refreshClicked = () => { const refreshClicked = () => {
// turn the spinner on // turn the spinner on
@ -148,7 +149,7 @@ class Network extends Component {
} }
{ {
loadingChannelPubkeys.length > 0 && currentChannels.length > 0 && loadingChannelPubkeys.length > 0 || currentChannels.length > 0 &&
<header className={styles.listHeader}> <header className={styles.listHeader}>
<section> <section>
<h2 onClick={toggleFilterPulldown} className={styles.filterTitle}> <h2 onClick={toggleFilterPulldown} className={styles.filterTitle}>
@ -275,7 +276,7 @@ class Network extends Component {
</ul> </ul>
</div> </div>
{ {
loadingChannelPubkeys.length > 0 && currentChannels.length > 0 && loadingChannelPubkeys.length > 0 || currentChannels.length > 0 &&
<footer className={styles.search}> <footer className={styles.search}>
<label htmlFor='search' className={`${styles.label} ${styles.input}`}> <label htmlFor='search' className={`${styles.label} ${styles.input}`}>
<Isvg src={search} /> <Isvg src={search} />

2
app/components/Contacts/SubmitChannelForm.js

@ -38,7 +38,7 @@ class SubmitChannelForm extends React.Component {
const formSubmitted = () => { const formSubmitted = () => {
// dont submit to LND if they havent set channel capacity amount // dont submit to LND if they havent set channel capacity amount
if (contactCapacity > 0) { return } if (contactCapacity > 0) { console.log('hello?'); return }
// submit the channel to LND // submit the channel to LND
openChannel({ pubkey: node.pub_key, host: node.addresses[0].addr, local_amt: contactCapacity }) openChannel({ pubkey: node.pub_key, host: node.addresses[0].addr, local_amt: contactCapacity })

14
app/components/Contacts/SuggestedNodes.js

@ -2,7 +2,13 @@ import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import styles from './SuggestedNodes.scss' import styles from './SuggestedNodes.scss'
const SuggestedNodes = ({ suggestedNodesLoading, suggestedNodes }) => { const SuggestedNodes = ({ suggestedNodesLoading, suggestedNodes, setNode, openSubmitChannelForm }) => {
const nodeClicked = (n) => {
// set the node public key for the submit form
setNode({ pub_key: n.pubkey, addresses: [{ addr: n.host }] })
// open the submit form
openSubmitChannelForm()
}
if (suggestedNodesLoading) { if (suggestedNodesLoading) {
return ( return (
<div className={styles.spinnerContainer}> <div className={styles.spinnerContainer}>
@ -28,7 +34,7 @@ const SuggestedNodes = ({ suggestedNodesLoading, suggestedNodes }) => {
<span>{`${node.pubkey.substring(0, 30)}...`}</span> <span>{`${node.pubkey.substring(0, 30)}...`}</span>
</section> </section>
<section> <section>
<span>Connect</span> <span onClick={() => nodeClicked(node)}>Connect</span>
</section> </section>
</li> </li>
) )
@ -41,7 +47,9 @@ const SuggestedNodes = ({ suggestedNodesLoading, suggestedNodes }) => {
SuggestedNodes.propTypes = { SuggestedNodes.propTypes = {
suggestedNodesLoading: PropTypes.bool.isRequired, suggestedNodesLoading: PropTypes.bool.isRequired,
suggestedNodes: PropTypes.array.isRequired suggestedNodes: PropTypes.array.isRequired,
setNode: PropTypes.func.isRequired,
openSubmitChannelForm: PropTypes.func.isRequired
} }
export default SuggestedNodes export default SuggestedNodes

6
app/components/Contacts/SuggestedNodes.scss

@ -38,6 +38,12 @@
span { span {
font-size: 10px; font-size: 10px;
opacity: 0.5; opacity: 0.5;
cursor: pointer;
transition: all 0.25s;
&:hover {
opacity: 1;
}
} }
} }
} }

5
app/routes/app/containers/AppContainer.js

@ -319,7 +319,10 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
suggestedNodesProps: { suggestedNodesProps: {
suggestedNodesLoading: stateProps.channels.suggestedNodesLoading, suggestedNodesLoading: stateProps.channels.suggestedNodesLoading,
suggestedNodes: stateProps.info.data.testnet ? stateProps.channels.suggestedNodes.testnet : stateProps.channels.suggestedNodes.mainnet suggestedNodes: stateProps.info.data.testnet ? stateProps.channels.suggestedNodes.testnet : stateProps.channels.suggestedNodes.mainnet,
setNode: dispatchProps.setNode,
openSubmitChannelForm: () => dispatchProps.setChannelFormType('SUBMIT_CHANNEL_FORM')
} }
} }

Loading…
Cancel
Save