Skip to content
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

Warn / Prevent Outdated Browsers from Wallet Generation #329

Merged
merged 4 commits into from
Nov 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/components/ui/NewTabLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';

interface AAttributes {
charset?: string;
className?: string;
coords?: string;
download?: string;
href: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@import "common/sass/variables";

.CryptoWarning {
max-width: 740px;
margin: 0 auto;
text-align: center;

&-title {
margin-bottom: 15px;
}

&-text {
margin-bottom: 30px;
}

&-browsers {
&-browser {
display: inline-block;
width: 86px;
margin: 0 25px;
color: $text-color;
opacity: 0.8;
transition: opacity 100ms ease;

&:hover {
opacity: 1;
}

&-icon {
width: 100%;
height: auto;
margin-bottom: 10px;
}

&-name {
font-size: 18px;
font-weight: 300;
}
}
}
}
66 changes: 66 additions & 0 deletions common/containers/Tabs/GenerateWallet/components/CryptoWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import * as React from 'react';
import NewTabLink from 'components/ui/NewTabLink';
import isMobile from 'utils/isMobile';

import firefoxIcon from 'assets/images/browsers/firefox.svg';
import chromeIcon from 'assets/images/browsers/chrome.svg';
import operaIcon from 'assets/images/browsers/opera.svg';
import './CryptoWarning.scss';

const BROWSERS = [{
name: "Firefox",
href: "https://www.mozilla.org/en-US/firefox/new/",
icon: firefoxIcon,
}, {
name: "Chrome",
href: "https://www.google.com/chrome/browser/desktop/index.html",
icon: chromeIcon,
}, {
name: "Opera",
href: "http://www.opera.com/",
icon: operaIcon,
}];

const CryptoWarning: React.SFC<{}> = () =>
<div className="Tab-content-pane">
<div className="CryptoWarning">
<h2 className="CryptoWarning-title">
Your Browser Cannot Generate a Wallet
</h2>
<p className="CryptoWarning-text">
{isMobile ? `
MyEtherWallet requires certain features for secure wallet generation
that your browser doesn't offer. You can still securely use the site
otherwise. To generate a wallet, please use your device's default
browser, or switch to a laptop or desktop computer.
` : `
MyEtherWallet requires certain features for secure wallet generation
that your browser doesn't offer. You can still securely use the site
otherwise. To generate a wallet, upgrade to one of the following
browsers:
`}
</p>

<div className="CryptoWarning-browsers">
{BROWSERS.map((browser) =>
<NewTabLink
key={browser.href}
href={browser.href}
className="CryptoWarning-browsers-browser"
>
<div>
<img
className="CryptoWarning-browsers-browser-icon"
src={browser.icon}
/>
<div className="CryptoWarning-browsers-browser-name">
{browser.name}
</div>
</div>
</NewTabLink>
)}
</div>
</div>
</div>

export default CryptoWarning;
60 changes: 33 additions & 27 deletions common/containers/Tabs/GenerateWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AppState } from 'reducers';
import DownloadWallet from './components/DownloadWallet';
import EnterPassword from './components/EnterPassword';
import PaperWallet from './components/PaperWallet';
import CryptoWarning from './components/CryptoWarning';
import TabSection from 'containers/TabSection';

interface Props {
Expand All @@ -38,38 +39,43 @@ class GenerateWallet extends Component<Props, {}> {

const AnyEnterPassword = EnterPassword as new () => any;

switch (activeStep) {
case 'password':
content = (
<AnyEnterPassword
walletPasswordForm={this.props.walletPasswordForm}
generateNewWallet={this.props.generateNewWallet}
/>
);
break;

case 'download':
if (wallet) {
if (window.crypto) {
switch (activeStep) {
case 'password':
content = (
<DownloadWallet
wallet={wallet}
password={password}
continueToPaper={this.props.continueToPaper}
<AnyEnterPassword
walletPasswordForm={this.props.walletPasswordForm}
generateNewWallet={this.props.generateNewWallet}
/>
);
}
break;
break;

case 'paper':
if (wallet) {
content = <PaperWallet wallet={wallet} />;
} else {
content = <h1>Uh oh. Not sure how you got here.</h1>;
}
break;
case 'download':
if (wallet) {
content = (
<DownloadWallet
wallet={wallet}
password={password}
continueToPaper={this.props.continueToPaper}
/>
);
}
break;

case 'paper':
if (wallet) {
content = <PaperWallet wallet={wallet} />;
} else {
content = <h1>Uh oh. Not sure how you got here.</h1>;
}
break;

default:
content = <h1>Uh oh. Not sure how you got here.</h1>;
default:
content = <h1>Uh oh. Not sure how you got here.</h1>;
}
}
else {
content = <CryptoWarning/>;
}

return (
Expand Down
4 changes: 4 additions & 0 deletions common/utils/isMobile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const isMobile = window && window.navigator ?
/iPhone|iPad|iPod|Android/i.test(window.navigator.userAgent) : false;

export default isMobile;