-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Invites: Add invites create validation methods #3037
Conversation
return state.setIn( [ 'errors', action.siteId ], action.error ); | ||
} | ||
return state; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this matches with the API. The validation endpoint doesn't return errors for usernames or emails that don't validate. The endpoint returns an object that looks a bit like:
{
errors: [ WP_Error objects ],
success: [ user1, useremail@test.com ]
}
😄 this is still in progress, I need to iterate on invites-create-validation.js that I copied from invites-accept-validation.js |
Just giving early feedback 😜 |
6a8d1bd
to
da865c4
Compare
#3058 is merged, which might be of interest if we want to go ahead and tie that UI into the validation that you're working on here. |
e6cbe34
to
552a050
Compare
type: constants.action.RECEIVE_CREATE_INVITE_VALIDATION_SUCCESS, | ||
siteId: siteId, | ||
data: { | ||
errors: [ 'asdfasdf' ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this test works, I don't think it matches what we'll want from the API. On an error, we'll probably receive an array of objects, where each object contains the invitee as well as the error message. That currently looks like:
{
"errors": {
"test@gmail.com": {
"errors": {
"form-error-username-or-email": [
"User already has a role on your site."
]
},
"error_data": []
}
},
"success": []
}
We could simplify errors a bit to be something like this perhaps:
errors: [
{
invitee: "test@gmail.com",
error: "form-error-username-or-email",
error_message: "User already has a role on your site."
}
]
I left a couple of comments. I had issues with getting an error to show properly. When I attempted to invite someone that was already a user on my site, I got a green "successful" token instead of a red one. Besides that, this feels pretty close. |
that's probably an API error 😞 |
af646ef
to
df920c7
Compare
I rebased the PR to fix a merge conflict and have updated the PR to fix an issue where validation was not happening because the site ID wasn't being sent to the API. Of note, I also removed the Note: Since I rebased against master, the new styles for @lezama – I think this is ready for another review. If you're fine with my changes, let's 🚢. |
3b9857b
to
bb77af5
Compare
…n-action-store Invites: Add invites create validation methods
Closes #2844
HOW TO TEST
add/invites-create-validation-action-store