Skip to content

feat: allow users to sign up and fill out public forms#1114

Merged
3mcd merged 49 commits into
mainfrom
tfk/public-form-users
Apr 3, 2025
Merged

feat: allow users to sign up and fill out public forms#1114
3mcd merged 49 commits into
mainfrom
tfk/public-form-users

Conversation

@tefkah
Copy link
Copy Markdown
Member

@tefkah tefkah commented Mar 26, 2025

Issue(s) Resolved

Resolves #1053
Resolves #1051

High-level Explanation of PR

There is now the possibility for people to sign up to communities without being invited.

Communities that have at least one public form now automatically enable signups at /c/{communitySlug}/public/signup. There currently is no way to disable this aside from settings your forms to private.

Users who go to a public form, will now be redirected to the signup page, where they can sign up to the community. Once complete, they will be redirected to the form they tried to access.

Separately from all this: once a user creates a pub using the PubEditor, they will be added as a Contributor to the pub. This allows the user to see the pub in the pub list.

This PR also removes the "Invite Only" access type. Forms which were set to this will be set to private instead.

Extra credits

Redirect to the created pub

Currently there is no easy way to direct the user to their created pub. I added a new option to the :link token that allows you to link to a pub. It goes like :link(page='currentPub' text='View your pub'). This will link to the pub that the user just created. By setting the postsubmit screen like i do here

https://github.com/pubpub/platform/blob/1e622788da94c05597f27a586f5df2040bd40bea/core/playwright/formAccess.spec.ts#L126-L131

the user will see a screen like this (note how it links to a direct pub)

Image

We should probably have some redirect action instead, see #1115 for more details.

Nicer button

I added a button that automatically does broadly correct loading state showing, see:

Screen.Recording.2025-03-27.at.19.55.02.mov

The code is here:

https://github.com/pubpub/platform/blob/8b86f1f18dd978de78d5622e7c0ede14d322066c/core/app/components/SubmitButton.tsx#L1-L176

I think it's nice and we should use it in more places.

Test Plan

As always, convince yourself of the truth and accuracy of the added tests.

  1. Go to https://pr-1114-public-form-u-ip-54-221-104-228.my.preview.run/c/croccroc/public/forms/review/fill while not logged in.
  2. Be presented with the signup form, create an account.
  3. You should be redirected back to the form.
  4. Fill out form and submit.
  5. Click the link
  6. See that you are redirected to your pub, and see that you are a contributor.

Do maybe the same again after changing the form to private (and logging out). You should not be able to see the form/signup page at all.

Screenshots (if applicable)

Demo:

Screenshare.-.2025-03-27.8_21_16.PM.mp4

I changed the spacing of button config form from this

image

to this

image

Notes

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 26, 2025

PR Preview Action v1.6.0
Preview removed because the pull request was closed.
2025-04-03 16:31 UTC

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

please add to this when you encounter an issue!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ideally we would define most errors for server actions like this i think, rather than having a bunch of random return { error: 'xxxx' } everywhere

@3mcd 3mcd temporarily deployed to gh-654103159-pr-1114 March 27, 2025 19:27 Inactive
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i thought i wanted to use this in a playwright test (to do a rollback), which is why i moved it. didn't actually want to turns out, bc if you update things in a transaction, ofc the app will not reflect those changes before you commit


const handleSubmit = useCallback(
async (data: SignupFormSchema) => {
// TODO: this is not very nice UX, we should wait a sec and show a loading state
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

since the signup function already redirected users i didn't really want to change it, but we should figure out some nice pattern here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is the signup form for users who are invited using the email action to complete their signup. i think we should phase this out and handle those invites the same as invites where we do not create an account yet (#1002)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

users who are already logged in should not sign up again, they can just join the community immediately.
both this and the signup form (or just that page) should show some branding in the future.

Comment on lines -11 to -16
[FormAccessType.inviteOnly]: {
Icon: Contact,
description: "Accessible via URL with tracked submissions",
name: "Invite Only",
help: "Community members & invited contributors can submit",
},
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As per the extra work in #1051 , we now only have private and public forms

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this logic is getting very complex. in my next pr i will create some kind of centralized place to handle this, like a Service class or something

"display": "Next.js",
"extends": "./base.json",
"compilerOptions": {
"plugins": [{ "name": "next" }],
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this removal doesn't really do anything other than make me feel better.

@3mcd 3mcd temporarily deployed to gh-654103159-pr-1114 April 1, 2025 13:48 Inactive
@3mcd 3mcd temporarily deployed to gh-654103159-pr-1114 April 2, 2025 09:49 Inactive
type?: "button" | "submit" | "reset";
};

export const SubmitButton = ({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤩

@allisonking
Copy link
Copy Markdown
Contributor

I tested using the preview environment, though I wasn't able to see the pub once I hit submit on the form. I saw the 'Go see your pubs here' link, and clicked here, but then got redirected to sign in. I tried to sign in but it didn't work (this might just be because I didn't remember my temp password right). the pub I made is there though: https://pr-1114-public-form-u-ip-54-221-104-228.my.preview.run/c/croccroc/pubs/84e66eea-563f-4c2c-ba90-fcfd1f781cea

I'll try locally too to see if maybe it's just something is up with the preview env

@allisonking
Copy link
Copy Markdown
Contributor

well it seems to work locally! although I can't seem to change a form to private so haven't been able to test the 'no forms should show up' state yet

Screen.Recording.2025-04-02.at.11.28.26.AM.mov

@tefkah
Copy link
Copy Markdown
Member Author

tefkah commented Apr 3, 2025

huh that's strange, ill have a look!

@tefkah
Copy link
Copy Markdown
Member Author

tefkah commented Apr 3, 2025

The "not being able to change access types" is a bug in the formbuilder, you need to change something else about the form in order for it to change. ill put up a quick pr which addresses that (and some other thing), but i don't want this pr to be even bigger!

Copy link
Copy Markdown
Contributor

@allisonking allisonking left a comment

Choose a reason for hiding this comment

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

ah okay great! I confirmed that I can make private if I also add another form element, and then the not-signed-in user can't see it 👍 nice work!

@3mcd 3mcd had a problem deploying to gh-654103159-pr-1114 April 3, 2025 16:15 Error
@3mcd 3mcd merged commit b76526c into main Apr 3, 2025
@3mcd 3mcd deleted the tfk/public-form-users branch April 3, 2025 16:31
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 8, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ Error: Unexpected link variant serverAction/ View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Auto-deploys a preview application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add contributor pub membership when user creates pub Allow users to create or login to accounts to fill out forms set to public

3 participants