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

Commit

Permalink
Add warning to web browser and fix links. (#6232)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw authored and ngotchac committed Aug 18, 2017
1 parent 08d7ee7 commit cf3e8df
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
1 change: 1 addition & 0 deletions js/src/views/Home/Urls/urls.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
color: rgb(0, 151, 167);
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
}

.timestamp {
Expand Down
2 changes: 1 addition & 1 deletion js/src/views/Home/Urls/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class Urls extends Component {
this.props.store.gotoUrl(url);

if (extensionStore.hasExtension) {
window.open(this.props.store.currentUrl, '_blank');
window.open(url, '_blank');
} else {
router.push('/web');
}
Expand Down
7 changes: 2 additions & 5 deletions js/src/views/Web/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,9 @@ export default class Store {
if (!hasProtocol.test(url)) {
url = `https://${url}`;
}

this.setNextUrl(url);
return this.generateToken(url).then(() => {
transaction(() => {
this.setNextUrl(url);
this.setCurrentUrl(this.nextUrl);
});
this.setCurrentUrl(this.nextUrl);
});
}

Expand Down
31 changes: 30 additions & 1 deletion js/src/views/Web/web.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,39 @@
width: 100%;
}

:root .warningClose {
text-align: right;
a {
color: #fff;
text-decoration: underline;
}
}

.warning {
color: #fff;
background: #f80;
position: fixed;
bottom: 0;
left: 0;
right: 50%;
padding: 1.5em;
z-index: 100;
animation: fadein 0.3s;
}

@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

.loading {
text-align: center;
margin-top: 5em;
color: #999;
color: #444;
font-size: 2em;
}

Expand Down
30 changes: 30 additions & 0 deletions js/src/views/Web/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export default class Web extends Component {

store = Store.get(this.context.api);

state = {
isWarningDismissed: false
}

componentDidMount () {
this.store.gotoUrl(this.props.params.url);
}
Expand Down Expand Up @@ -83,10 +87,36 @@ export default class Web extends Component {
scrolling='auto'
src={ encodedPath }
/>
{ this.renderWarning() }
</div>
);
}

renderWarning () {
if (this.state.isWarningDismissed) {
return null;
}

return (
<div className={ styles.warning }>
<p>
WARNING: The web browser dapp is not safe as a general purpose browser.
Make sure to only visit web3-enabled sites that you trust.
Do not use it to browse web2.0 and never log in to any service - web3 dapps should not require that.
</p>
<div className={ styles.warningClose }>
<a onClick={ this.dismissWarning }>Okay!</a>
</div>
</div>
);
}

dismissWarning = () => {
this.setState({
isWarningDismissed: true
});
};

iframeOnLoad = () => {
this.store.setLoading(false);
};
Expand Down

0 comments on commit cf3e8df

Please sign in to comment.