Skip to content

Commit

Permalink
fix(web) improve first user form (#1374)
Browse files Browse the repository at this point in the history
## Problem

#1364 reported two small
problems in the first user form:

* The lack of red asterisk in some mandatory fields
* The presence of "undefined" suggestion for the username field when the
name has not been given.

## Solution

To show suggestions only when it make sense and to drop the required
mark from the username field. As said in a commit, after Agama 9 the
forms and its required fields are going to be improved.

## Testing

- Tested manually
  • Loading branch information
dgdavid authored Jun 25, 2024
2 parents 7f641e4 + 33d2fdc commit 100672e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion web/src/components/users/FirstUserForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ export default function FirstUserForm() {
className="first-username-wrapper"
fieldId="userName"
label={_("Username")}
isRequired
>
<TextInput
id="userName"
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/users/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* @returns {string[]} An array of username suggestions.
*/
const suggestUsernames = (fullName) => {
if (!fullName) return [];

// Cleaning the name.
const cleanedName = fullName
.normalize('NFD')
Expand Down
5 changes: 5 additions & 0 deletions web/src/components/users/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
import { suggestUsernames } from "./utils";

describe('suggestUsernames', () => {
test('returns empty collection if fullName not defined', () => {
expect(suggestUsernames(undefined)).toEqual([]);
expect(suggestUsernames(null)).toEqual([]);
});

test('handles basic single name', () => {
expect(suggestUsernames('John')).toEqual(expect.arrayContaining(['john']));
});
Expand Down

0 comments on commit 100672e

Please sign in to comment.