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

let users open urls from dapps view #4042

Merged
merged 8 commits into from Jan 5, 2017
Merged

let users open urls from dapps view #4042

merged 8 commits into from Jan 5, 2017

Conversation

derhuerst
Copy link
Contributor

Fixes #3957.

@derhuerst derhuerst added A0-pleasereview 🤓 Pull request needs code review. M7-ui labels Jan 4, 2017
import styles from './urlButton.css';

class UrlButton extends Component {
static propTypes = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

router is actually also available on the context, so we don't need the withRouter wrapper. Could just do static contextTypes = { router: PropTypes.object.isRequired }, e.g. Same as what we do in views/Settings/settings.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed the a react-router guide, which says this:

Prior to 2.4.0, you could access the router object via this.context. This is still true, but context is often times a difficult and error-prone API to work with.

In order to more easily access the router object, a withRouter higher-order component has been added as the new primary means of access.

It's important to note this is not a deprecation of the context API. As long as React supports this.context in its current form, any code written for that API will continue to work. We will continue to use it internally and you can continue to write in that format, if you want. We think this new HoC is nicer and easier, and will be using it in documentation and examples, but it is not a hard requirement to switch.

onBlur={ this.hideInput }
onFocus={ this.showInput }
onSubmit={ this.inputOnSubmit }
style={ { display: 'inline-block', width: '20em' } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small picky thing, but wouldn't it make more sense to define the style as a constant and then just reference it here?

@@ -88,6 +89,9 @@ class Dapps extends Component {
defaultMessage='Decentralized Applications' />
}
buttons={ [
<UrlButton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this could just be a single line since there is only one attribute

});
};

handleIframeLoad = (ev) => {
iframeOnLoad = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly onIframeLoad since it is an event?

Copy link
Contributor Author

@derhuerst derhuerst Jan 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it is a load even on the iframe, not a iframeLoad event. I think the current form is more expressive. Still, having all even handlers begin with on is a fair point.

@jacogr
Copy link
Contributor

jacogr commented Jan 4, 2017

Some small comments, but looking quite good. (Just want to play a bit to see if anything pops out)

@ngotchac
Copy link
Contributor

ngotchac commented Jan 5, 2017

One remark though: the protocol is not inferred, hence typing google.fr will result in an error. Secondly, no errors are shown, thus inputting a wrong URL leaves the user with a Requesting access token... message

@ngotchac ngotchac added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 5, 2017
@derhuerst derhuerst added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Jan 5, 2017
let host = parsed.host;
let path = parsed.path;
if (!host) {
host = parsed.path.split(pathSep).slice(0, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this returning an array ? It's fine with the cast to String though, but still...

let path = parsed.path;
if (!host) {
host = parsed.path.split(pathSep).slice(0, 1);
path = parsed.path.split(pathSep).slice(1).join(pathSep);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there missing the first / then ? Try reddit.com/r/ethereum

Also, what's the point of using pathSep ? Should always be / with URLs, no ?

Copy link
Contributor Author

@derhuerst derhuerst Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what's the point of using pathSep ? Should always be / with URLs, no ?

You're right. I am so much into "always use path.sep to make modules cross-platform" that i didn't think about it.

@ngotchac ngotchac added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 5, 2017
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling f402ca7 on jr-url-input into ** on master**.

@derhuerst derhuerst added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Jan 5, 2017
@derhuerst derhuerst dismissed ngotchac’s stale review January 5, 2017 17:01

addressed grumbles

@ngotchac ngotchac added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 5, 2017
@gavofyork gavofyork merged commit 20c1d37 into master Jan 5, 2017
@gavofyork gavofyork deleted the jr-url-input branch January 5, 2017 20:15
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

5 participants