From f89b76653434ff801779e10b9f8a9a546997cb9b Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 25 Oct 2017 14:10:03 -0230 Subject: Adds revert feature to customize gas modal. --- ui/app/components/customize-gas-modal/index.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'ui/app') diff --git a/ui/app/components/customize-gas-modal/index.js b/ui/app/components/customize-gas-modal/index.js index 598247497..722ed2b23 100644 --- a/ui/app/components/customize-gas-modal/index.js +++ b/ui/app/components/customize-gas-modal/index.js @@ -58,10 +58,7 @@ function mapDispatchToProps (dispatch) { } } -inherits(CustomizeGasModal, Component) -function CustomizeGasModal (props) { - Component.call(this) - +function getOriginalState(props) { const gasPrice = props.gasPrice || MIN_GAS_PRICE_DEC const gasLimit = props.gasLimit || MIN_GAS_LIMIT_DEC @@ -71,7 +68,7 @@ function CustomizeGasModal (props) { multiplierBase: 16, }) - this.state = { + return { gasPrice, gasLimit, gasTotal, @@ -79,6 +76,13 @@ function CustomizeGasModal (props) { } } +inherits(CustomizeGasModal, Component) +function CustomizeGasModal (props) { + Component.call(this) + + this.state = getOriginalState(props) +} + module.exports = connect(mapStateToProps, mapDispatchToProps)(CustomizeGasModal) CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) { @@ -95,6 +99,10 @@ CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) { hideModal() } +CustomizeGasModal.prototype.revert = function () { + this.setState(getOriginalState(this.props)) +} + CustomizeGasModal.prototype.validate = function ({ gasTotal, gasLimit }) { const { amount, @@ -241,9 +249,8 @@ CustomizeGasModal.prototype.render = function () { ]), h('div.send-v2__customize-gas__revert', { - // onClick: () => console.log('Revert'), - }, ['']), - // }, ['Revert']), + onClick: () => this.revert(), + }, ['Revert']), h('div.send-v2__customize-gas__buttons', [ h('div.send-v2__customize-gas__cancel', { -- cgit