From 0096ed24e5b7c2b6265c33e56dfb1c94c23b3d9f Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 10 Sep 2019 18:22:45 +0400 Subject: [PATCH] Make name mandatory for create/load safe flows --- src/routes/load/components/DetailsForm/index.jsx | 11 +++++++++-- src/routes/open/components/Layout.jsx | 4 ++-- src/routes/open/components/SafeNameForm/index.jsx | 10 ++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/routes/load/components/DetailsForm/index.jsx b/src/routes/load/components/DetailsForm/index.jsx index 0ce657c1..bfbdb1a3 100644 --- a/src/routes/load/components/DetailsForm/index.jsx +++ b/src/routes/load/components/DetailsForm/index.jsx @@ -50,8 +50,15 @@ export const SAFE_MASTERCOPY_ERROR = 'Mastercopy used by this safe is not the sa export const safeFieldsValidation = async (values: Object) => { const errors = {} const web3 = getWeb3() + const safeName = values[FIELD_LOAD_NAME] const safeAddress = values[FIELD_LOAD_ADDRESS] + + if (!safeName) { + errors[FIELD_LOAD_NAME] = 'Required' + } + if (!safeAddress || mustBeEthereumAddress(safeAddress) !== undefined) { + errors[FIELD_LOAD_ADDRESS] = 'Required' return errors } @@ -92,8 +99,8 @@ const Details = ({ classes, errors, form }: Props) => ( <> - Adding an existing Safe only requires the Safe address. Your connected wallet does not have to be the owner of - this Safe. In this case, the interface will provide you a read-only view. + You are about to load an existing Gnosis Safe. First, choose a name and enter the Safe address. The name is only + stored locally and will never be shared with Gnosis or any third parties diff --git a/src/routes/open/components/Layout.jsx b/src/routes/open/components/Layout.jsx index 75fe9fba..d66b3a70 100644 --- a/src/routes/open/components/Layout.jsx +++ b/src/routes/open/components/Layout.jsx @@ -7,7 +7,7 @@ import Block from '~/components/layout/Block' import Heading from '~/components/layout/Heading' import Row from '~/components/layout/Row' import Review from '~/routes/open/components/ReviewInformation' -import SafeNameField from '~/routes/open/components/SafeNameForm' +import SafeNameField, { safeNameValidation } from '~/routes/open/components/SafeNameForm' import SafeOwnersFields from '~/routes/open/components/SafeOwnersConfirmationsForm' import { getOwnerNameBy, getOwnerAddressBy, FIELD_CONFIRMATIONS } from '~/routes/open/components/fields' import { history } from '~/store' @@ -67,7 +67,7 @@ const Layout = ({ mutators={formMutators} testId="create-safe-form" > - {SafeNameField} + {SafeNameField} {SafeOwnersFields} {Review} diff --git a/src/routes/open/components/SafeNameForm/index.jsx b/src/routes/open/components/SafeNameForm/index.jsx index da603793..d243115f 100644 --- a/src/routes/open/components/SafeNameForm/index.jsx +++ b/src/routes/open/components/SafeNameForm/index.jsx @@ -10,6 +10,16 @@ import Paragraph from '~/components/layout/Paragraph' import OpenPaper from '~/components/Stepper/OpenPaper' import { sm, secondary } from '~/theme/variables' +export const safeNameValidation = async (values: Object) => { + const errors = {} + + if (!values[FIELD_NAME]) { + errors[FIELD_NAME] = 'Required' + } + + return errors +} + type Props = { classes: Object, }