From 3086c0db7102f7f50f93b790cd180d7b9774eb8d Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Sat, 23 Nov 2019 12:52:52 -0330 Subject: [PATCH] Convert AccountList component to use JSX (#7524) --- .../connect-hardware/account-list.js | 223 +++++++++--------- 1 file changed, 113 insertions(+), 110 deletions(-) diff --git a/ui/app/pages/create-account/connect-hardware/account-list.js b/ui/app/pages/create-account/connect-hardware/account-list.js index 71684783f..af9f58210 100644 --- a/ui/app/pages/create-account/connect-hardware/account-list.js +++ b/ui/app/pages/create-account/connect-hardware/account-list.js @@ -1,8 +1,7 @@ -const { Component } = require('react') -const PropTypes = require('prop-types') -const h = require('react-hyperscript') +import PropTypes from 'prop-types' +import React, { Component } from 'react' +import Select from 'react-select' const genAccountLink = require('../../../../lib/account-link.js') -const Select = require('react-select').default import Button from '../../../components/ui/button' class AccountList extends Component { @@ -36,22 +35,28 @@ class AccountList extends Component { const { onPathChange, selectedPath } = this.props const options = this.getHdPaths() - return h('div', [ - h('h3.hw-connect__hdPath__title', {}, this.context.t('selectHdPath')), - h('p.hw-connect__msg', {}, this.context.t('selectPathHelp')), - h('div.hw-connect__hdPath', [ - h(Select, { - className: 'hw-connect__hdPath__select', - name: 'hd-path-select', - clearable: false, - value: selectedPath, - options, - onChange: (opt) => { - onPathChange(opt.value) - }, - }), - ]), - ]) + return ( +
+

+ {this.context.t('selectHdPath')} +

+

+ {this.context.t('selectPathHelp')} +

+
+ this.props.onAccountChange(e.target.value)} + checked={this.props.selectedAccount === account.index.toString()} + /> + +
+ + + +
+ ))} + + ) } renderPagination () { - return h('div.hw-list-pagination', [ - h( - 'button.hw-list-pagination__button', - { - onClick: this.goToPreviousPage, - }, - `< ${this.context.t('prev')}` - ), - - h( - 'button.hw-list-pagination__button', - { - onClick: this.goToNextPage, - }, - `${this.context.t('next')} >` - ), - ]) + return ( +
+ + +
+ ) } renderButtons () { @@ -139,40 +133,49 @@ class AccountList extends Component { buttonProps.disabled = true } - return h('div.new-account-connect-form__buttons', {}, [ - h(Button, { - type: 'default', - large: true, - className: 'new-account-connect-form__button', - onClick: this.props.onCancel.bind(this), - }, [this.context.t('cancel')]), - - h(Button, { - type: 'primary', - large: true, - className: 'new-account-connect-form__button unlock', - disabled, - onClick: this.props.onUnlockAccount.bind(this, this.props.device), - }, [this.context.t('unlock')]), - ]) + return ( +
+ + +
+ ) } renderForgetDevice () { - return h('div.hw-forget-device-container', {}, [ - h('a', { - onClick: this.props.onForgetDevice.bind(this, this.props.device), - }, this.context.t('forgetDevice')), - ]) + return ( +
+ + {this.context.t('forgetDevice')} + +
+ ) } render () { - return h('div.new-account-connect-form.account-list', {}, [ - this.renderHeader(), - this.renderAccounts(), - this.renderPagination(), - this.renderButtons(), - this.renderForgetDevice(), - ]) + return ( +
+ {this.renderHeader()} + {this.renderAccounts()} + {this.renderPagination()} + {this.renderButtons()} + {this.renderForgetDevice()} +
+ ) } }