From 854883a8aaac0b9f591694b66600ae510b8bbabd Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Mon, 26 Nov 2018 13:31:59 +0100 Subject: [PATCH] feat(wallets): ability to reset autopilot settings --- .../Home/WalletSettingsFormLocal.js | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/app/components/Home/WalletSettingsFormLocal.js b/app/components/Home/WalletSettingsFormLocal.js index 8623a522..4579b0f7 100644 --- a/app/components/Home/WalletSettingsFormLocal.js +++ b/app/components/Home/WalletSettingsFormLocal.js @@ -1,7 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' 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' class WalletSettingsFormLocal extends React.Component { @@ -10,6 +10,18 @@ class WalletSettingsFormLocal extends React.Component { 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 => { try { yup.boolean().validateSync(value) @@ -154,6 +166,7 @@ class WalletSettingsFormLocal extends React.Component { id="autopilotMaxchannels" type="number" initialValue={wallet.autopilotMaxchannels} + min="1" step="1" width={150} ml="auto" @@ -171,8 +184,8 @@ class WalletSettingsFormLocal extends React.Component { field="autopilotMinchansize" id="autopilotMinchansize" type="number" - min="0" - max="100000000" + min="20000" + max="16777215" step="1" initialValue={wallet.autopilotMinchansize} width={150} @@ -191,8 +204,8 @@ class WalletSettingsFormLocal extends React.Component { field="autopilotMaxchansize" id="autopilotMaxchansize" type="number" - min="0" - max="100000000" + min="20000" + max="16777215" step="1" initialValue={wallet.autopilotMaxchansize} width={150} @@ -202,6 +215,12 @@ class WalletSettingsFormLocal extends React.Component { /> } /> + + + + ) : null}