Skip to content

Commit

Permalink
Merge pull request #19 from MyEtherWallet/cleanup-v2
Browse files Browse the repository at this point in the history
Cleanup round #2
  • Loading branch information
dternyak authored Jun 20, 2017
2 parents 227abd5 + 1a4fac1 commit 59b0d44
Show file tree
Hide file tree
Showing 10 changed files with 319 additions and 313 deletions.
35 changes: 18 additions & 17 deletions common/actions/generateWallet.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
export const GENERATE_WALLET_SHOW_PASSWORD = 'GENERATE_WALLET_SHOW_PASSWORD';
export const GENERATE_WALLET_FILE = 'GENERATE_WALLET_FILE'
export const GENERATE_WALLET_HAS_DOWNLOADED_FILE = 'GENERATE_WALLET_HAS_DOWNLOADED_FILE'
export const GENERATE_WALLET_CONTINUE_TO_PAPER = 'GENERATE_WALLET_CONTINUE_TO_PAPER'
import {
GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER,
GENERATE_WALLET_FILE,
GENERATE_WALLET_DOWNLOAD_FILE,
GENERATE_WALLET_SHOW_PASSWORD
} from 'actions/generateWalletConstants';

export const showPasswordGenerateWallet = () => {
return { type: GENERATE_WALLET_SHOW_PASSWORD };
};

export const SHOW_GENERATE_WALLET_PASSWORD_ACTION = () => Object ({
type: GENERATE_WALLET_SHOW_PASSWORD
})
export const generateFileGenerateWallet = () => {
return { type: GENERATE_WALLET_FILE };
};

export const GENERATE_WALLET_FILE_ACTION = () => Object ({
type: GENERATE_WALLET_FILE
})
export const downloadFileGenerateWallet = () => {
return { type: GENERATE_WALLET_DOWNLOAD_FILE };
};

export const GENERATE_WALLET_HAS_DOWNLOADED_FILE_ACTION = () => Object ({
type: GENERATE_WALLET_HAS_DOWNLOADED_FILE
})

export const GENERATE_WALLET_CONTINUE_TO_PAPER_ACTION = () => Object ({
type: GENERATE_WALLET_CONTINUE_TO_PAPER
})
export const confirmContinueToPaperGenerateWallet = () => {
return { type: GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER };
};
5 changes: 5 additions & 0 deletions common/actions/generateWalletConstants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const GENERATE_WALLET_SHOW_PASSWORD = 'GENERATE_WALLET_SHOW_PASSWORD';
export const GENERATE_WALLET_FILE = 'GENERATE_WALLET_FILE';
export const GENERATE_WALLET_DOWNLOAD_FILE = 'GENERATE_WALLET_DOWNLOAD_FILE';
export const GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER =
'GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER';
10 changes: 5 additions & 5 deletions common/actions/swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ import {
SWAP_UPDATE_BITY_RATES
} from './swapConstants';

export const SWAP_ORIGIN_KIND_TO = value => {
export const originKindSwap = value => {
return {
type: SWAP_ORIGIN_KIND,
value
};
};

export const SWAP_DESTINATION_KIND_TO = value => {
export const destinationKindSwap = value => {
return {
type: SWAP_DESTINATION_KIND,
value
};
};

export const SWAP_ORIGIN_AMOUNT_TO = value => {
export const originAmountSwap = value => {
return {
type: SWAP_ORIGIN_AMOUNT,
value
};
};

export const SWAP_DESTINATION_AMOUNT_TO = value => {
export const destinationAmountSwap = value => {
return {
type: SWAP_DESTINATION_AMOUNT,
value
};
};

export const SWAP_UPDATE_BITY_RATES_TO = value => {
export const updateBityRatesSwap = value => {
return {
type: SWAP_UPDATE_BITY_RATES,
value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,141 +1,159 @@
import React, {Component} from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {Field, reduxForm} from 'redux-form';
import { Field, reduxForm } from 'redux-form';
import GenerateWalletPasswordInputComponent from './GenerateWalletPasswordInputComponent';
import LedgerTrezorWarning from './LedgerTrezorWarning';
import translate from 'translations';


// VALIDATORS
const minLength = min => value => {
return value && value.length < min ? `Must be ${min} characters or more` : undefined
return value && value.length < min
? `Must be ${min} characters or more`
: undefined;
};
const minLength9 = minLength(9);
const required = value => value ? undefined : 'Required';

const required = value => (value ? undefined : 'Required');

class GenerateWalletPasswordComponent extends Component {
constructor(props) {
super(props)
}

static propTypes = {
title: PropTypes.string,
body: PropTypes.string,
userId: PropTypes.number,
id: PropTypes.number,
generateWalletPassword: PropTypes.object,
showPassword: PropTypes.bool,
showGenerateWalletPasswordAction: PropTypes.func,
generateWalletFileAction: PropTypes.func,
generateWalletHasDownloadedFileAction: PropTypes.func,
generateWalletFile: PropTypes.bool,
hasDownloadedWalletFile: PropTypes.bool,
generateWalletContinueToPaperAction: PropTypes.func,
canProceedToPaper: PropTypes.bool
};
constructor(props) {
super(props);
}

static propTypes = {
// state
title: PropTypes.string,
body: PropTypes.string,
userId: PropTypes.number,
id: PropTypes.number,
generateWalletPassword: PropTypes.object,
showPassword: PropTypes.bool,
generateWalletFile: PropTypes.bool,
hasDownloadedWalletFile: PropTypes.bool,
canProceedToPaper: PropTypes.bool,
// actions
showPasswordGenerateWallet: PropTypes.func,
generateFileGenerateWallet: PropTypes.func,
downloadFileGenerateWallet: PropTypes.func,
confirmContinueToPaperGenerateWallet: PropTypes.func
};

continueToPaper() {
}
continueToPaper() {}

downloaded() {
let nextState = this.state;
nextState.hasDownloadedWalletFile = true;
this.setState(nextState)
}
downloaded() {
let nextState = this.state;
nextState.hasDownloadedWalletFile = true;
this.setState(nextState);
}

render() {
const {
generateWalletPassword,
showPassword,
generateWalletFile,
hasDownloadedWalletFile,
showPasswordGenerateWallet,
generateFileGenerateWallet,
downloadFileGenerateWallet,
confirmContinueToPaperGenerateWallet
} = this.props;

render() {
const {
// handleSubmit,
// pristine,
// reset,
// submitting,
generateWalletPassword,
showPassword,
showGenerateWalletPasswordAction,
generateWalletFileAction,
generateWalletFile,
hasDownloadedWalletFile,
generateWalletHasDownloadedFileAction,
generateWalletContinueToPaperAction
// canProceedToPaper

} = this.props;

return (
<section className="container" style={{minHeight: '50%'}}>
<div className="tab-content">
<main className="tab-pane active text-center" role="main">
<br/>
{
!generateWalletFile && (
<div>
<section className="row">
<h1 aria-live="polite">{translate('NAV_GenerateWallet')}</h1>
<div className="col-sm-8 col-sm-offset-2">
<h4>{translate('HELP_1_Desc_3')}</h4>
<Field
validate={[required, minLength9]}
component={GenerateWalletPasswordInputComponent}
showPassword={showPassword}
showGenerateWalletPasswordAction={showGenerateWalletPasswordAction}
name="password"
type="text"/>
<br/>
<button onClick={() => generateWalletFileAction()}
disabled={generateWalletPassword ? generateWalletPassword.syncErrors : true}
className="btn btn-primary btn-block">
{translate('NAV_GenerateWallet')}
</button>
</div>
</section>
<LedgerTrezorWarning/>
</div>
)
}
{
generateWalletFile && (
<section role="main" className="row">
<h1>{translate('GEN_Label_2')}</h1>
<br/>
<div className="col-sm-8 col-sm-offset-2">
<div aria-hidden="true" className="account-help-icon"><img
src="https://myetherwallet.com/images/icon-help.svg" className="help-icon"/>
<p className="account-help-text">{translate('x_KeystoreDesc')}</p>
<h4>{translate('x_Keystore2')}</h4>
</div>
<a role="button" className="btn btn-primary btn-block"
href="blob:https://myetherwallet.com/2455ae32-916f-4224-a806-414bbe680168"
download="UTC--2017-04-26T23-07-03.538Z--c5b7fff4e1669e38e8d6bc8fffe7e562b2b70f43"
aria-label="Download Keystore File (UTC / JSON · Recommended · Encrypted)"
aria-describedby="x_KeystoreDesc"
onClick={() => generateWalletHasDownloadedFileAction()}>{translate('x_Download')}</a>
<p className="sr-only" id="x_KeystoreDesc">{translate('x_KeystoreDesc')}</p>
<br/><br/><br/><br/>
</div>
<div className="col-xs-12 alert alert-danger">
<span>
MyEtherWallet.com is not a web wallet &amp; does not store or transmit this secret information at any time. <br/>
<strong>If you do not save your wallet file and password, we cannot recover them.</strong><br/>
Save your wallet file now &amp; back it up in a second location (not on your computer).
<br/><br/>
<a role="button"
className={`btn btn-info ${hasDownloadedWalletFile ? '' : 'disabled'}`}
onClick={() => generateWalletContinueToPaperAction()}> I understand. Continue. </a>
</span>
</div>
</section>
)
}
</main>
return (
<section className="container" style={{ minHeight: '50%' }}>
<div className="tab-content">
<main className="tab-pane active text-center" role="main">
<br />
{!generateWalletFile &&
<div>
<section className="row">
<h1 aria-live="polite">{translate('NAV_GenerateWallet')}</h1>
<div className="col-sm-8 col-sm-offset-2">
<h4>{translate('HELP_1_Desc_3')}</h4>
<Field
validate={[required, minLength9]}
component={GenerateWalletPasswordInputComponent}
showPassword={showPassword}
showPasswordGenerateWallet={showPasswordGenerateWallet}
name="password"
type="text"
/>
<br />
<button
onClick={() => generateFileGenerateWallet()}
disabled={
generateWalletPassword
? generateWalletPassword.syncErrors
: true
}
className="btn btn-primary btn-block"
>
{translate('NAV_GenerateWallet')}
</button>
</div>
</section>
<LedgerTrezorWarning />
</div>}
{generateWalletFile &&
<section role="main" className="row">
<h1>{translate('GEN_Label_2')}</h1>
<br />
<div className="col-sm-8 col-sm-offset-2">
<div aria-hidden="true" className="account-help-icon">
<img
src="https://myetherwallet.com/images/icon-help.svg"
className="help-icon"
/>
<p className="account-help-text">
{translate('x_KeystoreDesc')}
</p>
<h4>{translate('x_Keystore2')}</h4>
</div>
<a
role="button"
className="btn btn-primary btn-block"
href="blob:https://myetherwallet.com/2455ae32-916f-4224-a806-414bbe680168"
download="UTC--2017-04-26T23-07-03.538Z--c5b7fff4e1669e38e8d6bc8fffe7e562b2b70f43"
aria-label="Download Keystore File (UTC / JSON · Recommended · Encrypted)"
aria-describedby="x_KeystoreDesc"
onClick={() => downloadFileGenerateWallet()}
>
{translate('x_Download')}
</a>
<p className="sr-only" id="x_KeystoreDesc">
{translate('x_KeystoreDesc')}
</p>
<br /><br /><br /><br />
</div>
<div className="col-xs-12 alert alert-danger">
<span>
MyEtherWallet.com is not a web wallet &amp; does not store
or transmit this secret information at any time. <br />
<strong>
If you do not save your wallet file and password, we
cannot recover them.
</strong>
<br />
Save your wallet file now &amp; back it up in a second
location (not on your computer).
<br /><br />
<a
role="button"
className={`btn btn-info ${hasDownloadedWalletFile
? ''
: 'disabled'}`}
onClick={() => confirmContinueToPaperGenerateWallet()}
>
{' '}I understand. Continue.{' '}
</a>
</span>
</div>
</section>
)
}
</section>}
</main>
</div>
</section>
);
}
}

export default reduxForm({
form: 'generateWalletPassword' // a unique name for this form
form: 'generateWalletPassword' // a unique name for this form
})(GenerateWalletPasswordComponent);
Loading

0 comments on commit 59b0d44

Please sign in to comment.