-
Notifications
You must be signed in to change notification settings - Fork 936
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Create user page #1197
Conversation
bug in formErrors story
Doesn't work in test
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 commit cf8442f.
|
||
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 getting authState
using useActor
means that this component will only re-render in response to changes in the org id, not all authXService
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 the cond
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 🎉
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!
Co-authored-by: G r e y <grey@coder.com>
* 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, stories bug 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 xservice Doesn't work in test * Move error type predicate to xservice * Lint * Switch to using creation mode in XState still problems in tests * Lint * Lint * Lint * Revert "Switch to using creation mode in XState" This reverts commit cf8442f. * Give XService a navigate action * Add missing validation messages * Fix XState warning * Fix tests IRL 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 tests Co-authored-by: G r e y <grey@coder.com> * Punctuate notification messages Co-authored-by: G r e y <grey@coder.com>
Blocked by #1184Fixes #734
I'm pretending users come with org ids in preparation for Bruno's PRselector
to get the org id out of theauthXService
without making theCreateUserPage
re-render for every 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.