From 2c2e63235ef53d5b77b0838d5deaca1af7a62441 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Thu, 4 Jan 2018 14:37:57 -0600 Subject: [PATCH] feature(contacts): add manual form --- app/components/Contacts/ContactsForm.js | 36 ++++++++++++++++--- app/components/Contacts/ContactsForm.scss | 36 ++++++++++++++++++- app/reducers/contactsform.js | 15 ++++++++ .../contacts/containers/ContactsContainer.js | 4 ++- 4 files changed, 85 insertions(+), 6 deletions(-) diff --git a/app/components/Contacts/ContactsForm.js b/app/components/Contacts/ContactsForm.js index ed48cb58..e6bbda16 100644 --- a/app/components/Contacts/ContactsForm.js +++ b/app/components/Contacts/ContactsForm.js @@ -10,7 +10,8 @@ class ContactsForm extends React.Component { super(props) this.state = { - editing: false + editing: false, + manualFormInput: '' } } @@ -25,10 +26,11 @@ class ContactsForm extends React.Component { activeChannelPubkeys, nonActiveChannelPubkeys, pendingOpenChannelPubkeys, - filteredNetworkNodes + filteredNetworkNodes, + showManualForm } = this.props - const { editing } = this.state + const { editing, manualFormInput } = this.state const renderRightSide = (node) => { if (activeChannelPubkeys.includes(node.pub_key)) { @@ -67,7 +69,7 @@ class ContactsForm extends React.Component { openChannel({ pubkey: node.pub_key, host: node.addresses[0].addr, local_amt: contactsform.contactsform.contactCapacity })} + onClick={() => openChannel({ pubkey: node.pub_key, host: node.addresses[0].addr, local_amt: contactsform.contactCapacity })} > Connect @@ -80,6 +82,15 @@ class ContactsForm extends React.Component { this.setState({ editing: true }) } + const manualFormSubmit = () => { + if (!manualFormInput.length) { return } + if (!manualFormInput.includes('@')) { return } + + const [pubkey, host] = manualFormInput && manualFormInput.split('@') + + openChannel({ pubkey, host, local_amt: contactsform.contactCapacity }) + } + return (
+ + { + showManualForm && +
+

Hm, looks like we can't see that contact from here. Want to try and manually connect?

+
+ this.setState({ manualFormInput: event.target.value })} + /> +
Submit
+
+
+ } +