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

[FEATURE] Adjust self delete account (PIX-15713) #10833

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions admin/app/components/users/user-overview.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ export default class UserOverview extends Component {
}

get anonymisationMessage() {
return this.args.user.anonymisedByFullName
? `Utilisateur anonymisé par ${this.args.user.anonymisedByFullName}.`
: 'Utilisateur anonymisé.';
return this.args.user.id === String(this.args.user.hasBeenAnonymisedBy)
? 'Utilisateur anonymisé par lui-même.'
: this.args.user.anonymisedByFullName
? `Utilisateur anonymisé par ${this.args.user.anonymisedByFullName}.`
: 'Utilisateur anonymisé.';
}

get canModifyEmail() {
Expand Down
1 change: 1 addition & 0 deletions admin/app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class User extends Model {
@attr() lastLoggedAt;
@attr() emailConfirmedAt;
@attr() hasBeenAnonymised;
@attr() hasBeenAnonymisedBy;
@attr() anonymisedByFullName;
@attr() isPixAgent;

Expand Down
77 changes: 73 additions & 4 deletions admin/tests/integration/components/users/user-overview-test.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,65 @@ module('Integration | Component | users | user-overview', function (hooks) {
});

module('when the admin look at user details', function () {
module('when the user is anonymised', function () {
module('when the user has self deleted his account', function () {
test('displays the dedicated deletion message', async function (assert) {
// given

const store = this.owner.lookup('service:store');
const user = store.createRecord('user', {
id: '123',
firstName: '(anonymised)',
lastName: '(anonymised)',
email: null,
username: null,
hasBeenAnonymised: true,
hasBeenAnonymisedBy: 123,
anonymisedByFullName: '(anonymised) (anonymised)',
});

// when
const screen = await render(<template><UserOverview @user={{user}} /></template>);

// then
assert
.dom(screen.getByText(t('pages.user-details.overview.anonymisation.self-anonymisation-message')))
.exists();
});
});

module("when the user's account has been deleted by an admin member", function () {
test("displays the deletion message with the admin member's full name", async function (assert) {
// given
const store = this.owner.lookup('service:store');
const fullname = 'Laurent Bobine';
const user = store.createRecord('user', {
id: '123',
firstName: '(anonymised)',
lastName: '(anonymised)',
email: null,
username: null,
hasBeenAnonymised: true,
hasBeenAnonymisedBy: 456,
anonymisedByFullName: fullname,
});

// when
const screen = await render(<template><UserOverview @user={{user}} /></template>);

// then

assert
.dom(
screen.getByText(
t('pages.user-details.overview.anonymisation.user-anonymised-by-admin-message', { fullname }),
),
)
.exists();
});
});
});

test('displays the update button', async function (assert) {
// given
const user = {
Expand Down Expand Up @@ -545,19 +604,27 @@ module('Integration | Component | users | user-overview', function (hooks) {
test('displays an anonymisation message with the full name of the admin member', async function (assert) {
// given
const store = this.owner.lookup('service:store');
const user = store.createRecord('user', { hasBeenAnonymised: true, anonymisedByFullName: 'Laurent Gina' });
const fullname = 'Laurent Gina';
const user = store.createRecord('user', { hasBeenAnonymised: true, anonymisedByFullName: fullname });

// when
const screen = await render(<template><UserOverview @user={{user}} /></template>);

// then
assert.dom(screen.getByText('Utilisateur anonymisé par Laurent Gina.')).exists();
assert
.dom(
screen.getByText(
t('pages.user-details.overview.anonymisation.user-anonymised-by-admin-message', { fullname }),
),
)
.exists();
});

test('disables action buttons "Modifier" and "Anonymiser cet utilisateur"', async function (assert) {
// given
const store = this.owner.lookup('service:store');
const user = store.createRecord('user', { hasBeenAnonymised: true, anonymisedByFullName: 'Laurent Gina' });
const fullname = 'Laurent Gina';
const user = store.createRecord('user', { hasBeenAnonymised: true, anonymisedByFullName: fullname });

// when
const screen = await render(<template><UserOverview @user={{user}} /></template>);
Expand All @@ -577,7 +644,9 @@ module('Integration | Component | users | user-overview', function (hooks) {
const screen = await render(<template><UserOverview @user={{user}} /></template>);

// then
assert.dom(screen.getByText('Utilisateur anonymisé.')).exists();
assert
.dom(screen.getByText(t('pages.user-details.overview.anonymisation.default-anonymised-user-message')))
.exists();
});
});
});
Expand Down
9 changes: 8 additions & 1 deletion admin/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@
"authentication-methods": "Méthodes de connexion",
"certification-centers-list": "Pix Certif",
"cgu": "Terms of service",
"cgu-aria-label" : "Terms of service",
"cgu-aria-label": "Terms of service",
"details": "Informations prescrit",
"organizations-list": "Pix Orga",
"participations-list": "Participations",
Expand All @@ -753,6 +753,13 @@
"deactivate-certification-center-membership": "Le membre a correctement été désactivé.",
"update-certification-center-membership-role": "Le rôle du membre a été modifié."
}
},
"overview": {
"anonymisation": {
"default-anonymised-user-message": "Anonymised user.",
"self-anonymisation-message": "User anonymised by themself.",
"user-anonymised-by-admin-message": "User anonymised by {fullname}."
}
}
},
"users-list": {
Expand Down
9 changes: 8 additions & 1 deletion admin/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@
"authentication-methods": "Méthodes de connexion",
"certification-centers-list": "Pix Certif",
"cgu": "CGU",
"cgu-aria-label" : "Conditions générales d'utilisation",
"cgu-aria-label": "Conditions générales d'utilisation",
"details": "Informations prescrit",
"organizations-list": "Pix Orga",
"participations-list": "Participations",
Expand All @@ -777,6 +777,13 @@
"deactivate-certification-center-membership": "Le membre a correctement été désactivé.",
"update-certification-center-membership-role": "Le rôle du membre a été modifié."
}
},
"overview": {
"anonymisation": {
"default-anonymised-user-message": "Utilisateur anonymisé.",
"self-anonymisation-message": "Utilisateur anonymisé par lui-même.",
"user-anonymised-by-admin-message": "Utilisateur anonymisé par {fullname}."
}
}
},
"users-list": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UserDetailsForAdmin {
emailConfirmedAt,
userLogin,
hasBeenAnonymised,
hasBeenAnonymisedBy,
anonymisedByFirstName,
anonymisedByLastName,
isPixAgent,
Expand Down Expand Up @@ -54,6 +55,7 @@ class UserDetailsForAdmin {
this.emailConfirmedAt = emailConfirmedAt;
this.userLogin = userLogin;
this.hasBeenAnonymised = hasBeenAnonymised;
this.hasBeenAnonymisedBy = hasBeenAnonymisedBy;
this.updatedAt = updatedAt;
this.anonymisedByFirstName = anonymisedByFirstName;
this.anonymisedByLastName = anonymisedByLastName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ function _fromKnexDTOToUserDetailsForAdmin({
authenticationMethods,
userLogin,
hasBeenAnonymised: userDTO.hasBeenAnonymised,
hasBeenAnonymisedBy: userDTO.hasBeenAnonymisedBy,
updatedAt: userDTO.updatedAt,
createdAt: userDTO.createdAt,
anonymisedByFirstName: userDTO.anonymisedByFirstName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const serialize = function (usersDetailsForAdmin) {
'lastLoggedAt',
'emailConfirmedAt',
'hasBeenAnonymised',
'hasBeenAnonymisedBy',
'anonymisedByFullName',
'organizationLearners',
'authenticationMethods',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ describe('Acceptance | Identity Access Management | Application | Route | Admin
'pix-orga-terms-of-service-accepted': false,
username: user.username,
'has-been-anonymised': false,
'has-been-anonymised-by': null,
'anonymised-by-full-name': null,
'is-pix-agent': false,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('Unit | Serializer | JSONAPI | user-details-for-admin-serializer', func
'last-logged-at': now,
'email-confirmed-at': now,
'has-been-anonymised': false,
'has-been-anonymised-by': null,
'anonymised-by-full-name': null,
'is-pix-agent': false,
},
Expand Down
6 changes: 3 additions & 3 deletions mon-pix/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2161,8 +2161,8 @@
"more-information": "Para más información,",
"more-information-contact-support": "puede ponerse en contacto con el servicio de asistencia.",
"title": "Eliminar mi cuenta definitivamente",
"warning-email": "Esta acción es irreversible. {pixScore} Todas las habilidades, cursos y píxeles que haya obtenido se eliminarán de forma permanente para la cuenta PIX que utilice la dirección de correo electrónico<strong>{email}</strong>.",
"warning-other": "Esta acción es irreversible. {pixScore} Todas las habilidades, cursos y píxeles que haya obtenido se eliminarán permanentemente de la cuenta PIX.<strong>{firstName} {lastName}</strong>."
"warning-email": "Esta acción es irreversible. {pixScore} Todas las habilidades, cursos y píxeles que haya obtenido se eliminarán de forma permanente para la cuenta PIX que utilice la dirección de correo electrónico <strong>{email}</strong>.",
"warning-other": "Esta acción es irreversible. {pixScore} Todas las habilidades, cursos y píxeles que haya obtenido se eliminarán permanentemente de la cuenta PIX <strong>{firstName} {lastName}</strong>."
},
"email-confirmed": "Dirección de correo electrónico verificada.",
"email-verification": {
Expand Down Expand Up @@ -2250,4 +2250,4 @@
"title": "Mis tutoriales"
}
}
}
}
6 changes: 3 additions & 3 deletions mon-pix/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2161,8 +2161,8 @@
"more-information": "Voor meer informatie,",
"more-information-contact-support": "kunt u contact opnemen met ondersteuning.",
"title": "Mijn account permanent verwijderen",
"warning-email": "Deze actie is onomkeerbaar. {pixScore} Alle vaardigheden, cursussen en pix die je hebt verkregen worden permanent verwijderd voor het PIX-account met het e-mailadres<strong>{email}</strong>.",
"warning-other": "Deze actie is onomkeerbaar. {pixScore} Alle vaardigheden, cursussen en pix die je hebt behaald, worden permanent verwijderd van het PIX-account.<strong>{firstName} {lastName}</strong>."
"warning-email": "Deze actie is onomkeerbaar. {pixScore} Alle vaardigheden, cursussen en pix die je hebt verkregen worden permanent verwijderd voor het PIX-account met het e-mailadres <strong>{email}</strong>.",
"warning-other": "Deze actie is onomkeerbaar. {pixScore} Alle vaardigheden, cursussen en pix die je hebt behaald, worden permanent verwijderd van het PIX-account <strong>{firstName} {lastName}</strong>."
},
"email-confirmed": "Geverifieerd e-mailadres.",
"email-verification": {
Expand Down Expand Up @@ -2250,4 +2250,4 @@
"title": "Mijn tutorials"
}
}
}
}
Loading