Moves composeValidatorsApps to managesApps.js

This commit is contained in:
apane 2020-04-24 10:58:16 -03:00 committed by Mikhail Mikheev
parent 74d9ce7265
commit 5cbb8f52ac
2 changed files with 9 additions and 8 deletions

View File

@ -91,13 +91,6 @@ export const uniqueAddress = (addresses: string[] | List<string>) =>
export const composeValidators = (...validators: Function[]): FieldValidator => (value: Field) =>
validators.reduce((error, validator) => error || validator(value), undefined)
export const composeValidatorsApps = (...validators: Function[]): FieldValidator => (value: Field, values, meta) => {
if (!meta.modified) {
return
}
return composeValidators(validators)
}
export const inLimit = (limit: number, base: number, baseText: string, symbol: string = 'ETH') => (value: string) => {
const amount = Number(value)
const max = limit - base

View File

@ -1,5 +1,6 @@
// @flow
import { ButtonLink, Checkbox, ManageListModal, Text, TextField } from '@gnosis.pm/safe-react-components'
import type { FieldValidator } from 'final-form'
import React, { useState } from 'react'
import { FormSpy } from 'react-final-form'
import styled from 'styled-components'
@ -9,7 +10,7 @@ import { getAppInfoFromUrl } from './utils'
import Field from '~/components/forms/Field'
import DebounceValidationField from '~/components/forms/Field/DebounceValidationField'
import GnoForm from '~/components/forms/GnoForm'
import { composeValidatorsApps, required } from '~/components/forms/validator'
import { composeValidators, required } from '~/components/forms/validator'
import Img from '~/components/layout/Img'
import appsIconSvg from '~/routes/safe/components/Transactions/TxsTable/TxType/assets/appsIcon.svg'
@ -55,6 +56,13 @@ const urlValidator = (value: string) => {
: 'Please, provide a valid url'
}
const composeValidatorsApps = (...validators: Function[]): FieldValidator => (value: Field, values, meta) => {
if (!meta.modified) {
return
}
return composeValidators(validators)
}
const ManageApps = ({ appList, onAppAdded, onAppToggle }: Props) => {
const [isOpen, setIsOpen] = useState(false)