Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

registry dapp: cleanup, support reverse entries #3933

Merged
merged 22 commits into from
Dec 27, 2016
Merged

Conversation

derhuerst
Copy link
Contributor

@derhuerst derhuerst commented Dec 21, 2016

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.

@derhuerst derhuerst added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. M7-ui labels Dec 21, 2016
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 49e00ed on jr-registry-reverse into ** on master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 64c3ca5 on jr-registry-reverse into ** on master**.

@derhuerst derhuerst added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Dec 22, 2016
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 85.77% when pulling 187a1c2 on jr-registry-reverse into be75cbf on master.

all: PropTypes.object.isRequired,
selected: PropTypes.object
selected: PropTypes.object,

Copy link
Contributor

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.

Copy link
Contributor Author

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 }
Copy link
Contributor

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,
Copy link
Contributor

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)
Copy link
Contributor

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;
Copy link
Contributor

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' ? (
Copy link
Contributor

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) => {
Copy link
Contributor

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)

Copy link
Contributor Author

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') {
Copy link
Contributor

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
Copy link
Contributor

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) => {
Copy link
Contributor

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.

Copy link
Contributor Author

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) => {
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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 }>
Copy link
Contributor

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 = {
Copy link
Contributor

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.

Copy link
Contributor Author

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 = {
Copy link
Contributor

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 {
Copy link
Contributor

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 = {
Copy link
Contributor

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 = {
Copy link
Contributor

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}`;
Copy link
Contributor

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;
Copy link
Contributor

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.

@derhuerst
Copy link
Contributor Author

Adressed most grumbles. For the rest, I either disagree or have questions.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 86.515% when pulling 48ab2fe on jr-registry-reverse into c2e5b78 on master.

@jacogr
Copy link
Contributor

jacogr commented Dec 25, 2016

Merge conflicts.

@jacogr jacogr added A7-looksgoodcantmerge 🙄 Pull request is reviewed well, but cannot be merged due to conflicts. and removed A0-pleasereview 🤓 Pull request needs code review. labels Dec 25, 2016
@derhuerst derhuerst added A8-looksgood 🦄 Pull request is reviewed well. and removed A7-looksgoodcantmerge 🙄 Pull request is reviewed well, but cannot be merged due to conflicts. labels Dec 26, 2016
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 66ef54b on jr-registry-reverse into ** on master**.

@gavofyork gavofyork merged commit 002e8b0 into master Dec 27, 2016
@gavofyork gavofyork deleted the jr-registry-reverse branch December 27, 2016 10:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants