Browse Source

feat(wallets): ability to reset autopilot settings

next
Tom Kirkpatrick 6 years ago
parent
commit
854883a8aa
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 29
      app/components/Home/WalletSettingsFormLocal.js

29
app/components/Home/WalletSettingsFormLocal.js

@ -1,7 +1,7 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Flex } from 'rebass' import { Flex } from 'rebass'
import { Bar, DataRow, Form, Input, Label, Range, Text, Toggle } from 'components/UI' import { Bar, Button, DataRow, Form, Input, Label, Range, Text, Toggle } from 'components/UI'
import * as yup from 'yup' import * as yup from 'yup'
class WalletSettingsFormLocal extends React.Component { class WalletSettingsFormLocal extends React.Component {
@ -10,6 +10,18 @@ class WalletSettingsFormLocal extends React.Component {
startLnd: PropTypes.func.isRequired startLnd: PropTypes.func.isRequired
} }
resetAutopilotSettings = () => {
const defaults = {
autopilotMaxchannels: 5,
autopilotMinchansize: 20000,
autopilotMaxchansize: 16777215,
autopilotAllocation: 60
}
Object.entries(defaults).forEach(([field, value]) => {
this.formApi.setValue(field, value)
})
}
validateAutopilot = value => { validateAutopilot = value => {
try { try {
yup.boolean().validateSync(value) yup.boolean().validateSync(value)
@ -154,6 +166,7 @@ class WalletSettingsFormLocal extends React.Component {
id="autopilotMaxchannels" id="autopilotMaxchannels"
type="number" type="number"
initialValue={wallet.autopilotMaxchannels} initialValue={wallet.autopilotMaxchannels}
min="1"
step="1" step="1"
width={150} width={150}
ml="auto" ml="auto"
@ -171,8 +184,8 @@ class WalletSettingsFormLocal extends React.Component {
field="autopilotMinchansize" field="autopilotMinchansize"
id="autopilotMinchansize" id="autopilotMinchansize"
type="number" type="number"
min="0" min="20000"
max="100000000" max="16777215"
step="1" step="1"
initialValue={wallet.autopilotMinchansize} initialValue={wallet.autopilotMinchansize}
width={150} width={150}
@ -191,8 +204,8 @@ class WalletSettingsFormLocal extends React.Component {
field="autopilotMaxchansize" field="autopilotMaxchansize"
id="autopilotMaxchansize" id="autopilotMaxchansize"
type="number" type="number"
min="0" min="20000"
max="100000000" max="16777215"
step="1" step="1"
initialValue={wallet.autopilotMaxchansize} initialValue={wallet.autopilotMaxchansize}
width={150} width={150}
@ -202,6 +215,12 @@ class WalletSettingsFormLocal extends React.Component {
/> />
} }
/> />
<Flex justifyContent="center" my={4}>
<Button type="button" size="small" onClick={this.resetAutopilotSettings}>
Set Autopilot settings to default
</Button>
</Flex>
</React.Fragment> </React.Fragment>
) : null} ) : null}
</React.Fragment> </React.Fragment>

Loading…
Cancel
Save