Browse Source

fix(lint/tests): fix lint and test errors

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
63707b0b40
  1. 53
      app/components/Contacts/Network.js
  2. 32
      app/components/Contacts/SuggestedNodes.js
  3. 8
      app/reducers/channels.js
  4. 1
      app/routes/app/components/App.js
  5. 3
      app/routes/app/containers/AppContainer.js
  6. 25
      test/reducers/__snapshots__/channels.spec.js.snap

53
app/components/Contacts/Network.js

@ -54,8 +54,6 @@ 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
this.setState({ refreshing: true }) this.setState({ refreshing: true })
@ -143,28 +141,28 @@ class Network extends Component {
</header> </header>
<div className={styles.channels}> <div className={styles.channels}>
{ {
!loadingChannelPubkeys.length && !currentChannels.length && !loadingChannelPubkeys.length && !currentChannels.length &&
<SuggestedNodes {...suggestedNodesProps} /> <SuggestedNodes {...suggestedNodesProps} />
} }
{ {
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}>
{filter.name} <span className={filterPulldown && styles.pulldown}><FaAngleDown /></span> {filter.name} <span className={filterPulldown && styles.pulldown}><FaAngleDown /></span>
</h2> </h2>
<ul className={`${styles.filters} ${filterPulldown && styles.active}`}> <ul className={`${styles.filters} ${filterPulldown && styles.active}`}>
{ {
nonActiveFilters.map(f => ( nonActiveFilters.map(f => (
<li key={f.key} onClick={() => changeFilter(f)}> <li key={f.key} onClick={() => changeFilter(f)}>
{f.name} {f.name}
</li> </li>
)) ))
} }
</ul> </ul>
</section> </section>
<section className={styles.refreshContainer}> <section className={styles.refreshContainer}>
<span className={styles.refresh} onClick={refreshClicked} ref={(ref) => { this.repeat = ref }}> <span className={styles.refresh} onClick={refreshClicked} ref={(ref) => { this.repeat = ref }}>
{ {
@ -175,8 +173,8 @@ class Network extends Component {
} }
</span> </span>
</section> </section>
</header> </header>
} }
<ul className={filterPulldown && styles.fade}> <ul className={filterPulldown && styles.fade}>
{ {
@ -276,7 +274,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} />
@ -305,6 +303,7 @@ Network.propTypes = {
balance: PropTypes.object.isRequired, balance: PropTypes.object.isRequired,
currentTicker: PropTypes.object.isRequired, currentTicker: PropTypes.object.isRequired,
ticker: PropTypes.object.isRequired, ticker: PropTypes.object.isRequired,
suggestedNodesProps: PropTypes.object.isRequired,
fetchChannels: PropTypes.func.isRequired, fetchChannels: PropTypes.func.isRequired,
openContactsForm: PropTypes.func.isRequired, openContactsForm: PropTypes.func.isRequired,

32
app/components/Contacts/SuggestedNodes.js

@ -2,7 +2,12 @@ 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, setNode, openSubmitChannelForm }) => { const SuggestedNodes = ({
suggestedNodesLoading,
suggestedNodes,
setNode,
openSubmitChannelForm
}) => {
const nodeClicked = (n) => { const nodeClicked = (n) => {
// set the node public key for the submit form // set the node public key for the submit form
setNode({ pub_key: n.pubkey, addresses: [{ addr: n.host }] }) setNode({ pub_key: n.pubkey, addresses: [{ addr: n.host }] })
@ -22,23 +27,22 @@ const SuggestedNodes = ({ suggestedNodesLoading, suggestedNodes, setNode, openSu
return ( return (
<div className={styles.container}> <div className={styles.container}>
<header> <header>
Hmmm, looks like you don't have any channels yet. Here are some suggested nodes to open a channel with to get started {'Hmmm, looks like you don\'t have any channels yet. Here are some suggested nodes to open a channel with to get started'}
</header> </header>
<ul className={styles.suggestedNodes}> <ul className={styles.suggestedNodes}>
{ {
suggestedNodes.map(node => ( suggestedNodes.map(node => (
<li key={node.pubkey}> <li key={node.pubkey}>
<section> <section>
<span>{node.nickname}</span> <span>{node.nickname}</span>
<span>{`${node.pubkey.substring(0, 30)}...`}</span> <span>{`${node.pubkey.substring(0, 30)}...`}</span>
</section> </section>
<section> <section>
<span onClick={() => nodeClicked(node)}>Connect</span> <span onClick={() => nodeClicked(node)}>Connect</span>
</section> </section>
</li> </li>
) ))
)
} }
</ul> </ul>
</div> </div>

8
app/reducers/channels.js

@ -170,7 +170,7 @@ export function receiveSuggestedNodes(suggestedNodes) {
export const fetchSuggestedNodes = () => async (dispatch) => { export const fetchSuggestedNodes = () => async (dispatch) => {
dispatch(getSuggestedNodes()) dispatch(getSuggestedNodes())
const suggestedNodes = await requestSuggestedNodes() const suggestedNodes = await requestSuggestedNodes()
dispatch(receiveSuggestedNodes(suggestedNodes)) dispatch(receiveSuggestedNodes(suggestedNodes))
} }
@ -369,7 +369,7 @@ const ACTION_HANDLERS = {
[CLOSE_CONTACT_MODAL]: state => ({ ...state, contactModal: { isOpen: false, channel: null } }), [CLOSE_CONTACT_MODAL]: state => ({ ...state, contactModal: { isOpen: false, channel: null } }),
[SET_SELECTED_CHANNEL]: (state, { selectedChannel }) => ({ ...state, selectedChannel }), [SET_SELECTED_CHANNEL]: (state, { selectedChannel }) => ({ ...state, selectedChannel }),
[GET_SUGGESTED_NODES]: state => ({ ...state, suggestedNodesLoading: true }), [GET_SUGGESTED_NODES]: state => ({ ...state, suggestedNodesLoading: true }),
[RECEIVE_SUGGESTED_NODES]: (state, { suggestedNodes }) => ({ ...state, suggestedNodesLoading: false, suggestedNodes }) [RECEIVE_SUGGESTED_NODES]: (state, { suggestedNodes }) => ({ ...state, suggestedNodesLoading: false, suggestedNodes })
} }
@ -564,8 +564,8 @@ const initialState = {
selectedChannel: null, selectedChannel: null,
// nodes stored at zap.jackmallers.com/suggested-peers manages by JimmyMow // nodes stored at zap.jackmallers.com/suggested-peers manages by JimmyMow
// we store this node list here and if the user doesnt have any channels // we store this node list here and if the user doesnt have any channels
// we show them this list in case they wanna use our suggestions to connect // we show them this list in case they wanna use our suggestions to connect
// to the network and get started // to the network and get started
// **** Example **** // **** Example ****
// { // {

1
app/routes/app/components/App.js

@ -129,6 +129,7 @@ App.propTypes = {
fetchChannels: PropTypes.func.isRequired, fetchChannels: PropTypes.func.isRequired,
fetchBalance: PropTypes.func.isRequired, fetchBalance: PropTypes.func.isRequired,
fetchDescribeNetwork: PropTypes.func.isRequired, fetchDescribeNetwork: PropTypes.func.isRequired,
fetchSuggestedNodes: PropTypes.func.isRequired,
children: PropTypes.object.isRequired children: PropTypes.object.isRequired
} }

3
app/routes/app/containers/AppContainer.js

@ -137,7 +137,6 @@ const mapDispatchToProps = {
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
info: state.info,
activity: state.activity, activity: state.activity,
lnd: state.lnd, lnd: state.lnd,
@ -320,7 +319,7 @@ 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, setNode: dispatchProps.setNode,
openSubmitChannelForm: () => dispatchProps.setChannelFormType('SUBMIT_CHANNEL_FORM') openSubmitChannelForm: () => dispatchProps.setChannelFormType('SUBMIT_CHANNEL_FORM')
} }

25
test/reducers/__snapshots__/channels.spec.js.snap

@ -54,6 +54,11 @@ Object {
}, },
"searchQuery": "", "searchQuery": "",
"selectedChannel": null, "selectedChannel": null,
"suggestedNodes": Object {
"mainnet": Array [],
"testnet": Array [],
},
"suggestedNodesLoading": false,
"viewType": 0, "viewType": 0,
} }
`; `;
@ -112,6 +117,11 @@ Object {
}, },
"searchQuery": "", "searchQuery": "",
"selectedChannel": null, "selectedChannel": null,
"suggestedNodes": Object {
"mainnet": Array [],
"testnet": Array [],
},
"suggestedNodesLoading": false,
"viewType": 0, "viewType": 0,
} }
`; `;
@ -171,6 +181,11 @@ Object {
], ],
"searchQuery": "", "searchQuery": "",
"selectedChannel": null, "selectedChannel": null,
"suggestedNodes": Object {
"mainnet": Array [],
"testnet": Array [],
},
"suggestedNodesLoading": false,
"viewType": 0, "viewType": 0,
} }
`; `;
@ -229,6 +244,11 @@ Object {
}, },
"searchQuery": "", "searchQuery": "",
"selectedChannel": null, "selectedChannel": null,
"suggestedNodes": Object {
"mainnet": Array [],
"testnet": Array [],
},
"suggestedNodesLoading": false,
"viewType": 0, "viewType": 0,
} }
`; `;
@ -287,6 +307,11 @@ Object {
}, },
"searchQuery": "", "searchQuery": "",
"selectedChannel": null, "selectedChannel": null,
"suggestedNodes": Object {
"mainnet": Array [],
"testnet": Array [],
},
"suggestedNodesLoading": false,
"viewType": 0, "viewType": 0,
} }
`; `;

Loading…
Cancel
Save