-
Notifications
You must be signed in to change notification settings - Fork 1.7k
registry dapp: cleanup, support reverse entries #3933
Conversation
In preparation for the next commit.
Changes Unknown when pulling 49e00ed on jr-registry-reverse into ** on master**. |
Changes Unknown when pulling 64c3ca5 on jr-registry-reverse into ** on master**. |
all: PropTypes.object.isRequired, | ||
selected: PropTypes.object | ||
selected: PropTypes.object, | ||
|
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.
Extra empty line for no immediately apparent reason.
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.
props and actions separated.
@@ -61,20 +65,27 @@ export default class Accounts extends Component { | |||
} | |||
|
|||
renderAccount = (account) => { | |||
const { all, selected } = this.props; | |||
const { selected } = this.props; | |||
const isSelected = selected && selected.address === account.address; | |||
|
|||
return ( | |||
<MenuItem | |||
key={ account.address } value={ account.address } | |||
checked={ isSelected } insetChildren={ !isSelected } |
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 related, however not sure why this stayed this way - everywhere we have an attribute per line
|
||
export default connect( | ||
// mapStateToProps | ||
(state) => state.accounts, |
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 we have to comment this to state intent, something is wrong, the code should just be self-explanatory (if the reader gets confused, it means we are not making the writing clear enough - a reason why in the rest of the app the functions are properly named)
events: PropTypes.object.isRequired, | ||
names: PropTypes.object.isRequired, | ||
records: PropTypes.object.isRequired | ||
fee: nullableProptype(PropTypes.object.isRequired) |
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.
Probably would make more sense as nullableProptype(PropTypes.object).isRequired
?
.inline { | ||
display: inline-block; | ||
width: auto; | ||
marginRight: 1em; |
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.
margin-right?
<MenuItem value='propose' primaryText='propose a reverse entry' /> | ||
<MenuItem value='confirm' primaryText='confirm a reverse entry' /> | ||
</DropDownMenu> | ||
{ action === 'propose' ? ( |
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.
As per above, slightly more readable since there is a null for one condition, but the reader and maintainer gets lost here)
onNameChange = (e) => { | ||
this.setState({ name: e.target.value }); | ||
}; | ||
onAddressChange = (e) => { |
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.
Lines between functions. (All the ones below here could use the whitespace)
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.
Leftover.
}; | ||
onSubmitClick = () => { | ||
const { action, name, address } = this.state; | ||
if (action === 'propose') { |
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.
Blank line between variables and tests.
} | ||
|
||
export default connect( | ||
// mapStateToProps |
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.
As per other places.
|
||
export const fetchIsTestnet = () => (dispatch) => | ||
api.net.version() | ||
.then((netVersion) => { |
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.
Indent .then as per the rest of the codebase and the other files in this PR.
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.
Leftover.
netVersion === '3' // ropsten | ||
)); | ||
}) | ||
.catch((err) => { |
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.
.catch on same level as .then (not start of line)
text-decoration: none; | ||
color: inherit; | ||
} | ||
.link:hover { |
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.
Either use
.link {
...
&:hover {
...
}
}
Or at the very least put blank lines before the blocks.
.link:hover { | ||
text-decoration: underline; | ||
} | ||
.link abbr { |
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.
As per above comment. (PostCSS allows nesting)
return ( | ||
<div style={ container }> | ||
<IdentityIcon address={ address } style={ align } /> | ||
<div key={ key } className={ styles.container }> |
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.
Single attribute per line when multiples.
{ caption } | ||
</div> | ||
); | ||
}; | ||
|
||
Address.propTypes = { |
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.
No static? This doesn't fit in with the rest of the codebase 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.
I guess this is not the place to discuss functional vs class
components, so I will adapt it. 😉
shortenHash: PropTypes.bool | ||
}; | ||
|
||
Address.defaultProps = { |
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 per previous comment.
text-decoration: none; | ||
color: inherit; | ||
} | ||
.link:hover { |
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.
PostCSS nesting or at least a blank line between blocks.
return (<abbr title={ hash }>{ shortened }</abbr>); | ||
}; | ||
|
||
Hash.propTypes = { |
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.
Let's do components in one way, here even in the PR we have different approaches. Consistency yields ease of maintainability.
linked: PropTypes.bool | ||
}; | ||
|
||
Hash.defaultProps = { |
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.
As per above. Nothing wrong with simple components, but as soon as we start doing this we are adding yet another way of writing code.
const etherscanUrl = (hash, isTestnet) => { | ||
hash = hash.toLowerCase().replace(leading0x, ''); | ||
const type = hash.length === 40 ? 'address' : 'tx'; | ||
return `https://${isTestnet ? 'testnet.' : ''}etherscan.io/${type}/0x${hash}`; |
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.
Blank like before return would be appreciated here.
if (err && err.type === 'REQUEST_REJECTED') { | ||
throw new Error('The request has been rejected.'); | ||
} | ||
throw err; |
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.
Consider a blank line before.
Adressed most grumbles. For the rest, I either disagree or have questions. |
Merge conflicts. |
Changes Unknown when pulling 66ef54b on jr-registry-reverse into ** on master**. |
Fixes #3098, with the exception of
removeReverse
. Fixes #2933.Work in progress, not happy with the actions & reducers boilerplate. Also the captions in the UI are not very helpful.