Page MenuHomePhabricator

[web] Call `create_thread` from `CommunityCreationModal` on form submission
ClosedPublic

Authored by atul on May 16 2023, 1:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 14, 1:16 AM
Unknown Object (File)
Tue, May 7, 6:14 AM
Unknown Object (File)
Mon, Apr 22, 9:14 AM
Unknown Object (File)
Mon, Apr 22, 9:14 AM
Unknown Object (File)
Mon, Apr 22, 9:14 AM
Unknown Object (File)
Mon, Apr 22, 9:14 AM
Unknown Object (File)
Mon, Apr 22, 9:13 AM
Unknown Object (File)
Mon, Apr 22, 9:00 AM
Subscribers

Details

Summary

We send a request to the create_thread endpoint with the community name and announcement setting selected by the user in CommunityCreationModal.

We show a spinner when the request is loading.

We display an error message and style the button if the request fails. The error message and styling is cleared when:

  1. The user makes a change to any of the inputs (name or announcement).
  2. The user clicks the button and re-attempts submitting the form.

If the request succeeds, we navigate to the newly created community root thread.

In subsequent diff we will bring up an "Add members" modal (after a small delay?) after displaying the newly created thread.

Test Plan

Tested "happy case" by creating multiple communities and ensuring that they were created as expected by checked threads table and navigating to them in the web app.

705b95.png (2×620 px, 179 KB)

Also modified threadCreationResponder to immediately throw new ServerError("Error") to simulate request failure case. Ensured that errorMessage + button styling appeared as expected. Then updated the endpoint to return successfully, retried request, and ensured it went through as expected.

e7805b.png (1×1 px, 115 KB)

ab425e.png (2×1 px, 157 KB)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul published this revision for review.May 16 2023, 1:02 PM
atul added inline comments.
web/sidebar/community-creation/community-creation-modal.css
88–93 ↗(On Diff #26567)

The min-height here is to ensure that the text + LoadingIndicator both fit inside the createCommunityButton and it doesn't weirdly resize when the content changes.

(Open to other approaches here)

ashoat added inline comments.
web/sidebar/community-creation/community-creation-modal.react.js
85 ↗(On Diff #26567)

You should throw e here so that we properly dispatch a NEW_THREAD_FAILED

99 ↗(On Diff #26567)

This should be a NewThreadResult (not optional); we expect the promise to reject if anything goes wrong

This revision is now accepted and ready to land.May 16 2023, 1:32 PM
web/sidebar/community-creation/community-creation-modal.react.js
85 ↗(On Diff #26567)

Ah yeah, thanks for catching that

atul edited the test plan for this revision. (Show Details)

address feedback

This revision was landed with ongoing or failed builds.May 16 2023, 3:09 PM
This revision was automatically updated to reflect the committed changes.
web/sidebar/community-creation/community-creation-modal.react.js
101

This conditional should've been removed

web/sidebar/community-creation/community-creation-modal.react.js
101

Thanks for catching that, addressed in https://phab.comm.dev/D7862