Skip to content
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

Show username validation error messages #6399

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

SHestres
Copy link

Changes

  • Validates the username input field against the same regex used by the backend. The regex was modified to not allow usernames that are all spaces.
  • This is done by adding a "validator" attribute to InputElement which has a regex pattern and an error message.
  • The error message is only shown when the input is invalid, and after the input has been changed (to prevent immediate error messages before a single character has been entered)
  • Styles for the error message are in a new scss file
  • Shows errors returned by the api in a toast notification, such as when another user already has that name
  • These changes were all made to the forms for creating a new user and editing an existing user
  • Hides loading spinner when submitting user profile edits with errors. Previously the spinner would stay until the page was refreshed if the api returned an error

Issues
Closes #6384

Any errors returned by the API when submitting edits to a user caused the loading spinner to stay on screen. This hides the spinner and makes the error message visible to the user
Show a descriptive message when the username input doesn't match a modified version of the regex used by the backend
@SHestres SHestres requested a review from a team as a code owner December 18, 2024 08:24
@jellyfin-bot
Copy link
Collaborator

jellyfin-bot commented Dec 18, 2024

Cloudflare Pages deployment

Latest commit 51c4070
Status ✅ Deployed!
Preview URL https://31dbd1db.jellyfin-web.pages.dev
Type 🔀 Preview

View build logs

src/apps/dashboard/routes/users/add.tsx Outdated Show resolved Hide resolved
@@ -318,6 +327,7 @@ const UserEdit = () => {
type='text'
id='txtUserName'
label='LabelName'
validator={{ pattern: '^([\\w \\-\'._@+]*)([\\w\\-\'._@+])([\\w \\-\'._@+]*)$', errMessage: 'Username must not be empty and contain only numbers, letters, spaces, or the following symbols -\'._@+' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

The text of the error message should be moved to en-us.json and globalize.translate should be used.

Copy link
Author

Choose a reason for hiding this comment

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

Is that the way to add new phrases for globalization? Is there anything else I need to do for Weblate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants