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', {}, [
const { t } = this.context
h('div.send-v2__customize-gas__title', this.context.t('customGas')),
return (
h('div.send-v2__customize-gas__close', { <div className="send-v2__customize-gas">
onClick: hideModal, <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')}
</div>
h('div.send-v2__customize-gas__body', {}, [ <div
className="send-v2__customize-gas__close"
h(GasModalCard, { onClick={hideModal}
value: convertedGasPrice, />
min: forceGasMin || MIN_GAS_PRICE_GWEI, </div>
step: 1, <div className="send-v2__customize-gas__body">
onChange: value => this.convertAndSetGasPrice(value), <GasModalCard
title: this.context.t('gasPrice'), value={convertedGasPrice}
copy: this.context.t('gasPriceCalculation'), min={forceGasMin || MIN_GAS_PRICE_GWEI}
gasIsLoading, step={1}
}), onChange={value => this.convertAndSetGasPrice(value)}
title={t('gasPrice')}
h(GasModalCard, { copy={t('gasPriceCalculation')}
value: convertedGasLimit, gasIsLoading={gasIsLoading}
min: 1, />
step: 1, <GasModalCard
onChange: value => this.convertAndSetGasLimit(value), value={convertedGasLimit}
title: this.context.t('gasLimit'), min={1}
copy: this.context.t('gasLimitCalculation'), step={1}
gasIsLoading, onChange={value => this.convertAndSetGasLimit(value)}
}), title={t('gasLimit')}
copy={t('gasLimitCalculation')}
]), gasIsLoading={gasIsLoading}
/>
h('div.send-v2__customize-gas__footer', {}, [ </div>
<div className="send-v2__customize-gas__footer">
error && h('div.send-v2__customize-gas__error-message', [ {error && (
error, <div className="send-v2__customize-gas__error-message">
]), {error}
</div>
h('div.send-v2__customize-gas__revert', { )}
onClick: () => this.revert(), <div className="send-v2__customize-gas__revert" onClick={() => this.revert()}>
}, [this.context.t('revert')]), {t('revert')}
</div>
h('div.send-v2__customize-gas__buttons', [ <div className="send-v2__customize-gas__buttons">
h(Button, { <Button
type: 'default', type="default"
className: 'send-v2__customize-gas__cancel', className="send-v2__customize-gas__cancel"
onClick: this.props.hideModal, onClick={hideModal}
}, [this.context.t('cancel')]), >
h(Button, { {t('cancel')}
type: 'secondary', </Button>
className: 'send-v2__customize-gas__save', <Button
onClick: () => !error && this.save(newGasPrice, gasLimit, gasTotal), type="secondary"
disabled: error, className="send-v2__customize-gas__save"
}, [this.context.t('save')]), onClick={() => !error && this.save(newGasPrice, gasLimit, gasTotal)}
]), disabled={error}
>
]), {t('save')}
</Button>
]), </div>
]) </div>
</div>
</div>
)
} }