Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

[Address Book v2] - Prevent name validation in AB reducer#2356

Merged
fernandomg merged 7 commits into
address-book-v2from
fix/prevent-name-validation-in-reducer
Jun 1, 2021
Merged

[Address Book v2] - Prevent name validation in AB reducer#2356
fernandomg merged 7 commits into
address-book-v2from
fix/prevent-name-validation-in-reducer

Conversation

@fernandomg

Copy link
Copy Markdown
Contributor

What it solves

Moves the name validation from the reducer to the UI (the error will appear in the form field)
image

How this PR fixes it

By creating a validator validAddressBookName for the name form field

How to test it

verify that the error will appear on any form field for names that will be stored in the address book.

@fernandomg fernandomg self-assigned this May 30, 2021
@github-actions

Copy link
Copy Markdown

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions

github-actions Bot commented May 30, 2021

Copy link
Copy Markdown

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 3 0
Ignored 1 N/A
  • Result: ✅ success

  • Annotations: 3 total


[warning] @typescript-eslint/explicit-module-boundary-types

Require explicit return and argument types on exported functions' and classes' public class methods


Report generated by eslint-plus-action

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Comment thread src/components/forms/validator.ts Outdated
import { isFeatureEnabled } from 'src/config'
import { FEATURES } from 'src/config/networks/network.d'
import { isValidAddress } from 'src/utils/isValidAddress'
import { ADDRESS_BOOK_INVALID_NAMES, isValidAddressBookName } from '../../logic/addressBook/utils'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use full route here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -50,7 +45,6 @@ export default handleActions<AppReduxState['addressBook'], Payloads>(

addressBookEntries
// exclude those entries with invalid name

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was related to the .filter

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

text="Owner Name"
type="text"
validate={composeValidators(required, minMaxLength(1, 50))}
validate={composeValidators(required, minMaxLength(1, 50), validAddressBookName)}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will force to set a name to all owners when loading a Safe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops! thanks, just removed it.

text="Owner Name"
type="text"
validate={composeValidators(required, minMaxLength(1, 50))}
validate={composeValidators(required, minMaxLength(1, 50), validAddressBookName)}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will force to set a name to all owners when creating a Safe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Comment thread src/components/forms/validator.ts Outdated
text="Safe name"
type="text"
validate={composeValidators(required, minMaxLength(1, 50))}
validate={composeValidators(required, minMaxLength(1, 50), validAddressBookName)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make minMaxLength(1, 50) part of validAddressBookName.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@fernandomg fernandomg requested review from dasanra and katspaugh May 31, 2021 13:47

@katspaugh katspaugh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@@ -94,7 +94,7 @@ export const CreateEditEntryModal = ({
testId={CREATE_ENTRY_INPUT_NAME_ID}
text="Name"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find some places where an input is mandatory but we are not setting the *, while this character is tipically used for indicating that. I would like to raise this here because it's missing so either we should add it also here as it's a mandatory field or remove it from every place were we have it, because I don't even remember an input that could accept empty values in the whole app

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katspaugh would also like to read your input here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally not a fan of literally typing * in the label.
Ideally the component should indicate somehow that it's required if the prop required is true.
But yeah, for consistency with the other inputs it might make sense to add it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@fernandomg fernandomg requested a review from dasanra June 1, 2021 11:38
Base automatically changed from fix/avoid-checksum-in-reducer to address-book-v2 June 1, 2021 12:13
@fernandomg fernandomg force-pushed the fix/prevent-name-validation-in-reducer branch from 1fe2697 to d4997f3 Compare June 1, 2021 12:16
@fernandomg fernandomg merged commit 94bee4f into address-book-v2 Jun 1, 2021
@fernandomg fernandomg deleted the fix/prevent-name-validation-in-reducer branch June 1, 2021 12:49
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants