- Notifications
You must be signed in to change notification settings - Fork928
feat: Create user page#1197
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
bug in formErrors story
Doesn't work in test
codecovbot commentedApr 27, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## main #1197 +/- ##==========================================+ Coverage 66.00% 66.30% +0.29%========================================== Files 265 268 +3 Lines 16751 16817 +66 Branches 157 162 +5 ==========================================+ Hits 11057 11151 +94+ Misses 4533 4508 -25+ Partials 1161 1158 -3
Continue to review full report at Codecov.
|
This reverts commitcf8442f.
export const CreateUserPage: React.FC = () => { | ||
const xServices = useContext(XServiceContext) | ||
const myOrgId = useSelector(xServices.authXService, selectOrgId) |
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.
Doing this instead of gettingauthState
usinguseActor
means that this component will only re-render in response to changes in the org id, not allauthXService
changes. I haven't bothered with this approach in other places yet because so far it's been components that have a lot to do with the XService they're accessing and there probably won't be many irrelevant updates, but we should do this for cases where we only care about a little piece of some global state.
email: "", | ||
password: "", | ||
username: "", | ||
organization_id: myOrgId, |
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 just hard-coded the org id in here; in EE we'll need a drop-down field for it.
target: "idle", | ||
actions: ["assignCreateUserError"], | ||
}, | ||
], |
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.
This works like a switch statement - if thecond
is true on the first case, do that, otherwise try the next case.
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.
Nicely done 🎉
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
onError: [ | ||
{ | ||
target: "idle", | ||
cond: "isFormError", | ||
actions: ["assignCreateUserFormErrors"], | ||
}, | ||
{ | ||
target: "idle", | ||
actions: ["assignCreateUserError"], | ||
}, | ||
], |
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.
praise: Very nice!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: G r e y <grey@coder.com>
Uh oh!
There was an error while loading.Please reload this page.
* Add button and route* Hook up api* Lint* Add basic form* Get users on page mount* Make cancel work* Creating -> idle bc users page refetches* Import as TypesGen* Handle api errors* Lint* Add handler* Add FormFooter* Add FullPageForm* Lint* Better form, error, storiesbug in formErrors story* Make detail optional* Use Language* Remove detail prop* Add back autoFocus* Remove displayError, use displaySuccess* Lint, export Language* Tests - wip* Fix cancel tests* Switch back to mock* Add navigate to xserviceDoesn't work in test* Move error type predicate to xservice* Lint* Switch to using creation mode in XStatestill problems in tests* Lint* Lint* Lint* Revert "Switch to using creation mode in XState"This reverts commitcf8442f.* Give XService a navigate action* Add missing validation messages* Fix XState warning* Fix testsIRL is broken bc I need to send org id* Pretend user has org id and make it work* Format* Lint* Switch to org ids array* Skip lines between testsCo-authored-by: G r e y <grey@coder.com>* Punctuate notification messagesCo-authored-by: G r e y <grey@coder.com>
Uh oh!
There was an error while loading.Please reload this page.
Blocked by#1184Fixes#734
I'm pretending users come with org ids in preparation forBruno's PRselector
to get the org id out of theauthXService
without making theCreateUserPage
re-render forevery change toauthXService
CreateUserForm
stories have a flash of a validation error message. That appears to be a Storybook problem where it thinks the field istouched
momentarily, maybe a lag from looking at a related story.navigate
in an action like@BrunoQuaresma suggested. I prefer this over embedding it incontext
because in the latter solution, the XService has to know our routes.