aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/first-time
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-04-14 06:28:44 +0800
committerDan Finlay <dan@danfinlay.com>2016-04-14 06:28:44 +0800
commitd814a45dffa6a872f6e336cad33ca41ffb102887 (patch)
treed8cdd0c4b8c6559efaf6846b24f0d6440f3c94f5 /ui/app/first-time
parent9f1438b85b3dac8f1dd98f7bd6e101035cfce0a5 (diff)
downloadtangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.tar.gz
tangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.tar.zst
tangerine-wallet-browser-d814a45dffa6a872f6e336cad33ca41ffb102887.zip
Moved UI into repo with its own dependency stack
Diffstat (limited to 'ui/app/first-time')
-rw-r--r--ui/app/first-time/create-vault-complete.js57
-rw-r--r--ui/app/first-time/create-vault.js123
-rw-r--r--ui/app/first-time/init-menu.js123
-rw-r--r--ui/app/first-time/restore-vault.js116
4 files changed, 419 insertions, 0 deletions
diff --git a/ui/app/first-time/create-vault-complete.js b/ui/app/first-time/create-vault-complete.js
new file mode 100644
index 000000000..cd062effe
--- /dev/null
+++ b/ui/app/first-time/create-vault-complete.js
@@ -0,0 +1,57 @@
+const inherits = require('util').inherits
+const Component = require('react').Component
+const connect = require('react-redux').connect
+const h = require('react-hyperscript')
+const actions = require('../actions')
+
+module.exports = connect(mapStateToProps)(CreateVaultCompleteScreen)
+
+
+inherits(CreateVaultCompleteScreen, Component)
+function CreateVaultCompleteScreen() {
+ Component.call(this)
+}
+
+function mapStateToProps(state) {
+ return {
+ seed: state.appState.currentView.context,
+ cachedSeed: state.metamask.seedWords,
+ }
+}
+
+CreateVaultCompleteScreen.prototype.render = function() {
+ var state = this.props
+ var seed = state.seed || state.cachedSeed
+
+ return (
+
+ h('.initialize-screen.flex-column.flex-center.flex-grow', [
+
+ // subtitle and nav
+ h('.section-title.flex-row.flex-center', [
+ h('h2.page-subtitle', 'Vault Created'),
+ ]),
+
+ h('span.error', { // Error for the right red
+ style: {
+ padding: '12px 20px 0px 20px',
+ textAlign: 'center',
+ }
+ }, 'These 12 words can restore all of your MetaMask accounts for this vault.\nSave them somewhere safe and secret.'),
+
+ h('textarea.twelve-word-phrase', {
+ readOnly: true,
+ value: seed,
+ }),
+
+ h('button.btn-thin', {
+ onClick: () => this.confirmSeedWords(),
+ }, 'I\'ve copied it somewhere safe.'),
+ ])
+ )
+}
+
+CreateVaultCompleteScreen.prototype.confirmSeedWords = function() {
+ this.props.dispatch(actions.confirmSeedWords())
+}
+
diff --git a/ui/app/first-time/create-vault.js b/ui/app/first-time/create-vault.js
new file mode 100644
index 000000000..d7bf9cd5d
--- /dev/null
+++ b/ui/app/first-time/create-vault.js
@@ -0,0 +1,123 @@
+const inherits = require('util').inherits
+
+const Component = require('react').Component
+const connect = require('react-redux').connect
+const h = require('react-hyperscript')
+const actions = require('../actions')
+
+module.exports = connect(mapStateToProps)(CreateVaultScreen)
+
+
+inherits(CreateVaultScreen, Component)
+function CreateVaultScreen() {
+ Component.call(this)
+}
+
+function mapStateToProps(state) {
+ return {
+ warning: state.appState.warning,
+ }
+}
+
+CreateVaultScreen.prototype.render = function() {
+ var state = this.props
+ return (
+
+ h('.initialize-screen.flex-column.flex-center.flex-grow', [
+
+ // subtitle and nav
+ h('.section-title.flex-row.flex-center', [
+ h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
+ onClick: this.showInitializeMenu.bind(this),
+ }),
+ h('h2.page-subtitle', 'Create Vault'),
+ ]),
+
+ // password
+ h('label', {
+ htmlFor: 'password-box',
+ }, 'Enter Password (min 8 chars):'),
+
+ h('input', {
+ type: 'password',
+ id: 'password-box',
+ }),
+
+ // confirm password
+ h('label', {
+ htmlFor: 'password-box-confirm',
+ }, 'Confirm Password:'),
+
+ h('input', {
+ type: 'password',
+ id: 'password-box-confirm',
+ onKeyPress: this.createVaultOnEnter.bind(this),
+ }),
+
+ /* ENTROPY TEXT INPUT CURRENTLY DISABLED
+ // entropy
+ h('label', {
+ htmlFor: 'entropy-text-entry',
+ }, 'Enter random text (optional)'),
+
+ h('textarea', {
+ id: 'entropy-text-entry',
+ style: { resize: 'none' },
+ onKeyPress: this.createVaultOnEnter.bind(this),
+ }),
+ */
+
+ // submit
+ h('button.create-vault.btn-thin', {
+ onClick: this.createNewVault.bind(this),
+ }, 'OK'),
+
+ (!state.inProgress && state.warning) && (
+ h('span.in-progress-notification', state.warning)
+
+ ),
+
+ state.inProgress && (
+ h('span.in-progress-notification', 'Generating Seed...')
+ ),
+ ])
+ )
+}
+
+CreateVaultScreen.prototype.componentDidMount = function(){
+ document.getElementById('password-box').focus()
+}
+
+CreateVaultScreen.prototype.showInitializeMenu = function() {
+ this.props.dispatch(actions.showInitializeMenu())
+}
+
+// create vault
+
+CreateVaultScreen.prototype.createVaultOnEnter = function(event) {
+ if (event.key === 'Enter') {
+ event.preventDefault()
+ this.createNewVault()
+ }
+}
+
+CreateVaultScreen.prototype.createNewVault = function(){
+ var passwordBox = document.getElementById('password-box')
+ var password = passwordBox.value
+ var passwordConfirmBox = document.getElementById('password-box-confirm')
+ var passwordConfirm = passwordConfirmBox.value
+ // var entropy = document.getElementById('entropy-text-entry').value
+
+ if (password.length < 8) {
+ this.warning = 'password not long enough'
+ this.props.dispatch(actions.displayWarning(this.warning))
+ return
+ }
+ if (password !== passwordConfirm) {
+ this.warning = 'passwords dont match'
+ this.props.dispatch(actions.displayWarning(this.warning))
+ return
+ }
+
+ this.props.dispatch(actions.createNewVault(password, ''/*entropy*/))
+}
diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js
new file mode 100644
index 000000000..11b01a88b
--- /dev/null
+++ b/ui/app/first-time/init-menu.js
@@ -0,0 +1,123 @@
+const inherits = require('util').inherits
+const EventEmitter = require('events').EventEmitter
+const Component = require('react').Component
+const connect = require('react-redux').connect
+const h = require('react-hyperscript')
+const getCaretCoordinates = require('textarea-caret')
+const Mascot = require('../components/mascot')
+const actions = require('../actions')
+const CreateVaultScreen = require('./create-vault')
+const CreateVaultCompleteScreen = require('./create-vault-complete')
+
+module.exports = connect(mapStateToProps)(InitializeMenuScreen)
+
+inherits(InitializeMenuScreen, Component)
+function InitializeMenuScreen() {
+ Component.call(this)
+ this.animationEventEmitter = new EventEmitter()
+}
+
+function mapStateToProps(state) {
+ return {
+ // state from plugin
+ currentView: state.appState.currentView,
+ }
+}
+
+InitializeMenuScreen.prototype.render = function() {
+ var state = this.props
+
+ switch (state.currentView.name) {
+
+ case 'createVault':
+ return h(CreateVaultScreen)
+
+ case 'createVaultComplete':
+ return h(CreateVaultCompleteScreen)
+
+ case 'restoreVault':
+ return this.renderRestoreVault()
+
+ default:
+ return this.renderMenu()
+
+ }
+
+}
+
+// InitializeMenuScreen.prototype.componentDidMount = function(){
+// document.getElementById('password-box').focus()
+// }
+
+InitializeMenuScreen.prototype.renderMenu = function() {
+ var state = this.props
+ return (
+
+ h('.initialize-screen.flex-column.flex-center.flex-grow', [
+
+ h('h2.page-subtitle', 'Welcome!'),
+
+ h(Mascot, {
+ animationEventEmitter: this.animationEventEmitter,
+ }),
+
+ h('button.btn-thin', {
+ onClick: this.showCreateVault.bind(this),
+ }, 'Create New Vault'),
+
+ h('.flex-row.flex-center.flex-grow', [
+ h('hr'),
+ h('div', 'OR'),
+ h('hr'),
+ ]),
+
+ h('button.btn-thin', {
+ onClick: this.showRestoreVault.bind(this),
+ }, 'Restore Existing Vault'),
+
+ ])
+
+ )
+}
+
+InitializeMenuScreen.prototype.renderRestoreVault = function() {
+ var state = this.props
+ return (
+
+ h('.initialize-screen.flex-column.flex-center.flex-grow', [
+
+ // subtitle and nav
+ h('.section-title.flex-row.flex-center', [
+ h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
+ onClick: this.showInitializeMenu.bind(this),
+ }),
+ h('h2.page-subtitle', 'Restore Vault'),
+ ]),
+
+
+ h('h3', 'Coming soon....'),
+ // h('textarea.twelve-word-phrase', {
+ // value: 'hey ho what the actual hello rubber duck bumbersnatch crumplezone frankenfurter',
+ // }),
+
+ ])
+
+ )
+}
+
+// InitializeMenuScreen.prototype.splitWor = function() {
+// this.props.dispatch(actions.showInitializeMenu())
+// }
+
+InitializeMenuScreen.prototype.showInitializeMenu = function() {
+ this.props.dispatch(actions.showInitializeMenu())
+}
+
+InitializeMenuScreen.prototype.showCreateVault = function() {
+ this.props.dispatch(actions.showCreateVault())
+}
+
+InitializeMenuScreen.prototype.showRestoreVault = function() {
+ this.props.dispatch(actions.showRestoreVault())
+}
+
diff --git a/ui/app/first-time/restore-vault.js b/ui/app/first-time/restore-vault.js
new file mode 100644
index 000000000..55041e8c0
--- /dev/null
+++ b/ui/app/first-time/restore-vault.js
@@ -0,0 +1,116 @@
+const inherits = require('util').inherits
+const Component = require('react').Component
+const connect = require('react-redux').connect
+const h = require('react-hyperscript')
+const actions = require('../actions')
+
+module.exports = connect(mapStateToProps)(RestoreVaultScreen)
+
+
+inherits(RestoreVaultScreen, Component)
+function RestoreVaultScreen() {
+ Component.call(this)
+}
+
+function mapStateToProps(state) {
+ return {
+ warning: state.appState.warning,
+ }
+}
+
+
+RestoreVaultScreen.prototype.render = function() {
+ var state = this.props
+ return (
+
+ h('.initialize-screen.flex-column.flex-center.flex-grow', [
+
+ // subtitle and nav
+ h('.section-title.flex-row.flex-center', [
+ h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
+ onClick: this.showInitializeMenu.bind(this),
+ }),
+ h('h2.page-subtitle', 'Restore Vault'),
+ ]),
+
+ // wallet seed entry
+ h('h3', 'Wallet Seed'),
+ h('textarea.twelve-word-phrase', {
+ placeholder: 'Enter your secret twelve word phrase here to restore your vault.'
+ }),
+
+ // password
+ h('label', {
+ htmlFor: 'password-box',
+ }, 'New Password (min 8 chars):'),
+
+ h('input', {
+ type: 'password',
+ id: 'password-box',
+ }),
+
+ // confirm password
+ h('label', {
+ htmlFor: 'password-box-confirm',
+ }, 'Confirm Password:'),
+
+ h('input', {
+ type: 'password',
+ id: 'password-box-confirm',
+ onKeyPress: this.onMaybeCreate.bind(this),
+ }),
+
+ (state.warning) && (
+ h('span.error.in-progress-notification', state.warning)
+ ),
+
+ // submit
+ h('button.btn-thin', {
+ onClick: this.restoreVault.bind(this),
+ }, 'I\'ve double checked the 12 word phrase.'),
+
+ ])
+
+ )
+}
+
+RestoreVaultScreen.prototype.showInitializeMenu = function() {
+ this.props.dispatch(actions.showInitializeMenu())
+}
+
+RestoreVaultScreen.prototype.onMaybeCreate = function(event) {
+ if (event.key === 'Enter') {
+ this.restoreVault()
+ }
+}
+
+RestoreVaultScreen.prototype.restoreVault = function(){
+ // check password
+ var passwordBox = document.getElementById('password-box')
+ var password = passwordBox.value
+ var passwordConfirmBox = document.getElementById('password-box-confirm')
+ var passwordConfirm = passwordConfirmBox.value
+ if (password.length < 8) {
+ this.warning = 'Password not long enough'
+
+ this.props.dispatch(actions.displayWarning(this.warning))
+ return
+ }
+ if (password !== passwordConfirm) {
+ this.warning = 'Passwords don\'t match'
+ this.props.dispatch(actions.displayWarning(this.warning))
+ return
+ }
+ // check seed
+ var seedBox = document.querySelector('textarea.twelve-word-phrase')
+ var seed = seedBox.value.trim()
+ if (seed.split(' ').length !== 12) {
+ this.warning = 'seed phrases are 12 words long'
+ this.props.dispatch(actions.displayWarning(this.warning))
+ return
+ }
+ // submit
+ this.warning = null
+ this.props.dispatch(actions.displayWarning(this.warning))
+ this.props.dispatch(actions.recoverFromSeed(password, seed))
+}