diff --git a/js/src/modals/CreateAccount/CreationType/creationType.js b/js/src/modals/CreateAccount/CreationType/creationType.js index 9c0fb1b4f..aca3a5e4d 100644 --- a/js/src/modals/CreateAccount/CreationType/creationType.js +++ b/js/src/modals/CreateAccount/CreationType/creationType.js @@ -39,21 +39,6 @@ const TYPES = [ ), key: 'fromNew' }, - { - description: ( - - ), - label: ( - - ), - key: 'fromPhrase' - }, { description: ( - - } - label={ - - } - onChange={ this.onEditPhrase } - value={ phrase } - /> - - } - label={ - - } - onChange={ this.onEditName } - value={ name } - /> - - } - label={ - - } - onChange={ this.onEditPasswordHint } - value={ passwordHint } - /> -
-
- + { this.renderWarning() } +
+ - } - label={ - - } - onChange={ this.onEditPassword } - type='password' - value={ password } - /> + ) + : null + } + hint={ + + } + label={ + + } + onChange={ this.onEditPhrase } + value={ phrase } + /> + + } + label={ + + } + onChange={ this.onEditName } + value={ name } + /> + + } + label={ + + } + onChange={ this.onEditPasswordHint } + value={ passwordHint } + /> +
+
+ + } + label={ + + } + onChange={ this.onEditPassword } + type='password' + value={ password } + /> +
+
+ + } + label={ + + } + onChange={ this.onEditPasswordRepeat } + type='password' + value={ passwordRepeat } + /> +
-
- - } - label={ - - } - onChange={ this.onEditPasswordRepeat } - type='password' - value={ passwordRepeat } - /> -
-
- - - - } - onCheck={ this.onToggleWindowsPhrase } - /> - + + + + } + onCheck={ this.onToggleWindowsPhrase } + /> + +
); } + renderWarning () { + const { isTest, phrase } = this.props.store; + + if (!isTest && phrase.length === 0) { + return ( + + } + /> + ); + } + + if (phrase.length === 0) { + return ( + + } + /> + ); + } + + const words = phrase.split(' '); + + if (words.length < 11) { + return ( + + } + /> + ); + } + + return null; + } + onToggleWindowsPhrase = (event) => { const { store } = this.props; diff --git a/js/src/modals/CreateAccount/createAccount.js b/js/src/modals/CreateAccount/createAccount.js index d89c2afa8..9781e2a4c 100644 --- a/js/src/modals/CreateAccount/createAccount.js +++ b/js/src/modals/CreateAccount/createAccount.js @@ -62,37 +62,63 @@ const TITLES = { ), import: ( + ), + restore: ( + ) }; const STAGE_NAMES = [TITLES.type, TITLES.create, TITLES.info]; const STAGE_IMPORT = [TITLES.type, TITLES.import, TITLES.info]; +const STAGE_RESTORE = [TITLES.restore, TITLES.info]; @observer class CreateAccount extends Component { static contextTypes = { api: PropTypes.object.isRequired - } + }; static propTypes = { accounts: PropTypes.object.isRequired, + isTest: PropTypes.bool.isRequired, newError: PropTypes.func.isRequired, onClose: PropTypes.func, - onUpdate: PropTypes.func - } + onUpdate: PropTypes.func, + restore: PropTypes.bool + }; - store = new Store(this.context.api, this.props.accounts); + static defaultProps = { + restore: false + }; + + store = new Store(this.context.api, this.props.accounts, this.props.isTest); vaultStore = VaultStore.get(this.context.api); componentWillMount () { + if (this.props.restore) { + this.store.setCreateType('fromPhrase'); + this.store.nextStage(); + } + return this.vaultStore.loadVaults(); } render () { const { isBusy, createType, stage } = this.store; + let steps = STAGE_IMPORT; + + if (createType === 'fromNew') { + steps = STAGE_NAMES; + } else if (createType === 'fromPhrase') { + steps = STAGE_RESTORE; + } + return ( }> { this.renderPage() } @@ -179,6 +201,7 @@ class CreateAccount extends Component { renderDialogActions () { const { createType, canCreate, isBusy, stage } = this.store; + const { restore } = this.props; const cancelBtn = (