Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
presleyp merged 49 commits intomainfromcreate-user/presleyp/734
Apr 28, 2022
Merged

feat: Create user page#1197

presleyp merged 49 commits intomainfromcreate-user/presleyp/734
Apr 28, 2022

Conversation

presleyp
Copy link
Contributor

@presleyppresleyp commentedApr 27, 2022
edited
Loading

Blocked by#1184
Fixes#734

  • Adds New User button to the Users page
  • Adds Create User page
  • XState determines if it's a field error or a generic error
  • I'm pretending users come with org ids in preparation forBruno's PR
  • I use aselector to get the org id out of theauthXService without making theCreateUserPage re-render forevery change toauthXService
  • Note that theCreateUserForm 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.
  • Note that in order to see the field error message under test in the FormErrors story, you have to touch the email field.
  • I gave up on testing for redirect after success because it was taking too long. We should e2e test redirects after the deadline.
  • I got rid of creation mode in the XService because it expanded the surface area for bugs by requiring routing and the XService to stay in sync. So I'm embeddingnavigate 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.
  • I had to resort to a jest mock for the generic error because other ways of mocking a non-response error either caused a crash or caused MSW to fall back to its happy path handler.

bug in formErrors story
Doesn't work in test
@codecov
Copy link

codecovbot commentedApr 27, 2022
edited
Loading

Codecov Report

Merging#1197 (10c765c) intomain (816441e) willincrease coverage by0.29%.
The diff coverage is91.54%.

@@            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
FlagCoverage Δ
unittest-go-macos-latest53.44% <ø> (-0.01%)⬇️
unittest-go-postgres-65.44% <ø> (+0.19%)⬆️
unittest-go-ubuntu-latest55.95% <ø> (-0.08%)⬇️
unittest-go-windows-202253.06% <ø> (ø)
unittest-js68.85% <91.54%> (+2.35%)⬆️
Impacted FilesCoverage Δ
site/src/AppRouter.tsx0.00% <0.00%> (ø)
site/src/api/errors.ts85.71% <ø> (ø)
site/src/testHelpers/entities.ts100.00% <ø> (ø)
site/src/api/index.ts65.30% <66.66%> (+0.08%)⬆️
site/src/xServices/users/usersXService.ts81.25% <77.77%> (-4.47%)⬇️
site/src/xServices/StateContext.tsx92.30% <80.00%> (-7.70%)⬇️
site/src/pages/UsersPage/UsersPage.tsx82.35% <87.50%> (-0.99%)⬇️
...e/src/components/CreateUserForm/CreateUserForm.tsx100.00% <100.00%> (ø)
site/src/components/FormFooter/FormFooter.tsx91.66% <100.00%> (+91.66%)⬆️
.../pages/UsersPage/CreateUserPage/CreateUserPage.tsx100.00% <100.00%> (ø)
... and12 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update816441e...10c765c. Read thecomment docs.

@presleyppresleyp marked this pull request as ready for reviewApril 28, 2022 15:36
@presleyppresleyp requested a review froma team as acode ownerApril 28, 2022 15:36

export const CreateUserPage: React.FC = () => {
const xServices = useContext(XServiceContext)
const myOrgId = useSelector(xServices.authXService, selectOrgId)
Copy link
ContributorAuthor

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.

greyscaled reacted with heart emoji
email: "",
password: "",
username: "",
organization_id: myOrgId,
Copy link
ContributorAuthor

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.

greyscaled reacted with thumbs up emoji
target: "idle",
actions: ["assignCreateUserError"],
},
],
Copy link
ContributorAuthor

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.

@presleyppresleyp self-assigned thisApr 28, 2022
Copy link
Contributor

@greyscaledgreyscaled left a comment

Choose a reason for hiding this comment

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

Nicely done 🎉

Comment on lines +76 to +86
onError: [
{
target: "idle",
cond: "isFormError",
actions: ["assignCreateUserFormErrors"],
},
{
target: "idle",
actions: ["assignCreateUserError"],
},
],
Copy link
Contributor

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>
@presleyppresleyp merged commitc16f105 intomainApr 28, 2022
@presleyppresleyp deleted the create-user/presleyp/734 branchApril 28, 2022 20:32
@missknissmisskniss added this to theV2 Beta milestoneMay 15, 2022
kylecarbs pushed a commit that referenced this pull requestJun 10, 2022
* 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>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@khorne3khorne3khorne3 left review comments

@greyscaledgreyscaledgreyscaled approved these changes

Assignees

@presleyppresleyp

Labels
None yet
Projects
None yet
Milestone
V2 Beta
Development

Successfully merging this pull request may close these issues.

Frontend User Create
4 participants
@presleyp@greyscaled@khorne3@misskniss

[8]ページ先頭

©2009-2025 Movatter.jp