-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Private network support #49
Conversation
I noticed that there is a generated sass cache file being committed here. Should we be avoiding committing generated files other than the package lock files? |
@@ -6,7 +6,12 @@ import NetworkSwitcher from '../../src/app/components/NetworkSwitcher' | |||
|
|||
const setup = () => { | |||
const props = { | |||
network: { name: 'MainNet' }, | |||
networkId: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the difference between the networkId and the networks map below it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
network/networkId is the currently selected network. Networks is a listing of all available networks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but I'm wondering how they map to each other, or if they do at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state.network.id is the id for accessing the config object states.config.networks. you think we should just add it to state.config.currentNetworkId or something like that?
@@ -0,0 +1,2 @@ | |||
import AddCustomNetwork from './AddCustomNetwork' | |||
export default AddCustomNetwork |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be condensed to export { default as AddCustomNetwork } from './AddCustomNetwork'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
} | ||
}) | ||
|
||
let content = (<div>You have no custom networks defined</div>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be condensed a bit.
const content = networkRows.length
? <div>{ networkRows }</div>
: <div>You have no custom networks defined</div>
or even
const content = networkRows.length ? { networkRows } : 'You have no custom networks defined'
|
||
const networkRows = [] | ||
|
||
networks.forEach((network, index) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to keep this kind of logic outside of the render function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're saying just throw it in a different method of the same class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, render functions are ideally just template expressions. All of the generation of children are best abstracted out to their own methods for easy testing and clear understanding of their functionality.
@@ -0,0 +1,2 @@ | |||
import CustomNetworkList from './CustomNetworkList' | |||
export default CustomNetworkList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
src/app/containers/Config/Config.js
Outdated
<div> | ||
<TabBar | ||
style={ { | ||
position: 'absolute', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be moved to a stylesheet?
</div> | ||
) | ||
} | ||
import { connect } from 'react-redux' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job here
@@ -61,7 +62,14 @@ export default class Transactions extends Component { | |||
) | |||
return ( | |||
// <ul style="overflow: hidden;">{listItems}</ul> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be removed?
<textarea readOnly style='border: 0; bottom: 0;' rows='20' cols='40' name='transactionList'>{listItems}</textarea> | ||
<textarea | ||
readOnly | ||
style={ { border: 0, bottom: 0 } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be handled in some sort of reset or moved to CSS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. I was just fixing this part so it worked. I think transactions needs a good once over in general.
@@ -1,2 +1,3 @@ | |||
**/*.html | |||
build/* | |||
coverage/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this something that is generated by the package or your local environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you run tests with coverage, yes
For the sass file, I agree it shouldn't be in the repo. Removing causes builds to fail. I think it should be handled separately. |
delete = (index) => { | ||
const { deleteCustomNetwork, setNetwork, selectedNetworkId } = this.props | ||
|
||
// If this is the current network they're using, reset to MainNet (index 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still valid?
import PropTypes from 'prop-types' | ||
|
||
import { TabBar, Tab } from 'rmwc/Tabs' | ||
import '@material/tabs/dist/mdc.tabs.min.css' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in progress on cleaning up some code, and I haven't needed to include the component CSS along with it. Have you tried without?
src/app/containers/Config/Config.js
Outdated
activeTabIndex={ this.state.activeTabIndex || 0 } | ||
onChange={ evt => this.setState({ 'activeTabIndex': evt.target.value }) } | ||
> | ||
<Tab style={ { display: 'table-cell' } }>Networks</Tab> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use css classes for any styling we need to do. In addition table-cell isn't the best for layout, have you considered a flexbox alternative?
<textarea readOnly style='border: 0; bottom: 0;' rows='20' cols='40' name='transactionList'>{listItems}</textarea> | ||
<textarea | ||
readOnly | ||
style={ { border: 0, bottom: 0 } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put this in our stylesheet or a reset?
src/app/reducers/config.js
Outdated
}, | ||
[ActionTypes.ADD_CUSTOM_NETWORK] (state, action) { | ||
const networks = { ...state.networks } | ||
networks[uuidv4()] = { name: action.name, url: action.url, canDelete: true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
…when we also support neoscan
Adds configuration panes to add/delete private networks.
Can be used by developers running NeonDB + a private NEO blockchain.
This PR also adds the CoZ Testnet as a third default option.
To test, if you don't have a private network set up you can add a copy of testnet with URL:
http://testnet-api.wallet.cityofzion.io
Here's what the add page looks like:
Some things to test: