Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domains/cctlds: add organization field to fr-form #20043

Merged
merged 9 commits into from
Nov 23, 2017

Conversation

deBhal
Copy link
Contributor

@deBhal deBhal commented Nov 21, 2017

This PR adds an organization field to the ccTLD forms to address a problem with validating the organization field where the organization field on the first form is required only if the registrantType is set to organization on the second form (T553-code).

By adding the organization field to the tld forms, we can give the user the opportunity to fix the problem.

There are several things we want to check:

  1. The new field is hooked up to the state correctly
  • Any value from the initial form is carried over
  • Changing the form updates the state (visible in redux devtools at State > domains > management > items > _contactDetailsCache )
  • The changed value is sent to the back end ( visible in the payload of the api call to https://public-api.wordpress.com/rest/v1.1/me/transactions )
  1. Validation
  • The user should not be able to submit the form with an empty field
  • Validation errors should show if the organization field is empty while the registrantType is set to organization
  • Non-alphanumeric characters are not permitted in the Organization field
  • Match other validation that happens on the back end (length <= 100)
  1. Tests should run and pass
  2. Punted: .ca

fr-organization-validation-2

Discussion:
Both the length and characters could be enforced by a sanitizing function, but I pulled the character sanitizing out and replaced it with the validation message because it's easier to understand. I'm particularly worried about this in the context of international input. A user that's trying to type Asian characters will get an empty field with no explanation.

I've punted .ca because there are quite involved rules around it implemented on the back end, so I think I'm going to have to take a different approach so I thought I'd push that out into a different PR.

@matticbot
Copy link
Contributor

@@ -190,6 +198,24 @@ class RegistrantExtraInfoFrForm extends React.PureComponent {

return (
<div>
<FormFieldset>
<FormLabel className="registrant-extra-info__optional" htmlFor="organization">
{ translate( 'Organization Name' ) }
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 15 times:
translate( 'Add Organization Name' ) ES Score: 15
See 2 additional suggestions in the PR translation status page

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👎 The "Add" makes a pretty big difference to the meaning in this case

@designsimply designsimply added [Feature Group] Emails & Domains Features related to email integrations and domain management. [Status] In Progress labels Nov 21, 2017
return (
<div>
<FormFieldset>
<FormLabel className="registrant-extra-info" htmlFor="organization">
{ translate( 'Organization Name' ) }
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 15 times:
translate( 'Add Organization Name' ) ES Score: 15
See 2 additional suggestions in the PR translation status page

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

Copy link
Contributor

Choose a reason for hiding this comment

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

👎

@deBhal deBhal changed the title [WIP] Domains/cctlds: add organization to fr forms Domains/cctlds: add organization field to fr-form Nov 22, 2017
@deBhal deBhal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Nov 22, 2017
@deBhal deBhal requested a review from mhsdef November 22, 2017 05:44
@deBhal deBhal self-assigned this Nov 22, 2017
return (
<div>
<FormFieldset>
<FormLabel className="registrant-extra-info__organization" htmlFor="organization">
{ translate( 'Organization Name' ) }
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 15 times:
translate( 'Add Organization Name' ) ES Score: 15
See 2 additional suggestions in the PR translation status page

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

@mhsdef
Copy link
Contributor

mhsdef commented Nov 22, 2017

Tested, works beautifully. I did get a warning (see 1c536-pb) which I think we should fix if we can.

@mhsdef mhsdef added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 22, 2017
Copy link
Contributor

@mhsdef mhsdef left a comment

Choose a reason for hiding this comment

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

Looks good! I had a question on naming, the hack, and whether we can quash that warning reasonably or not [eg, some larger module issue?]. Almost RTG.

@@ -9,70 +10,98 @@
"maxLength": 0
}
]
},
"organizationRequiredForIndividualTypeOrganization": {
Copy link
Contributor

Choose a reason for hiding this comment

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

"IndividualTypeOrganization", not quite sure I understand the naming intention there. Shouldn't it be something like organizationRequiredForRegistrantTypeOrganization?

// path.
// We've only got one such case at the moment, so we can insert this
// hack, but if we need to tell multiple such rules apart, we're
// going to need to add a some magic to map schemas to fields
Copy link
Contributor

Choose a reason for hiding this comment

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

How hard would said map be? I don't understand this part of the code well but hack sense is tingling and if the investment is straightward and cheap enough (say, half a day?) my vote would be worthwhile.

If it'd be a big deal, then, ignore this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mini essay in comments, short version: let's not in this PR.

@deBhal
Copy link
Contributor Author

deBhal commented Nov 22, 2017

I had a question on naming

Good catch! I think the self-documentation is worth a few extra characters, so decided to go big with organizationIsRequiredWhenRegistrantTypeIsOrganization.

whether we can quash that warning reasonably or not [eg, some larger module issue?].

I've got a fix for that warning, but it's not related to this PR so I'll open a fresh one: #20139

the hack
Yeah, "hack sense is tingling" is spot on.

The map itself would easy, but it would just be another hack. Json schema can totally do this, so we'd be starting down the slippery slope of writing our own schema validator, and closing ourselves off from the spec.

The root of the problem is that we don't get good information about the failing rule. If we could grab the rule that failed, we can add any meta data that we want.

For example, in this case we want to be able to specify that this rule describes a problem with the organization field, so we could use a convention where a field attribute overrides the path if it's present and add field: 'organization' to the rule in the schema to say "when this rule fails, it indicates a problem with the organization field. We could also add an errorCode, or even errorMessage directly, and maybe also the variable extraction that @klimeryk was musing about to feed variables into error messages (e.g. naming the specific banned word in the error message). In short: whatever we need.

is-my-json-valid is excellent in terms of getting pass/fail right, it's just a bit terse. There are several issues related to it that have been open for several years (mafintosh/is-my-json-valid#38, mafintosh/is-my-json-valid#39, mafintosh/is-my-json-valid#22).

Trying to fix that looks pretty fun but not very easy, so at the moment I'm leaning towards trying a different lib (ajv in particular looks very promising), and that requires discussion and investigation that I'd prefer to do after landing this bugfix.

@deBhal deBhal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Author Reply labels Nov 23, 2017
@mhsdef
Copy link
Contributor

mhsdef commented Nov 23, 2017

LGTM. Test an org .fr purchase all the way through (if you haven't already) and ship it!

@deBhal deBhal force-pushed the update/cctlds/add-organization-to-tld-forms branch from d2b3cfb to ce7fe11 Compare November 23, 2017 21:43
@deBhal deBhal merged commit 8d708e4 into master Nov 23, 2017
@deBhal deBhal deleted the update/cctlds/add-organization-to-tld-forms branch November 23, 2017 23:46
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature Group] Emails & Domains Features related to email integrations and domain management.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants