From 5cbb8f52acb520b8b1a387640d6bbd58a3fc16b0 Mon Sep 17 00:00:00 2001 From: apane Date: Fri, 24 Apr 2020 10:58:16 -0300 Subject: [PATCH] Moves composeValidatorsApps to managesApps.js --- src/components/forms/validator.js | 7 ------- src/routes/safe/components/Apps/ManageApps.js | 10 +++++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/forms/validator.js b/src/components/forms/validator.js index 9a923ebd..0a065a4e 100644 --- a/src/components/forms/validator.js +++ b/src/components/forms/validator.js @@ -91,13 +91,6 @@ export const uniqueAddress = (addresses: string[] | List) => 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 diff --git a/src/routes/safe/components/Apps/ManageApps.js b/src/routes/safe/components/Apps/ManageApps.js index 4b0abc9f..beb3102c 100644 --- a/src/routes/safe/components/Apps/ManageApps.js +++ b/src/routes/safe/components/Apps/ManageApps.js @@ -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)