Skip to content

Commit

Permalink
feat(admin): allow email null when editing a user with userName conne…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
P-Jeremy committed Jan 13, 2025
1 parent e27405c commit 2fac36f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion admin/app/components/users/user-overview.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export default class UserOverview extends Component {
return hasBeenAnonymised || isPixAgent;
}

get isEmailRequired() {
return this.args.user.username ? null : 'obligatoire';
}

_initForm() {
this.form.firstName = this.args.user.firstName;
this.form.lastName = this.args.user.lastName;
Expand Down Expand Up @@ -201,7 +205,7 @@ export default class UserOverview extends Component {
{{#if this.canModifyEmail}}
<div class="form-field">
<PixInput
@requiredLabel="obligatoire"
@requiredLabel={{this.isEmailRequired}}
@errorMessage={{this.form.emailError.message}}
@validationStatus={{this.form.emailError.status}}
@value={{this.form.email}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
assert.dom(screen.getByRole('textbox', { name: 'Identifiant *' })).hasValue(user.username);
});

test('displays email', async function (assert) {
test('displays not required email', async function (assert) {
// given
const user = EmberObject.create({
lastName: 'Harry',
Expand All @@ -529,7 +529,9 @@ module('Integration | Component | users | user-overview', function (hooks) {
await clickByName('Modifier');

// then
assert.dom(screen.getByRole('textbox', { name: 'Adresse e-mail *' })).exists();
const emailInput = screen.getByRole('textbox', { name: 'Adresse e-mail' });
assert.dom(emailInput).exists();
assert.dom(emailInput).hasNoAttribute('required');
});
});

Expand Down

0 comments on commit 2fac36f

Please sign in to comment.