Make name mandatory for create/load safe flows

This commit is contained in:
Mikhail Mikheev 2019-09-10 18:22:45 +04:00
parent e09795c7ef
commit 0096ed24e5
3 changed files with 21 additions and 4 deletions

View File

@ -50,8 +50,15 @@ export const SAFE_MASTERCOPY_ERROR = 'Mastercopy used by this safe is not the sa
export const safeFieldsValidation = async (values: Object) => { export const safeFieldsValidation = async (values: Object) => {
const errors = {} const errors = {}
const web3 = getWeb3() const web3 = getWeb3()
const safeName = values[FIELD_LOAD_NAME]
const safeAddress = values[FIELD_LOAD_ADDRESS] const safeAddress = values[FIELD_LOAD_ADDRESS]
if (!safeName) {
errors[FIELD_LOAD_NAME] = 'Required'
}
if (!safeAddress || mustBeEthereumAddress(safeAddress) !== undefined) { if (!safeAddress || mustBeEthereumAddress(safeAddress) !== undefined) {
errors[FIELD_LOAD_ADDRESS] = 'Required'
return errors return errors
} }
@ -92,8 +99,8 @@ const Details = ({ classes, errors, form }: Props) => (
<> <>
<Block margin="sm"> <Block margin="sm">
<Paragraph noMargin size="lg" color="primary"> <Paragraph noMargin size="lg" color="primary">
Adding an existing Safe only requires the Safe address. Your connected wallet does not have to be the owner of You are about to load an existing Gnosis Safe. First, choose a name and enter the Safe address. The name is only
this Safe. In this case, the interface will provide you a read-only view. stored locally and will never be shared with Gnosis or any third parties
</Paragraph> </Paragraph>
</Block> </Block>
<Block className={classes.root}> <Block className={classes.root}>

View File

@ -7,7 +7,7 @@ import Block from '~/components/layout/Block'
import Heading from '~/components/layout/Heading' import Heading from '~/components/layout/Heading'
import Row from '~/components/layout/Row' import Row from '~/components/layout/Row'
import Review from '~/routes/open/components/ReviewInformation' 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 SafeOwnersFields from '~/routes/open/components/SafeOwnersConfirmationsForm'
import { getOwnerNameBy, getOwnerAddressBy, FIELD_CONFIRMATIONS } from '~/routes/open/components/fields' import { getOwnerNameBy, getOwnerAddressBy, FIELD_CONFIRMATIONS } from '~/routes/open/components/fields'
import { history } from '~/store' import { history } from '~/store'
@ -67,7 +67,7 @@ const Layout = ({
mutators={formMutators} mutators={formMutators}
testId="create-safe-form" testId="create-safe-form"
> >
<StepperPage>{SafeNameField}</StepperPage> <StepperPage validate={safeNameValidation}>{SafeNameField}</StepperPage>
<StepperPage>{SafeOwnersFields}</StepperPage> <StepperPage>{SafeOwnersFields}</StepperPage>
<StepperPage network={network} userAccount={userAccount}> <StepperPage network={network} userAccount={userAccount}>
{Review} {Review}

View File

@ -10,6 +10,16 @@ import Paragraph from '~/components/layout/Paragraph'
import OpenPaper from '~/components/Stepper/OpenPaper' import OpenPaper from '~/components/Stepper/OpenPaper'
import { sm, secondary } from '~/theme/variables' 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 = { type Props = {
classes: Object, classes: Object,
} }