1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Convert CustomizeGasModal component to use JSX (#7537)

This commit is contained in:
Whymarrh Whitby 2019-11-24 01:32:14 -03:30 committed by GitHub
parent 439fce8901
commit c3e834d17b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,5 @@
const Component = require('react').Component import React, { Component } from 'react'
const PropTypes = require('prop-types') const PropTypes = require('prop-types')
const h = require('react-hyperscript')
const inherits = require('util').inherits const inherits = require('util').inherits
const connect = require('react-redux').connect const connect = require('react-redux').connect
const BigNumber = require('bignumber.js') const BigNumber = require('bignumber.js')
@ -328,69 +327,72 @@ CustomizeGasModal.prototype.render = function () {
toNumericBase: 'dec', toNumericBase: 'dec',
}) })
return !gasIsLoading && h('div.send-v2__customize-gas', {}, [ if (gasIsLoading) {
h('div.send-v2__customize-gas__content', { return null
}, [ }
h('div.send-v2__customize-gas__header', {}, [
h('div.send-v2__customize-gas__title', this.context.t('customGas')), const { t } = this.context
h('div.send-v2__customize-gas__close', { return (
onClick: hideModal, <div className="send-v2__customize-gas">
}), <div className="send-v2__customize-gas__content">
<div className="send-v2__customize-gas__header">
]), <div className="send-v2__customize-gas__title">
{this.context.t('customGas')}
h('div.send-v2__customize-gas__body', {}, [ </div>
<div
h(GasModalCard, { className="send-v2__customize-gas__close"
value: convertedGasPrice, onClick={hideModal}
min: forceGasMin || MIN_GAS_PRICE_GWEI, />
step: 1, </div>
onChange: value => this.convertAndSetGasPrice(value), <div className="send-v2__customize-gas__body">
title: this.context.t('gasPrice'), <GasModalCard
copy: this.context.t('gasPriceCalculation'), value={convertedGasPrice}
gasIsLoading, min={forceGasMin || MIN_GAS_PRICE_GWEI}
}), step={1}
onChange={value => this.convertAndSetGasPrice(value)}
h(GasModalCard, { title={t('gasPrice')}
value: convertedGasLimit, copy={t('gasPriceCalculation')}
min: 1, gasIsLoading={gasIsLoading}
step: 1, />
onChange: value => this.convertAndSetGasLimit(value), <GasModalCard
title: this.context.t('gasLimit'), value={convertedGasLimit}
copy: this.context.t('gasLimitCalculation'), min={1}
gasIsLoading, step={1}
}), onChange={value => this.convertAndSetGasLimit(value)}
title={t('gasLimit')}
]), copy={t('gasLimitCalculation')}
gasIsLoading={gasIsLoading}
h('div.send-v2__customize-gas__footer', {}, [ />
</div>
error && h('div.send-v2__customize-gas__error-message', [ <div className="send-v2__customize-gas__footer">
error, {error && (
]), <div className="send-v2__customize-gas__error-message">
{error}
h('div.send-v2__customize-gas__revert', { </div>
onClick: () => this.revert(), )}
}, [this.context.t('revert')]), <div className="send-v2__customize-gas__revert" onClick={() => this.revert()}>
{t('revert')}
h('div.send-v2__customize-gas__buttons', [ </div>
h(Button, { <div className="send-v2__customize-gas__buttons">
type: 'default', <Button
className: 'send-v2__customize-gas__cancel', type="default"
onClick: this.props.hideModal, className="send-v2__customize-gas__cancel"
}, [this.context.t('cancel')]), onClick={hideModal}
h(Button, { >
type: 'secondary', {t('cancel')}
className: 'send-v2__customize-gas__save', </Button>
onClick: () => !error && this.save(newGasPrice, gasLimit, gasTotal), <Button
disabled: error, type="secondary"
}, [this.context.t('save')]), className="send-v2__customize-gas__save"
]), onClick={() => !error && this.save(newGasPrice, gasLimit, gasTotal)}
disabled={error}
]), >
{t('save')}
]), </Button>
]) </div>
</div>
</div>
</div>
)
} }