Skip to content

Commit

Permalink
Adds revert feature to customize gas modal.
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm authored and chikeichan committed Oct 25, 2017
1 parent 3d8182f commit f89b766
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
23 changes: 15 additions & 8 deletions ui/app/components/customize-gas-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -71,14 +68,21 @@ function CustomizeGasModal (props) {
multiplierBase: 16,
})

this.state = {
return {
gasPrice,
gasLimit,
gasTotal,
error: null,
}
}

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) {
Expand All @@ -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,
Expand Down Expand Up @@ -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', {
Expand Down
8 changes: 1 addition & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,7 @@ async-each@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d"

async-eventemitter@^0.2.2:
version "0.2.3"
resolved "https://registry.yarnpkg.com/async-eventemitter/-/async-eventemitter-0.2.3.tgz#f79f480dfda6645a97bd6142c017150d63b4e70e"
dependencies:
async "^2.4.0"

async-eventemitter@ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c:
async-eventemitter@^0.2.2, async-eventemitter@ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c:
version "0.2.3"
resolved "https://codeload.github.com/ahultgren/async-eventemitter/tar.gz/fa06e39e56786ba541c180061dbf2c0a5bbf951c"
dependencies:
Expand Down

0 comments on commit f89b766

Please sign in to comment.