From bee93b86c415c97e60404780b23b512d8260329c Mon Sep 17 00:00:00 2001 From: AndreiaPena Date: Tue, 19 Nov 2024 17:26:10 +0100 Subject: [PATCH 01/10] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20admin:=20=20bump=20p?= =?UTF-8?q?ix=20ui=20to=20v48.6.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/package-lock.json | 8 ++++---- admin/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/admin/package-lock.json b/admin/package-lock.json index 4e97da36638..832f5db0aa0 100644 --- a/admin/package-lock.json +++ b/admin/package-lock.json @@ -13,7 +13,7 @@ "@1024pix/ember-cli-notifications": "^8.0.2", "@1024pix/ember-testing-library": "^3.0.6", "@1024pix/eslint-config": "^1.3.8", - "@1024pix/pix-ui": "^48.6.0", + "@1024pix/pix-ui": "^48.6.2", "@1024pix/stylelint-config": "^5.1.22", "@babel/eslint-parser": "^7.19.1", "@ember/optional-features": "^2.0.0", @@ -921,9 +921,9 @@ } }, "node_modules/@1024pix/pix-ui": { - "version": "48.6.0", - "resolved": "https://registry.npmjs.org/@1024pix/pix-ui/-/pix-ui-48.6.0.tgz", - "integrity": "sha512-e7dBX5VEvn8PDizhhtXHHXP6lYZXajoT1HXbre3nmA57j/7FqkgkJy0J8vxmGrTFr51cC4bJvl3Ns9vMFhCz9Q==", + "version": "48.6.2", + "resolved": "https://registry.npmjs.org/@1024pix/pix-ui/-/pix-ui-48.6.2.tgz", + "integrity": "sha512-Ww25fsoGFHu+gvKhEQ1ZX7w7KckweEuxAMUtAMGkav4nbW5EVYhLfwZELksIZyCxdyDvtJDNY8TsDNUOYy7b2g==", "dev": true, "hasInstallScript": true, "license": "MIT", diff --git a/admin/package.json b/admin/package.json index 22c10629439..176b8b83007 100644 --- a/admin/package.json +++ b/admin/package.json @@ -45,7 +45,7 @@ "@1024pix/ember-cli-notifications": "^8.0.2", "@1024pix/ember-testing-library": "^3.0.6", "@1024pix/eslint-config": "^1.3.8", - "@1024pix/pix-ui": "^48.6.0", + "@1024pix/pix-ui": "^48.6.2", "@1024pix/stylelint-config": "^5.1.22", "@babel/eslint-parser": "^7.19.1", "@ember/optional-features": "^2.0.0", From 90fb931b8c0fc73235d21117b1c6c3c5e7116666 Mon Sep 17 00:00:00 2001 From: AndreiaPena Date: Mon, 18 Nov 2024 17:09:04 +0100 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=94=A5=20admin:=20remove=20clearAll?= =?UTF-8?q?=20notifications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../administration/access/anonymize-gar-import.gjs | 1 - .../administration/access/oidc-providers-import.gjs | 1 - .../administration/campaigns/campaigns-import.gjs | 1 - .../administration/campaigns/swap-campaign-codes.gjs | 1 - .../administration/campaigns/update-campaign-code.gjs | 1 - .../certification/sco-whitelist-configuration.gjs | 1 - .../common/add-organization-features-in-batch.gjs | 1 - .../deployment/organization-tags-import.gjs | 1 - .../administration/deployment/organizations-import.gjs | 1 - .../deployment/update-organizations-in-batch.gjs | 1 - .../organizations/update-organization-import-format.gjs | 1 - admin/app/controllers/authenticated/tools.js | 1 - .../administration/campaigns/campaigns-import-test.gjs | 5 +---- .../administration/campaigns/swap-campaign-codes-test.gjs | 5 ----- .../campaigns/update-campaign-code-test.gjs | 2 -- .../deployment/organizations-import-test.gjs | 5 +---- .../update-organization-import-format-test.gjs | 6 +----- .../administration/update-campaign-code-test.js | 8 +------- 18 files changed, 4 insertions(+), 39 deletions(-) diff --git a/admin/app/components/administration/access/anonymize-gar-import.gjs b/admin/app/components/administration/access/anonymize-gar-import.gjs index 473ae80b8f1..2f2893d13f3 100644 --- a/admin/app/components/administration/access/anonymize-gar-import.gjs +++ b/admin/app/components/administration/access/anonymize-gar-import.gjs @@ -18,7 +18,6 @@ export default class AnonymizeGarImport extends Component { @action async anonymizeGar(files) { this.isLoading = true; - this.notifications.clearAll(); try { const token = this.session.data.authenticated.access_token; diff --git a/admin/app/components/administration/access/oidc-providers-import.gjs b/admin/app/components/administration/access/oidc-providers-import.gjs index 508454d5186..d806825d000 100644 --- a/admin/app/components/administration/access/oidc-providers-import.gjs +++ b/admin/app/components/administration/access/oidc-providers-import.gjs @@ -15,7 +15,6 @@ export default class OidcProvidersImport extends Component { @action async importOidcProviders(files) { - this.notifications.clearAll(); let response; try { diff --git a/admin/app/components/administration/campaigns/campaigns-import.gjs b/admin/app/components/administration/campaigns/campaigns-import.gjs index 3398db471a6..9ac515046d4 100644 --- a/admin/app/components/administration/campaigns/campaigns-import.gjs +++ b/admin/app/components/administration/campaigns/campaigns-import.gjs @@ -14,7 +14,6 @@ export default class CampaignsImport extends Component { @action async importCampaigns(files) { - this.notifications.clearAll(); const adapter = this.store.adapterFor('import-files'); try { diff --git a/admin/app/components/administration/campaigns/swap-campaign-codes.gjs b/admin/app/components/administration/campaigns/swap-campaign-codes.gjs index 7f2d03151ff..3393989a5ed 100644 --- a/admin/app/components/administration/campaigns/swap-campaign-codes.gjs +++ b/admin/app/components/administration/campaigns/swap-campaign-codes.gjs @@ -21,7 +21,6 @@ export default class SwapCampaignCodes extends Component { async swapCodes(event) { event.preventDefault(); this.isLoading = true; - this.notifications.clearAll(); const adapter = this.store.adapterFor('swap-campaign-code'); try { diff --git a/admin/app/components/administration/campaigns/update-campaign-code.gjs b/admin/app/components/administration/campaigns/update-campaign-code.gjs index dbc91ecf7d9..d805a6f22dd 100644 --- a/admin/app/components/administration/campaigns/update-campaign-code.gjs +++ b/admin/app/components/administration/campaigns/update-campaign-code.gjs @@ -20,7 +20,6 @@ export default class UpdateCampaignCode extends Component { async updateCode(event) { event.preventDefault(); this.isLoading = true; - this.notifications.clearAll(); const adapter = this.store.adapterFor('update-campaign-code'); try { diff --git a/admin/app/components/administration/certification/sco-whitelist-configuration.gjs b/admin/app/components/administration/certification/sco-whitelist-configuration.gjs index bfa24d3f540..0eaa203705d 100644 --- a/admin/app/components/administration/certification/sco-whitelist-configuration.gjs +++ b/admin/app/components/administration/certification/sco-whitelist-configuration.gjs @@ -15,7 +15,6 @@ export default class ScoWhitelistConfiguration extends Component { @action async importScoWhitelist(files) { - this.notifications.clearAll(); try { const fileContent = files[0]; diff --git a/admin/app/components/administration/common/add-organization-features-in-batch.gjs b/admin/app/components/administration/common/add-organization-features-in-batch.gjs index e51acc1d761..b5a7a8bde2b 100644 --- a/admin/app/components/administration/common/add-organization-features-in-batch.gjs +++ b/admin/app/components/administration/common/add-organization-features-in-batch.gjs @@ -15,7 +15,6 @@ export default class AddOrganizationFeaturesInBatch extends Component { @action async addOrganizationFeaturesInBatch(files) { - this.notifications.clearAll(); let response; try { diff --git a/admin/app/components/administration/deployment/organization-tags-import.gjs b/admin/app/components/administration/deployment/organization-tags-import.gjs index b999317f5c3..4af2f2bc911 100644 --- a/admin/app/components/administration/deployment/organization-tags-import.gjs +++ b/admin/app/components/administration/deployment/organization-tags-import.gjs @@ -15,7 +15,6 @@ export default class OrganizationTagsImport extends Component { @action async importOrganizationTags(files) { - this.notifications.clearAll(); let response; try { diff --git a/admin/app/components/administration/deployment/organizations-import.gjs b/admin/app/components/administration/deployment/organizations-import.gjs index 0df91d65c75..4e241af3245 100644 --- a/admin/app/components/administration/deployment/organizations-import.gjs +++ b/admin/app/components/administration/deployment/organizations-import.gjs @@ -14,7 +14,6 @@ export default class OrganizationsImport extends Component { @action async importOrganizations(files) { - this.notifications.clearAll(); const adapter = this.store.adapterFor('organizations-import'); try { diff --git a/admin/app/components/administration/deployment/update-organizations-in-batch.gjs b/admin/app/components/administration/deployment/update-organizations-in-batch.gjs index 72a57ee6464..85f4c268bd0 100644 --- a/admin/app/components/administration/deployment/update-organizations-in-batch.gjs +++ b/admin/app/components/administration/deployment/update-organizations-in-batch.gjs @@ -15,7 +15,6 @@ export default class UpdateOrganizationsInBatch extends Component { @action async updateOrganizationsInBatch(files) { - this.notifications.clearAll(); let response; diff --git a/admin/app/components/administration/organizations/update-organization-import-format.gjs b/admin/app/components/administration/organizations/update-organization-import-format.gjs index c87e1e7fb1d..5f18208300c 100644 --- a/admin/app/components/administration/organizations/update-organization-import-format.gjs +++ b/admin/app/components/administration/organizations/update-organization-import-format.gjs @@ -14,7 +14,6 @@ export default class UpdateOrganizationImportFormat extends Component { @action async uploadOrganizationImportFile(files) { - this.notifications.clearAll(); const adapter = this.store.adapterFor('import-files'); try { await adapter.updateOrganizationImportFormat(files); diff --git a/admin/app/controllers/authenticated/tools.js b/admin/app/controllers/authenticated/tools.js index 982f6b21824..602dbf4a398 100644 --- a/admin/app/controllers/authenticated/tools.js +++ b/admin/app/controllers/authenticated/tools.js @@ -12,7 +12,6 @@ export default class ToolsController extends Controller { const adapter = this.store.adapterFor('import-files'); this.isLoading = true; - this.notifications.clearAll(); try { await adapter.importCampaignsToArchive(files); this.isLoading = false; diff --git a/admin/tests/integration/components/administration/campaigns/campaigns-import-test.gjs b/admin/tests/integration/components/administration/campaigns/campaigns-import-test.gjs index c800a9be63c..40fefab20c0 100644 --- a/admin/tests/integration/components/administration/campaigns/campaigns-import-test.gjs +++ b/admin/tests/integration/components/administration/campaigns/campaigns-import-test.gjs @@ -13,7 +13,7 @@ module('Integration | Component | administration/campaigns-import', function (h setupIntlRenderingTest(hooks); setupMirage(hooks); - let store, adapter, notificationSuccessStub, clearAllStub, saveAdapterStub, notificationErrorStub; + let store, adapter, notificationSuccessStub, saveAdapterStub, notificationErrorStub; hooks.beforeEach(function () { store = this.owner.lookup('service:store'); adapter = store.adapterFor('import-files'); @@ -21,7 +21,6 @@ module('Integration | Component | administration/campaigns-import', function (h notificationSuccessStub = sinon.stub(); notificationErrorStub = sinon.stub().returns(); - clearAllStub = sinon.stub(); }); module('when import succeeds', function () { @@ -30,7 +29,6 @@ module('Integration | Component | administration/campaigns-import', function (h const file = new Blob(['foo'], { type: `valid-file` }); class NotificationsStub extends Service { success = notificationSuccessStub; - clearAll = clearAllStub; } this.owner.register('service:notifications', NotificationsStub); saveAdapterStub.withArgs(file).resolves(); @@ -65,7 +63,6 @@ module('Integration | Component | administration/campaigns-import', function (h const file = new Blob(['foo'], { type: `valid-file` }); class NotificationsStub extends Service { error = notificationErrorStub; - clearAll = clearAllStub; } this.owner.register('service:notifications', NotificationsStub); diff --git a/admin/tests/integration/components/administration/campaigns/swap-campaign-codes-test.gjs b/admin/tests/integration/components/administration/campaigns/swap-campaign-codes-test.gjs index 16d8b005f0a..2e0253f83b4 100644 --- a/admin/tests/integration/components/administration/campaigns/swap-campaign-codes-test.gjs +++ b/admin/tests/integration/components/administration/campaigns/swap-campaign-codes-test.gjs @@ -17,7 +17,6 @@ module('Integration | Component | administration/swap-campaign-codes', function store = this.owner.lookup('service:store'); sinon.stub(notificationService, 'success'); - sinon.stub(notificationService, 'clearAll'); sinon.stub(notificationService, 'error'); }); @@ -57,7 +56,6 @@ module('Integration | Component | administration/swap-campaign-codes', function ), ); assert.true(notificationService.error.notCalled); - assert.true(notificationService.clearAll.called); }); test('it should display common error notification', async function (assert) { @@ -90,7 +88,6 @@ module('Integration | Component | administration/swap-campaign-codes', function // then assert.true(swapStub.calledOnce); - assert.true(notificationService.clearAll.called); assert.true(notificationService.success.notCalled); assert.true(notificationService.error.calledOnceWithExactly(t('common.notifications.generic-error'))); }); @@ -125,7 +122,6 @@ module('Integration | Component | administration/swap-campaign-codes', function // then assert.true(swapStub.calledOnce); - assert.true(notificationService.clearAll.called); assert.true(notificationService.success.notCalled); assert.true( notificationService.error.calledOnceWithExactly( @@ -164,7 +160,6 @@ module('Integration | Component | administration/swap-campaign-codes', function // then assert.true(swapStub.calledOnce); - assert.true(notificationService.clearAll.called); assert.true(notificationService.success.notCalled); assert.true( notificationService.error.calledOnceWithExactly( diff --git a/admin/tests/integration/components/administration/campaigns/update-campaign-code-test.gjs b/admin/tests/integration/components/administration/campaigns/update-campaign-code-test.gjs index 6dcec1a7cb9..deef220feca 100644 --- a/admin/tests/integration/components/administration/campaigns/update-campaign-code-test.gjs +++ b/admin/tests/integration/components/administration/campaigns/update-campaign-code-test.gjs @@ -17,7 +17,6 @@ module('Integration | Component | administration/update-campaign-code', function store = this.owner.lookup('service:store'); sinon.stub(notificationService, 'success'); - sinon.stub(notificationService, 'clearAll'); sinon.stub(notificationService, 'error'); adapter = store.adapterFor('update-campaign-code'); @@ -57,6 +56,5 @@ module('Integration | Component | administration/update-campaign-code', function ), ); assert.true(notificationService.error.notCalled); - assert.true(notificationService.clearAll.called); }); }); diff --git a/admin/tests/integration/components/administration/deployment/organizations-import-test.gjs b/admin/tests/integration/components/administration/deployment/organizations-import-test.gjs index 80dac60f33c..e9b696a0b1d 100644 --- a/admin/tests/integration/components/administration/deployment/organizations-import-test.gjs +++ b/admin/tests/integration/components/administration/deployment/organizations-import-test.gjs @@ -13,7 +13,7 @@ module('Integration | Component | administration/organizations-import', functio setupIntlRenderingTest(hooks); setupMirage(hooks); - let store, adapter, notificationSuccessStub, clearAllStub, saveAdapterStub, notificationErrorStub; + let store, adapter, notificationSuccessStub, saveAdapterStub, notificationErrorStub; hooks.beforeEach(function () { store = this.owner.lookup('service:store'); @@ -22,7 +22,6 @@ module('Integration | Component | administration/organizations-import', functio notificationSuccessStub = sinon.stub(); notificationErrorStub = sinon.stub().returns(); - clearAllStub = sinon.stub(); }); module('when import succeeds', function () { @@ -31,7 +30,6 @@ module('Integration | Component | administration/organizations-import', functio const file = new Blob(['foo'], { type: `valid-file` }); class NotificationsStub extends Service { success = notificationSuccessStub; - clearAll = clearAllStub; } this.owner.register('service:notifications', NotificationsStub); saveAdapterStub.withArgs(file).resolves(); @@ -66,7 +64,6 @@ module('Integration | Component | administration/organizations-import', functio const file = new Blob(['foo'], { type: `valid-file` }); class NotificationsStub extends Service { error = notificationErrorStub; - clearAll = sinon.stub(); } this.owner.register('service:notifications', NotificationsStub); diff --git a/admin/tests/integration/components/administration/organizations/update-organization-import-format-test.gjs b/admin/tests/integration/components/administration/organizations/update-organization-import-format-test.gjs index 0c5622c3bb1..ab0696d5d3a 100644 --- a/admin/tests/integration/components/administration/organizations/update-organization-import-format-test.gjs +++ b/admin/tests/integration/components/administration/organizations/update-organization-import-format-test.gjs @@ -13,7 +13,7 @@ module('Integration | Component | administration/update-organization-import-form setupIntlRenderingTest(hooks); setupMirage(hooks); - let store, adapter, notificationSuccessStub, clearAllStub, saveAdapterStub, notificationErrorStub; + let store, adapter, notificationSuccessStub, saveAdapterStub, notificationErrorStub; hooks.beforeEach(function () { store = this.owner.lookup('service:store'); adapter = store.adapterFor('import-files'); @@ -21,7 +21,6 @@ module('Integration | Component | administration/update-organization-import-form notificationSuccessStub = sinon.stub(); notificationErrorStub = sinon.stub().returns(); - clearAllStub = sinon.stub(); }); module('when import succeeds', function () { @@ -31,7 +30,6 @@ module('Integration | Component | administration/update-organization-import-form class NotificationsStub extends Service { success = notificationSuccessStub; error = notificationErrorStub; - clearAll = clearAllStub; } this.owner.register('service:notifications', NotificationsStub); saveAdapterStub.withArgs([files]).resolves(); @@ -61,7 +59,6 @@ module('Integration | Component | administration/update-organization-import-form class NotificationsStub extends Service { error = notificationErrorStub; success = notificationSuccessStub; - clearAll = clearAllStub; } saveAdapterStub.withArgs([files]).rejects({ errors: [{ status: '422', meta: 'POUET', code: 'MISSING_REQUIRED_FIELD_NAMES' }], @@ -86,7 +83,6 @@ module('Integration | Component | administration/update-organization-import-form class NotificationsStub extends Service { error = notificationErrorStub; success = notificationSuccessStub; - clearAll = clearAllStub; } saveAdapterStub.withArgs([files]).rejects({ errors: [{ status: '422', title: "Un soucis avec l'import", code: '422', detail: 'Erreur d’import' }], diff --git a/admin/tests/unit/components/administration/update-campaign-code-test.js b/admin/tests/unit/components/administration/update-campaign-code-test.js index 8efb3f37678..e8895300e62 100644 --- a/admin/tests/unit/components/administration/update-campaign-code-test.js +++ b/admin/tests/unit/components/administration/update-campaign-code-test.js @@ -12,7 +12,7 @@ module('Unit | Component | update-campaign-code', function (hooks) { hooks.beforeEach(function () { // given updateCampaignCodeStub = sinon.stub(); - notificationStub = { clearAll: sinon.stub(), success: sinon.stub(), error: sinon.stub() }; + notificationStub = { sendSuccessNotification: sinon.stub(), sendErrorNotification: sinon.stub() }; intlStub = sinon.stub(); component = createGlimmerComponent('component:administration/campaigns/update-campaign-code'); component.notifications = notificationStub; @@ -49,7 +49,6 @@ module('Unit | Component | update-campaign-code', function (hooks) { await component.updateCode(event); // then - assert.ok(notificationStub.clearAll.calledOnce); assert.ok(intlStub.calledWithExactly('components.administration.update-campaign-code.notifications.success')); assert.ok(notificationStub.success.calledWithExactly(successMsg)); }); @@ -65,7 +64,6 @@ module('Unit | Component | update-campaign-code', function (hooks) { await component.updateCode(event); // then - assert.ok(notificationStub.clearAll.calledOnce); assert.ok( intlStub.calledWithExactly( 'components.administration.update-campaign-code.notifications.error.campaign-code-format', @@ -85,7 +83,6 @@ module('Unit | Component | update-campaign-code', function (hooks) { await component.updateCode(event); // then - assert.ok(notificationStub.clearAll.calledOnce); assert.ok( intlStub.calledWithExactly( 'components.administration.update-campaign-code.notifications.error.unique-code-error', @@ -105,7 +102,6 @@ module('Unit | Component | update-campaign-code', function (hooks) { await component.updateCode(event); // then - assert.ok(notificationStub.clearAll.calledOnce); assert.ok( intlStub.calledWithExactly( 'components.administration.update-campaign-code.notifications.error.campaign-id-error', @@ -125,7 +121,6 @@ module('Unit | Component | update-campaign-code', function (hooks) { await component.updateCode(event); // then - assert.ok(notificationStub.clearAll.calledOnce); assert.ok(intlStub.calledWithExactly('common.notifications.generic-error')); assert.ok(notificationStub.error.calledWithExactly(errorMsg)); }); @@ -141,7 +136,6 @@ module('Unit | Component | update-campaign-code', function (hooks) { await component.updateCode(event); // then - assert.ok(notificationStub.clearAll.calledOnce); assert.ok(intlStub.calledWithExactly('common.notifications.generic-error')); assert.ok(notificationStub.error.calledWithExactly(errorMsg)); }); From 6a9aa3fcf0f921d7762a93f175d9aa6675c27020 Mon Sep 17 00:00:00 2001 From: AndreiaPena Date: Mon, 18 Nov 2024 18:04:56 +0100 Subject: [PATCH 03/10] =?UTF-8?q?=F0=9F=94=A5=20admin:=20remove=20unused?= =?UTF-8?q?=20services?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/app/components/campaigns/participation-row.gjs | 1 - admin/app/components/certifications/issue-report.gjs | 1 - .../attach-badges/target-profile-selector/index.gjs | 1 - admin/app/components/organizations/list-items.gjs | 3 --- .../app/components/organizations/places-lot-creation-form.gjs | 4 ---- .../components/target-profiles/edit-target-profile-form.gjs | 4 ---- .../components/trainings/create-or-update-training-form.gjs | 3 --- admin/app/components/users/campaign-participations.gjs | 1 - .../users/certification-centers/membership-item.gjs | 2 -- 9 files changed, 20 deletions(-) diff --git a/admin/app/components/campaigns/participation-row.gjs b/admin/app/components/campaigns/participation-row.gjs index f95f1d16f08..aa87313cb81 100644 --- a/admin/app/components/campaigns/participation-row.gjs +++ b/admin/app/components/campaigns/participation-row.gjs @@ -10,7 +10,6 @@ import dayjsFormat from 'ember-dayjs/helpers/dayjs-format'; import { t } from 'ember-intl'; export default class ParticipationRow extends Component { - @service notifications; @service accessControl; @tracked isEditionMode = false; diff --git a/admin/app/components/certifications/issue-report.gjs b/admin/app/components/certifications/issue-report.gjs index d0930f1e088..cadc7ef487c 100644 --- a/admin/app/components/certifications/issue-report.gjs +++ b/admin/app/components/certifications/issue-report.gjs @@ -9,7 +9,6 @@ import { and, not, or } from 'ember-truth-helpers'; import CertificationIssueReportModal from './issue-reports/resolve-issue-report-modal'; export default class CertificationIssueReport extends Component { - @service notifications; @service accessControl; @tracked showResolveModal = false; diff --git a/admin/app/components/complementary-certifications/attach-badges/target-profile-selector/index.gjs b/admin/app/components/complementary-certifications/attach-badges/target-profile-selector/index.gjs index a0f0a7c5d65..d4404609d28 100644 --- a/admin/app/components/complementary-certifications/attach-badges/target-profile-selector/index.gjs +++ b/admin/app/components/complementary-certifications/attach-badges/target-profile-selector/index.gjs @@ -6,7 +6,6 @@ import Searchbar from 'pix-admin/components/complementary-certifications/attach- import SelectedTargetProfile from 'pix-admin/components/complementary-certifications/attach-badges/target-profile-selector/selected-target-profile'; export default class TargetProfileSelectorComponent extends Component { - @service notifications; @service store; @tracked attachableTargetProfiles = undefined; diff --git a/admin/app/components/organizations/list-items.gjs b/admin/app/components/organizations/list-items.gjs index a11e2719c5f..ebaf72094f5 100644 --- a/admin/app/components/organizations/list-items.gjs +++ b/admin/app/components/organizations/list-items.gjs @@ -5,15 +5,12 @@ import PixPagination from '@1024pix/pix-ui/components/pix-pagination'; import { fn } from '@ember/helper'; import { action } from '@ember/object'; import { LinkTo } from '@ember/routing'; -import { inject as service } from '@ember/service'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { t } from 'ember-intl'; import { not } from 'ember-truth-helpers'; export default class ActionsOnUsersRoleInOrganization extends Component { - @service notifications; - @tracked showModal = false; @tracked organizationToDetach; diff --git a/admin/app/components/organizations/places-lot-creation-form.gjs b/admin/app/components/organizations/places-lot-creation-form.gjs index 730448036d1..a34c3acbb9f 100644 --- a/admin/app/components/organizations/places-lot-creation-form.gjs +++ b/admin/app/components/organizations/places-lot-creation-form.gjs @@ -4,7 +4,6 @@ import PixInput from '@1024pix/pix-ui/components/pix-input'; import PixSelect from '@1024pix/pix-ui/components/pix-select'; import { on } from '@ember/modifier'; import { action } from '@ember/object'; -import { service } from '@ember/service'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import dayjs from 'dayjs'; @@ -22,9 +21,6 @@ const categories = [ ]; export default class PlacesLotCreationForm extends Component { - @service store; - @service notifications; - @service router; @tracked selectedCategory = null; @tracked count; diff --git a/admin/app/components/target-profiles/edit-target-profile-form.gjs b/admin/app/components/target-profiles/edit-target-profile-form.gjs index 53c278cc524..3f762ce9516 100644 --- a/admin/app/components/target-profiles/edit-target-profile-form.gjs +++ b/admin/app/components/target-profiles/edit-target-profile-form.gjs @@ -7,7 +7,6 @@ import PixTextarea from '@1024pix/pix-ui/components/pix-textarea'; import { fn } from '@ember/helper'; import { on } from '@ember/modifier'; import { action } from '@ember/object'; -import { service } from '@ember/service'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { t } from 'ember-intl'; @@ -17,9 +16,6 @@ import Card from '../card'; import TubesSelection from '../common/tubes-selection'; export default class CreateTargetProfileForm extends Component { - @service notifications; - @service router; - @tracked submitting = false; selectedTubes = []; diff --git a/admin/app/components/trainings/create-or-update-training-form.gjs b/admin/app/components/trainings/create-or-update-training-form.gjs index 35a38d6e673..6ea0a373a41 100644 --- a/admin/app/components/trainings/create-or-update-training-form.gjs +++ b/admin/app/components/trainings/create-or-update-training-form.gjs @@ -5,7 +5,6 @@ import PixSelect from '@1024pix/pix-ui/components/pix-select'; import { fn } from '@ember/helper'; import { on } from '@ember/modifier'; import { action } from '@ember/object'; -import { service } from '@ember/service'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { t } from 'ember-intl'; @@ -41,8 +40,6 @@ class Form { } export default class CreateOrUpdateTrainingForm extends Component { - @service notifications; - @tracked submitting = false; constructor() { diff --git a/admin/app/components/users/campaign-participations.gjs b/admin/app/components/users/campaign-participations.gjs index 072ff85eef9..63b5791cdb9 100644 --- a/admin/app/components/users/campaign-participations.gjs +++ b/admin/app/components/users/campaign-participations.gjs @@ -11,7 +11,6 @@ import ConfirmPopup from '../confirm-popup'; export default class CampaignParticipation extends Component { @service accessControl; - @service notifications; @tracked displayRemoveParticipationModal = false; @tracked participationToDelete = null; diff --git a/admin/app/components/users/certification-centers/membership-item.gjs b/admin/app/components/users/certification-centers/membership-item.gjs index 3e47746ec03..9b29638b0ba 100644 --- a/admin/app/components/users/certification-centers/membership-item.gjs +++ b/admin/app/components/users/certification-centers/membership-item.gjs @@ -9,8 +9,6 @@ import MembershipItemActions from './membership-item-actions'; import MembershipItemRole from './membership-item-role'; export default class UsersCertificationCentersMembershipItemComponent extends Component { - @service notifications; - @service store; @service intl; @tracked isEditionMode = false; From 82eaeb9378f155e6fbb3baa1158326aa4c9e240c Mon Sep 17 00:00:00 2001 From: AndreiaPena Date: Mon, 18 Nov 2024 17:58:01 +0100 Subject: [PATCH 04/10] =?UTF-8?q?=E2=9C=A8admin:=20use=20Pix=20Toast=20on?= =?UTF-8?q?=20access=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions-on-users-role-in-organization.gjs | 12 ++++--- .../access/anonymize-gar-import.gjs | 24 +++++++------ .../access/oidc-providers-import.gjs | 13 ++++--- .../add-organization-features-in-batch.gjs | 11 +++--- .../administration/deployment/new-tag.gjs | 8 ++--- .../deployment/organization-tags-import.gjs | 17 +++++---- .../deployment/organizations-import.gjs | 13 +++---- .../update-organizations-in-batch.gjs | 35 +++++++++---------- admin/app/components/layout/index.gjs | 5 +-- admin/app/components/team/add-member.gjs | 8 ++--- admin/app/components/team/list.gjs | 14 ++++---- .../user-detail-authentication-methods.gjs | 4 +-- .../user-detail-personal-information.gjs | 6 ++-- .../authentication-method.gjs | 8 +++-- admin/app/components/users/user-overview.gjs | 6 ++-- .../certification-centers/get.js | 16 +++++---- .../certification-centers/get/invitations.js | 8 ++--- .../certification-centers/get/team.js | 26 ++++++++------ .../authenticated/organizations/get.js | 12 +++---- .../organizations/get/children.js | 10 +++--- .../organizations/get/invitations.js | 11 +++--- .../authenticated/organizations/get/team.js | 12 +++---- .../users/get/authentication-methods.js | 22 ++++++------ .../get/certification-center-memberships.js | 28 +++++++-------- .../authenticated/organizations/get/team.js | 8 ++--- admin/translations/en.json | 3 ++ admin/translations/fr.json | 3 ++ 27 files changed, 182 insertions(+), 161 deletions(-) diff --git a/admin/app/components/actions-on-users-role-in-organization.gjs b/admin/app/components/actions-on-users-role-in-organization.gjs index 6e29015c03d..7cac60f1bfb 100644 --- a/admin/app/components/actions-on-users-role-in-organization.gjs +++ b/admin/app/components/actions-on-users-role-in-organization.gjs @@ -9,7 +9,7 @@ import { tracked } from '@glimmer/tracking'; import { t } from 'ember-intl'; export default class ActionsOnUsersRoleInOrganization extends Component { - @service notifications; + @service pixToast; @service accessControl; @service intl; @@ -37,9 +37,11 @@ export default class ActionsOnUsersRoleInOrganization extends Component { try { this.args.organizationMembership.organizationRole = this.selectedNewRole; await this.args.organizationMembership.save(); - this.notifications.success('Le rôle du membre a été mis à jour avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Le rôle du membre a été mis à jour avec succès.' }); } catch (e) { - this.notifications.error('Une erreur est survenue lors de la mise à jour du rôle du membre.'); + this.pixToast.sendErrorNotification({ + message: 'Une erreur est survenue lors de la mise à jour du rôle du membre.', + }); } finally { this.isEditionMode = false; } @@ -66,9 +68,9 @@ export default class ActionsOnUsersRoleInOrganization extends Component { async disableOrganizationMembership() { try { await this.args.organizationMembership.destroyRecord({ adapterOptions: { disable: true } }); - this.notifications.success('Le membre a été désactivé avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Le membre a été désactivé avec succès.' }); } catch (e) { - this.notifications.error('Une erreur est survenue lors de la désactivation du membre.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue lors de la désactivation du membre.' }); } finally { this.displayConfirm = false; } diff --git a/admin/app/components/administration/access/anonymize-gar-import.gjs b/admin/app/components/administration/access/anonymize-gar-import.gjs index 2f2893d13f3..d4eb37bc611 100644 --- a/admin/app/components/administration/access/anonymize-gar-import.gjs +++ b/admin/app/components/administration/access/anonymize-gar-import.gjs @@ -10,7 +10,7 @@ import AdministrationBlockLayout from '../block-layout'; export default class AnonymizeGarImport extends Component { @service intl; - @service notifications; + @service pixToast; @service session; @tracked isLoading = false; @@ -38,31 +38,33 @@ export default class AnonymizeGarImport extends Component { const { 'gar-anonymized-user-count': garAnonymizedUserCount, total } = json.data.attributes; if (garAnonymizedUserCount === total) { - return this.notifications.success( - this.intl.t('components.administration.anonymize-gar-import.notifications.success.full', { total }), - ); + return this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.anonymize-gar-import.notifications.success.full', { + total, + }), + }); } - return this.notifications.warning( - this.intl.t('components.administration.anonymize-gar-import.notifications.success.partial', { + return this.pixToast.sendWarningNotification({ + message: this.intl.t('components.administration.anonymize-gar-import.notifications.success.partial', { garAnonymizedUserCount, total, }), - ); + }); } const error = json.errors[0]; if (error.code === 'PAYLOAD_TOO_LARGE') { - return this.notifications.error( - this.intl.t('components.administration.anonymize-gar-import.notifications.error.payload-too-large', { + return this.pixToast.sendErrorNotification({ + message: this.intl.t('components.administration.anonymize-gar-import.notifications.error.payload-too-large', { maxSize: error.meta.maxSize, }), - ); + }); } this.errorResponseHandler.notify(await response.json()); } catch (error) { - this.notifications.error(this.intl.t('common.notifications.generic-error')); + this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } finally { this.isLoading = false; } diff --git a/admin/app/components/administration/access/oidc-providers-import.gjs b/admin/app/components/administration/access/oidc-providers-import.gjs index d806825d000..2008d5d5d49 100644 --- a/admin/app/components/administration/access/oidc-providers-import.gjs +++ b/admin/app/components/administration/access/oidc-providers-import.gjs @@ -10,12 +10,11 @@ import AdministrationBlockLayout from '../block-layout'; export default class OidcProvidersImport extends Component { @service intl; - @service notifications; + @service pixToast; @service session; @action async importOidcProviders(files) { - let response; try { const fileContent = files[0]; @@ -31,9 +30,9 @@ export default class OidcProvidersImport extends Component { body: fileContent, }); if (response.ok) { - this.notifications.success( - this.intl.t('components.administration.oidc-providers-import.notifications.success'), - ); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.oidc-providers-import.notifications.success'), + }); return; } @@ -43,10 +42,10 @@ export default class OidcProvidersImport extends Component { } jsonResponse.errors.forEach((error) => { - this.notifications.error(error.detail, { autoClear: false }); + this.pixToast.sendErrorNotification({ message: error.detail }); }); } catch (error) { - this.notifications.error(this.intl.t('common.notifications.generic-error')); + this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } finally { this.isLoading = false; } diff --git a/admin/app/components/administration/common/add-organization-features-in-batch.gjs b/admin/app/components/administration/common/add-organization-features-in-batch.gjs index b5a7a8bde2b..870a89ac468 100644 --- a/admin/app/components/administration/common/add-organization-features-in-batch.gjs +++ b/admin/app/components/administration/common/add-organization-features-in-batch.gjs @@ -9,13 +9,12 @@ import AdministrationBlockLayout from '../block-layout'; export default class AddOrganizationFeaturesInBatch extends Component { @service intl; - @service notifications; + @service pixToast; @service session; @service errorResponseHandler; @action async addOrganizationFeaturesInBatch(files) { - let response; try { const fileContent = files[0]; @@ -31,15 +30,15 @@ export default class AddOrganizationFeaturesInBatch extends Component { body: fileContent, }); if (response.ok) { - this.notifications.success( - this.intl.t('components.administration.add-organization-features-in-batch.notifications.success'), - ); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.add-organization-features-in-batch.notifications.success'), + }); return; } else { this.errorResponseHandler.notify(await response.json()); } } catch (error) { - this.notifications.error(this.intl.t('common.notifications.generic-error')); + this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } finally { this.isLoading = false; } diff --git a/admin/app/components/administration/deployment/new-tag.gjs b/admin/app/components/administration/deployment/new-tag.gjs index aba488f7a65..62478b51d55 100644 --- a/admin/app/components/administration/deployment/new-tag.gjs +++ b/admin/app/components/administration/deployment/new-tag.gjs @@ -10,7 +10,7 @@ import AdministrationBlockLayout from '../block-layout'; export default class NewTag extends Component { @service store; - @service notifications; + @service pixToast; @action async createNewTag(event) { @@ -21,15 +21,15 @@ export default class NewTag extends Component { tag = this.store.createRecord('tag', { name: this.tagName }); await tag.save(); - this.notifications.success('Le tag a bien été créé !'); + this.pixToast.sendSuccessNotification({ message: 'Le tag a bien été créé !' }); document.getElementById('tagNameInput').value = ''; } catch (response) { this.store.deleteRecord(tag); const status = get(response, 'errors[0].status'); if (status === '412') { - this.notifications.error('Ce tag existe déjà.'); + this.pixToast.sendErrorNotification({ message: 'Ce tag existe déjà.' }); } else { - this.notifications.error('Une erreur est survenue. Veuillez réessayer.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue. Veuillez réessayer.' }); } } } diff --git a/admin/app/components/administration/deployment/organization-tags-import.gjs b/admin/app/components/administration/deployment/organization-tags-import.gjs index 4af2f2bc911..b6181ab7530 100644 --- a/admin/app/components/administration/deployment/organization-tags-import.gjs +++ b/admin/app/components/administration/deployment/organization-tags-import.gjs @@ -9,13 +9,12 @@ import AdministrationBlockLayout from '../block-layout'; export default class OrganizationTagsImport extends Component { @service intl; - @service notifications; + @service pixToast; @service session; @service errorResponseHandler; @action async importOrganizationTags(files) { - let response; try { const fileContent = files[0]; @@ -31,28 +30,28 @@ export default class OrganizationTagsImport extends Component { body: fileContent, }); if (response.ok) { - this.notifications.success( - this.intl.t('components.administration.organization-tags-import.notifications.success'), - ); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.organization-tags-import.notifications.success'), + }); return; } else { const json = await response.json(); const error = json.errors[0]; if (error.code === 'TAG_NOT_FOUND') { - this.notifications.error( - this.intl.t( + this.pixToast.sendErrorNotification({ + message: this.intl.t( 'components.administration.organization-tags-import.notifications.errors.tag-not-found', error.meta, ), - ); + }); return; } this.errorResponseHandler.notify(json); } } catch (error) { - this.notifications.error(this.intl.t('common.notifications.generic-error')); + this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } finally { this.isLoading = false; } diff --git a/admin/app/components/administration/deployment/organizations-import.gjs b/admin/app/components/administration/deployment/organizations-import.gjs index 4e241af3245..0794aae5d1a 100644 --- a/admin/app/components/administration/deployment/organizations-import.gjs +++ b/admin/app/components/administration/deployment/organizations-import.gjs @@ -8,30 +8,31 @@ import AdministrationBlockLayout from '../block-layout'; export default class OrganizationsImport extends Component { @service intl; - @service notifications; + @service pixToast; @service router; @service store; @action async importOrganizations(files) { - const adapter = this.store.adapterFor('organizations-import'); try { await adapter.addOrganizationsCsv(files); - this.notifications.success(this.intl.t('components.administration.organizations-import.notifications.success')); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.organizations-import.notifications.success'), + }); } catch (errorResponse) { const errors = errorResponse.errors; if (!errors) { - return this.notifications.error(this.intl.t('common.notifications.generic-error')); + return this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } errors.forEach((error) => { switch (error.code) { case 'MISSING_REQUIRED_FIELD_NAMES': - this.notifications.error(`${error.meta}`, { autoClear: false }); + this.pixToast.sendErrorNotification({ message: `${error.meta}` }); break; default: - this.notifications.error(error.detail, { autoClear: false }); + this.pixToast.sendErrorNotification({ message: error.detail }); } }); } finally { diff --git a/admin/app/components/administration/deployment/update-organizations-in-batch.gjs b/admin/app/components/administration/deployment/update-organizations-in-batch.gjs index 85f4c268bd0..b94826170bd 100644 --- a/admin/app/components/administration/deployment/update-organizations-in-batch.gjs +++ b/admin/app/components/administration/deployment/update-organizations-in-batch.gjs @@ -9,13 +9,12 @@ import AdministrationBlockLayout from '../block-layout'; export default class UpdateOrganizationsInBatch extends Component { @service intl; - @service notifications; + @service pixToast; @service session; @service errorResponseHandler; @action async updateOrganizationsInBatch(files) { - let response; try { @@ -32,48 +31,48 @@ export default class UpdateOrganizationsInBatch extends Component { }); if (response.ok) { - this.notifications.success( - this.intl.t('components.administration.update-organizations-in-batch.notifications.success'), - ); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.update-organizations-in-batch.notifications.success'), + }); return; } else { const json = await response.json(); const error = json.errors[0]; if (error.code === 'ORGANIZATION_NOT_FOUND') { - return this.notifications.error( - this.intl.t( + return this.pixToast.sendErrorNotification({ + message: this.intl.t( 'components.administration.update-organizations-in-batch.notifications.errors.organization-not-found', error.meta, ), - ); + }); } else if (error.code === 'UNABLE_TO_ATTACH_CHILD_ORGANIZATION_TO_PARENT_ORGANIZATION') { - return this.notifications.error( - this.intl.t( + return this.pixToast.sendErrorNotification({ + message: this.intl.t( 'components.administration.update-organizations-in-batch.notifications.errors.parent-organization-not-found', error.meta, ), - ); + }); } else if (error.code === 'DPO_EMAIL_INVALID') { - return this.notifications.error( - this.intl.t( + return this.pixToast.sendErrorNotification({ + message: this.intl.t( 'components.administration.update-organizations-in-batch.notifications.errors.data-protection-email-invalid', error.meta, ), - ); + }); } else if (error.code === 'ORGANIZATION_BATCH_UPDATE_ERROR') { - return this.notifications.error( - this.intl.t( + return this.pixToast.sendErrorNotification({ + message: this.intl.t( 'components.administration.update-organizations-in-batch.notifications.errors.organization-batch-update-error', error.meta, ), - ); + }); } } this.errorResponseHandler.notify(await response.json()); } catch (error) { - this.notifications.error(this.intl.t('common.notifications.generic-error'), { autoClear: false }); + this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } finally { this.isLoading = false; } diff --git a/admin/app/components/layout/index.gjs b/admin/app/components/layout/index.gjs index 25e36cf0667..9d1a08ed6e5 100644 --- a/admin/app/components/layout/index.gjs +++ b/admin/app/components/layout/index.gjs @@ -1,5 +1,6 @@ -import NotificationContainer from '@1024pix/ember-cli-notifications/components/notification-container'; +import PixToastContainer from '@1024pix/pix-ui/components/pix-toast-container'; import { LinkTo } from '@ember/routing'; +import { t } from 'ember-intl'; import { pageTitle } from 'ember-page-title'; import MenuBar from './menu-bar'; @@ -23,7 +24,7 @@ import MenuBar from './menu-bar'; - + diff --git a/admin/app/components/team/add-member.gjs b/admin/app/components/team/add-member.gjs index 9b584e41839..f3001305688 100644 --- a/admin/app/components/team/add-member.gjs +++ b/admin/app/components/team/add-member.gjs @@ -11,7 +11,7 @@ import { t } from 'ember-intl'; import isEmailValid from '../../utils/email-validator'; export default class AddMember extends Component { - @service notifications; + @service pixToast; @service store; @service errorResponseHandler; @@ -45,9 +45,9 @@ export default class AddMember extends Component { await adminMember.save(); this.email = ''; this.role = 'SUPER_ADMIN'; - this.notifications.success( - `L'agent ${adminMember.firstName} ${adminMember.lastName} a dorénavant accès à Pix Admin`, - ); + this.pixToast.sendSuccessNotification({ + message: `L'agent ${adminMember.firstName} ${adminMember.lastName} a dorénavant accès à Pix Admin`, + }); } catch (errorResponse) { this.store.deleteRecord(adminMember); this.errorResponseHandler.notify(errorResponse, this.CUSTOM_ERROR_STATUS_MESSAGES); diff --git a/admin/app/components/team/list.gjs b/admin/app/components/team/list.gjs index dace3bbb97e..f4264d00d1c 100644 --- a/admin/app/components/team/list.gjs +++ b/admin/app/components/team/list.gjs @@ -12,7 +12,7 @@ import ConfirmPopup from '../confirm-popup'; export default class List extends Component { @service store; - @service notifications; + @service pixToast; @service errorResponseHandler; @tracked displayConfirm = false; @tracked editionMode = false; @@ -50,9 +50,9 @@ export default class List extends Component { try { await adminMember.save({ adapterOptions: { method: 'updateRole' } }); - this.notifications.success( - `L'agent ${adminMember.firstName} ${adminMember.lastName} a désormais le rôle ${adminMember.updatedRole}`, - ); + this.pixToast.sendSuccessNotification({ + message: `L'agent ${adminMember.firstName} ${adminMember.lastName} a désormais le rôle ${adminMember.updatedRole}`, + }); } catch (errorResponse) { this.errorResponseHandler.notify(errorResponse, this.CUSTOM_ERROR_STATUS_MESSAGES.UPDATE); adminMember.role = previousRole; @@ -69,9 +69,9 @@ export default class List extends Component { await this.adminMemberToDeactivate.save({ adapterOptions: { method: 'deactivate' } }); await this.args.refreshValues(); this.toggleDisplayConfirm(); - this.notifications.success( - `L'agent ${adminMemberToDeactivate.firstName} ${adminMemberToDeactivate.lastName} n'a plus accès à Pix Admin.`, - ); + this.pixToast.sendSuccessNotification({ + message: `L'agent ${adminMemberToDeactivate.firstName} ${adminMemberToDeactivate.lastName} n'a plus accès à Pix Admin.`, + }); } catch (errorResponse) { this.toggleDisplayConfirm(); diff --git a/admin/app/components/users/user-detail-authentication-methods.gjs b/admin/app/components/users/user-detail-authentication-methods.gjs index a1415b65634..4140f09d287 100644 --- a/admin/app/components/users/user-detail-authentication-methods.gjs +++ b/admin/app/components/users/user-detail-authentication-methods.gjs @@ -22,7 +22,7 @@ export default class UserDetailAuthenticationMethodsComponent extends Component @tracked isLoading = false; @tracked authenticationMethodType = null; - @service notifications; + @service pixToast; get translatedType() { return typesLabel[this.authenticationMethodType]; @@ -44,7 +44,7 @@ export default class UserDetailAuthenticationMethodsComponent extends Component if (get(response, 'errors[0].status') === '403') { errorMessage = 'Vous ne pouvez pas supprimer la dernière méthode de connexion de cet utilisateur'; } - this.notifications.error(errorMessage); + this.pixToast.sendErrorNotification({ message: errorMessage }); } finally { this.isLoading = false; this.toggleDisplayRemoveAuthenticationMethodModal(null); diff --git a/admin/app/components/users/user-detail-personal-information.gjs b/admin/app/components/users/user-detail-personal-information.gjs index 0f6fae92585..29cd0b58df6 100644 --- a/admin/app/components/users/user-detail-personal-information.gjs +++ b/admin/app/components/users/user-detail-personal-information.gjs @@ -12,7 +12,7 @@ export default class UserDetailPersonalInformationComponent extends Component { @tracked displayDissociateModal = false; @tracked isLoading = false; - @service notifications; + @service pixToast; organizationLearnerToDissociate = null; @@ -27,10 +27,10 @@ export default class UserDetailPersonalInformationComponent extends Component { this.isLoading = true; try { await this.organizationLearnerToDissociate.destroyRecord(); - this.notifications.success(DISSOCIATE_SUCCESS_NOTIFICATION_MESSAGE); + this.pixToast.sendSuccessNotification({ message: DISSOCIATE_SUCCESS_NOTIFICATION_MESSAGE }); } catch (response) { const errorMessage = 'Une erreur est survenue !'; - this.notifications.error(errorMessage); + this.pixToast.sendErrorNotification({ message: errorMessage }); } finally { this.displayDissociateModal = false; this.isLoading = false; diff --git a/admin/app/components/users/user-detail-personal-information/authentication-method.gjs b/admin/app/components/users/user-detail-personal-information/authentication-method.gjs index c6e9fc078e7..56a82eaaa98 100644 --- a/admin/app/components/users/user-detail-personal-information/authentication-method.gjs +++ b/admin/app/components/users/user-detail-personal-information/authentication-method.gjs @@ -13,7 +13,7 @@ import ReassignGarAuthenticationMethodModal from './reassign-gar-authentication- import ReassignOidcAuthenticationMethodModal from './reassign-oidc-authentication-method-modal'; export default class AuthenticationMethod extends Component { - @service notifications; + @service pixToast; @service accessControl; @service oidcIdentityProviders; @@ -116,7 +116,9 @@ export default class AuthenticationMethod extends Component { event.preventDefault(); try { await this.args.addPixAuthenticationMethod(this.newEmail); - this.notifications.success(`${this.newEmail} a bien été rajouté aux méthodes de connexion de l'utilisateur`); + this.pixToast.sendSuccessNotification({ + message: `${this.newEmail} a bien été rajouté aux méthodes de connexion de l'utilisateur`, + }); this.newEmail = ''; this.showAddAuthenticationMethodModal = false; this.showAlreadyExistingEmailError = false; @@ -130,7 +132,7 @@ export default class AuthenticationMethod extends Component { this.showAlreadyExistingEmailError = true; } else { this.showAddAuthenticationMethodModal = false; - this.notifications.error('Une erreur est survenue, veuillez réessayer.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue, veuillez réessayer.' }); this.newEmail = ''; this.showAlreadyExistingEmailError = false; } diff --git a/admin/app/components/users/user-overview.gjs b/admin/app/components/users/user-overview.gjs index f6248cfc789..34d91c6727e 100644 --- a/admin/app/components/users/user-overview.gjs +++ b/admin/app/components/users/user-overview.gjs @@ -24,7 +24,7 @@ import ConfirmPopup from '../confirm-popup'; export default class UserOverview extends Component { @service accessControl; @service intl; - @service notifications; + @service pixToast; @service references; @service store; @@ -139,13 +139,13 @@ export default class UserOverview extends Component { try { await this.args.user.save(); - this.notifications.success('L’utilisateur a été mis à jour avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'L’utilisateur a été mis à jour avec succès.' }); this.isEditionMode = false; } catch (response) { this.args.user.rollbackAttributes(); const messageValidationError = response.errors[0].detail || "une erreur est survenue, vos modifications n'ont pas été enregistrées"; - this.notifications.error(messageValidationError); + this.pixToast.sendErrorNotification({ message: messageValidationError }); } } diff --git a/admin/app/controllers/authenticated/certification-centers/get.js b/admin/app/controllers/authenticated/certification-centers/get.js index d14013d18ca..029f232111e 100644 --- a/admin/app/controllers/authenticated/certification-centers/get.js +++ b/admin/app/controllers/authenticated/certification-centers/get.js @@ -9,7 +9,7 @@ import { types } from '../../../models/certification-center'; export default class AuthenticatedCertificationCentersGetController extends Controller { certificationCenterTypes = types; - @service notifications; + @service pixToast; @service store; @service intl; @@ -25,14 +25,18 @@ export default class AuthenticatedCertificationCentersGetController extends Cont async updateCertificationCenter() { try { await this.model.certificationCenter.save(); - this.notifications.success('Centre de certification mis à jour avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Centre de certification mis à jour avec succès.' }); } catch (error) { if (get(error, 'errors[0].code') === 'PILOT_FEATURES_CONFLICT') { - return this.notifications.error( - this.intl.t('pages.certification-centers.notifications.update.errors.pilot-features-incompatibilities'), - ); + return this.pixToast.sendErrorNotification({ + message: this.intl.t( + 'pages.certification-centers.notifications.update.errors.pilot-features-incompatibilities', + ), + }); } - this.notifications.error("Une erreur est survenue, le centre de certification n'a pas été mis à jour."); + this.pixToast.sendErrorNotification({ + message: "Une erreur est survenue, le centre de certification n'a pas été mis à jour.", + }); } } } diff --git a/admin/app/controllers/authenticated/certification-centers/get/invitations.js b/admin/app/controllers/authenticated/certification-centers/get/invitations.js index 0bddedaebba..01d7fa5d5b2 100644 --- a/admin/app/controllers/authenticated/certification-centers/get/invitations.js +++ b/admin/app/controllers/authenticated/certification-centers/get/invitations.js @@ -7,7 +7,7 @@ import isEmailValid from '../../../../utils/email-validator'; export default class AuthenticatedCertificationCentersGetInvitationsController extends Controller { @service accessControl; - @service notifications; + @service pixToast; @service errorResponseHandler; @service store; @@ -41,7 +41,7 @@ export default class AuthenticatedCertificationCentersGetInvitationsController e certificationCenterId: this.model.certificationCenterId, }); - this.notifications.success(`Un email a bien a été envoyé à l'adresse ${email}.`); + this.pixToast.sendSuccessNotification({ message: `Un email a bien a été envoyé à l'adresse ${email}.` }); this.userEmailToInvite = null; } catch (err) { this.errorResponseHandler.notify(err, this.CUSTOM_ERROR_MESSAGES); @@ -72,9 +72,9 @@ export default class AuthenticatedCertificationCentersGetInvitationsController e certificationCenterInvitationId: certificationCenterInvitation.id, }, }); - this.notifications.success('Cette invitation a bien été annulée.'); + this.pixToast.sendSuccessNotification({ message: 'Cette invitation a bien été annulée.' }); } catch (error) { - this.notifications.error('Une erreur s’est produite, veuillez réessayer.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur s’est produite, veuillez réessayer.' }); } } } diff --git a/admin/app/controllers/authenticated/certification-centers/get/team.js b/admin/app/controllers/authenticated/certification-centers/get/team.js index d5d71372d48..e47c1c6d0c0 100644 --- a/admin/app/controllers/authenticated/certification-centers/get/team.js +++ b/admin/app/controllers/authenticated/certification-centers/get/team.js @@ -6,7 +6,7 @@ import { tracked } from '@glimmer/tracking'; import isEmailValid from '../../../../utils/email-validator'; export default class AuthenticatedCertificationCentersGetTeamController extends Controller { - @service notifications; + @service pixToast; @service errorResponseHandler; @service store; @service intl; @@ -52,7 +52,7 @@ export default class AuthenticatedCertificationCentersGetTeamController extends this.userEmailToAdd = null; this.send('refreshModel'); - this.notifications.success('Membre ajouté avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Membre ajouté avec succès.' }); } catch (responseError) { this.errorResponseHandler.notify(responseError, this.ERROR_MESSAGES); } @@ -64,9 +64,9 @@ export default class AuthenticatedCertificationCentersGetTeamController extends try { certificationCenterMembership.deleteRecord(); await certificationCenterMembership.save(); - this.notifications.success('Le membre a correctement été désactivé.'); - } catch (e) { - this.notifications.error("Une erreur est survenue, le membre n'a pas été désactivé."); + this.pixToast.sendSuccessNotification({ message: 'Le membre a correctement été désactivé.' }); + } catch (_) { + this.pixToast.sendErrorNotification({ message: "Une erreur est survenue, le membre n'a pas été désactivé." }); } } @@ -74,14 +74,18 @@ export default class AuthenticatedCertificationCentersGetTeamController extends async updateCertificationCenterMembershipRole(certificationCenterMembership) { try { await certificationCenterMembership.save(); - this.notifications.success( - this.intl.t('pages.certification-centers.notifications.success.update-certification-center-membership-role'), - ); + this.pixToast.sendSuccessNotification({ + message: this.intl.t( + 'pages.certification-centers.notifications.success.update-certification-center-membership-role', + ), + }); } catch (_) { certificationCenterMembership.rollbackAttributes(); - this.notifications.error( - this.intl.t('pages.certification-centers.notifications.failure.update-certification-center-membership-role'), - ); + this.pixToast.sendErrorNotification({ + message: this.intl.t( + 'pages.certification-centers.notifications.failure.update-certification-center-membership-role', + ), + }); } } diff --git a/admin/app/controllers/authenticated/organizations/get.js b/admin/app/controllers/authenticated/organizations/get.js index b3a09de7f59..88b69235391 100644 --- a/admin/app/controllers/authenticated/organizations/get.js +++ b/admin/app/controllers/authenticated/organizations/get.js @@ -4,7 +4,7 @@ import { service } from '@ember/service'; import get from 'lodash/get'; export default class GetController extends Controller { - @service notifications; + @service pixToast; @service router; @service accessControl; @service intl; @@ -13,7 +13,7 @@ export default class GetController extends Controller { async updateOrganizationInformation() { try { await this.model.save(); - this.notifications.success("L'organisation a bien été modifiée."); + this.pixToast.sendSuccessNotification({ message: "L'organisation a bien été modifiée." }); } catch (responseError) { this.model.rollbackAttributes(); const error = get(responseError, 'errors[0]'); @@ -27,7 +27,7 @@ export default class GetController extends Controller { default: message = this.intl.t(I18N_KEY_ERROR_MESSAGES['default']); } - this.notifications.error(message, { autoClear: false }); + this.pixToast.sendErrorNotification({ message }); } } @@ -36,14 +36,14 @@ export default class GetController extends Controller { try { await this.model.save({ adapterOptions: { archiveOrganization: true } }); - this.notifications.success('Cette organisation a bien été archivée.'); + this.pixToast.sendSuccessNotification({ message: 'Cette organisation a bien été archivée.' }); this.router.transitionTo('authenticated.organizations.get'); } catch (responseError) { const status = get(responseError, 'errors[0].status'); if (status === '422') { - return this.notifications.error("L'organisation n'a pas pu être archivée."); + return this.pixToast.sendErrorNotification({ message: "L'organisation n'a pas pu être archivée." }); } - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } } } diff --git a/admin/app/controllers/authenticated/organizations/get/children.js b/admin/app/controllers/authenticated/organizations/get/children.js index 5e8f624d8fa..d6c15a0e480 100644 --- a/admin/app/controllers/authenticated/organizations/get/children.js +++ b/admin/app/controllers/authenticated/organizations/get/children.js @@ -6,7 +6,7 @@ import get from 'lodash/get'; export default class AuthenticatedOrganizationsGetChildrenController extends Controller { @service accessControl; @service intl; - @service notifications; + @service pixToast; @service store; @action @@ -16,9 +16,9 @@ export default class AuthenticatedOrganizationsGetChildrenController extends Con try { await organizationAdapter.attachChildOrganization({ childOrganizationId, parentOrganizationId }); - this.notifications.success( - this.intl.t('pages.organization-children.notifications.success.attach-child-organization'), - ); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('pages.organization-children.notifications.success.attach-child-organization'), + }); await this.model.organization.hasMany('children').reload(); } catch (responseError) { @@ -54,7 +54,7 @@ export default class AuthenticatedOrganizationsGetChildrenController extends Con message = this.intl.t('common.notifications.generic-error'); } - this.notifications.error(message); + this.pixToast.sendErrorNotification({ message }); } } } diff --git a/admin/app/controllers/authenticated/organizations/get/invitations.js b/admin/app/controllers/authenticated/organizations/get/invitations.js index 8b0f5125d2a..d4babd0649a 100644 --- a/admin/app/controllers/authenticated/organizations/get/invitations.js +++ b/admin/app/controllers/authenticated/organizations/get/invitations.js @@ -10,7 +10,7 @@ export default class InvitationsController extends Controller { @tracked userEmailToInviteError; @tracked email = null; - @service notifications; + @service pixToast; @service store; @service accessControl; @service errorResponseHandler; @@ -37,7 +37,9 @@ export default class InvitationsController extends Controller { organizationId: this.model.organization.id, }); - this.notifications.success(`Un email a bien a été envoyé à l'adresse ${organizationInvitation.email}.`); + this.pixToast.sendSuccessNotification({ + message: `Un email a bien a été envoyé à l'adresse ${organizationInvitation.email}.`, + }); this.userEmailToInvite = null; } catch (err) { this.errorResponseHandler.notify(err, this.CUSTOM_ERROR_MESSAGES); @@ -74,10 +76,9 @@ export default class InvitationsController extends Controller { organizationId: this.model.organization.id, }, }); - this.notifications.success(`Cette invitation a bien été annulée.`); + this.pixToast.sendSuccessNotification({ message: `Cette invitation a bien été annulée.` }); } catch (error) { - console.error(error); - this.notifications.error('Une erreur s’est produite, veuillez réessayer.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur s’est produite, veuillez réessayer.' }); } } } diff --git a/admin/app/controllers/authenticated/organizations/get/team.js b/admin/app/controllers/authenticated/organizations/get/team.js index 3f6fac39320..e3ce441e2ea 100644 --- a/admin/app/controllers/authenticated/organizations/get/team.js +++ b/admin/app/controllers/authenticated/organizations/get/team.js @@ -21,7 +21,7 @@ export default class GetTeamController extends Controller { @tracked organizationRole = null; @service accessControl; - @service notifications; + @service pixToast; @service store; updateFilters(filters) { @@ -54,11 +54,11 @@ export default class GetTeamController extends Controller { const email = this.userEmailToAdd.trim(); const user = await this._getUser(email); if (!user) { - return this.notifications.error('Compte inconnu.'); + return this.pixToast.sendErrorNotification({ message: 'Compte inconnu.' }); } if (await organization.hasMember(user.id)) { - return this.notifications.error('Compte déjà associé.'); + return this.pixToast.sendErrorNotification({ message: 'Compte déjà associé.' }); } try { @@ -76,9 +76,9 @@ export default class GetTeamController extends Controller { }); this.userEmailToAdd = null; - this.notifications.success('Accès attribué avec succès.'); - } catch (e) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendSuccessNotification({ message: 'Accès attribué avec succès.' }); + } catch (_) { + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } } diff --git a/admin/app/controllers/authenticated/users/get/authentication-methods.js b/admin/app/controllers/authenticated/users/get/authentication-methods.js index c33bb6bc4db..e82241c354b 100644 --- a/admin/app/controllers/authenticated/users/get/authentication-methods.js +++ b/admin/app/controllers/authenticated/users/get/authentication-methods.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class UserAuthenticationMethodsController extends Controller { - @service notifications; + @service pixToast; @service oidcIdentityProviders; ERROR_MESSAGES = { @@ -46,10 +46,12 @@ export default class UserAuthenticationMethodsController extends Controller { identityProvider, }, }); - this.notifications.success(`La méthode de connexion a bien été déplacé vers l'utilisateur ${targetUserId}`); - this.notifications.success( - `L'utilisateur n'a plus de méthode de connexion ${reassignedAuthenticationMethodLabel}`, - ); + this.pixToast.sendSuccessNotification({ + message: `La méthode de connexion a bien été déplacé vers l'utilisateur ${targetUserId}`, + }); + this.pixToast.sendSuccessNotification({ + message: `L'utilisateur n'a plus de méthode de connexion ${reassignedAuthenticationMethodLabel}`, + }); } catch (errors) { authenticationMethod.rollbackAttributes(); this._handleResponseError(errors, identityProvider); @@ -63,21 +65,21 @@ export default class UserAuthenticationMethodsController extends Controller { errors.map((error) => { switch (error.status) { case '400': - this.notifications.error(this.ERROR_MESSAGES.STATUS_400); + this.pixToast.sendErrorNotification({ message: this.ERROR_MESSAGES.STATUS_400 }); break; case '404': - this.notifications.error(this.ERROR_MESSAGES.STATUS_404); + this.pixToast.sendErrorNotification({ message: this.ERROR_MESSAGES.STATUS_404 }); break; case '422': - this.notifications.error(this.ERROR_MESSAGES.STATUS_422[identityProvider]); + this.pixToast.sendErrorNotification({ message: this.ERROR_MESSAGES.STATUS_422[identityProvider] }); break; default: - this.notifications.error(this.ERROR_MESSAGES.DEFAULT); + this.pixToast.sendErrorNotification({ message: this.ERROR_MESSAGES.DEFAULT }); break; } }); } else { - this.notifications.error(this.ERROR_MESSAGES.DEFAULT); + this.pixToast.sendErrorNotification({ message: this.ERROR_MESSAGES.DEFAULT }); } } } diff --git a/admin/app/controllers/authenticated/users/get/certification-center-memberships.js b/admin/app/controllers/authenticated/users/get/certification-center-memberships.js index cf433ebf7c6..16da37d73a1 100644 --- a/admin/app/controllers/authenticated/users/get/certification-center-memberships.js +++ b/admin/app/controllers/authenticated/users/get/certification-center-memberships.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class UsersCertificationCenterMembershipsController extends Controller { - @service notifications; + @service pixToast; @service store; @service intl; @@ -11,14 +11,14 @@ export default class UsersCertificationCenterMembershipsController extends Contr async updateCertificationCenterMembershipRole(certificationCenterMembership) { try { await certificationCenterMembership.save(); - this.notifications.success( - this.intl.t('pages.user-details.notifications.success.update-certification-center-membership-role'), - ); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('pages.user-details.notifications.success.update-certification-center-membership-role'), + }); } catch (_) { certificationCenterMembership.rollbackAttributes(); - this.notifications.error( - this.intl.t('pages.user-details.notifications.failure.update-certification-center-membership-role'), - ); + this.pixToast.sendErrorNotification({ + message: this.intl.t('pages.user-details.notifications.failure.update-certification-center-membership-role'), + }); } } @@ -26,13 +26,13 @@ export default class UsersCertificationCenterMembershipsController extends Contr async disableCertificationCenterMembership(certificationCenterMembership) { try { await certificationCenterMembership.destroyRecord(); - this.notifications.success( - this.intl.t('pages.user-details.notifications.success.deactivate-certification-center-membership'), - ); - } catch (e) { - this.notifications.error( - this.intl.t('pages.user-details.notifications.failure.deactivate-certification-center-membership'), - ); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('pages.user-details.notifications.success.deactivate-certification-center-membership'), + }); + } catch (_) { + this.pixToast.sendErrorNotification({ + message: this.intl.t('pages.user-details.notifications.failure.deactivate-certification-center-membership'), + }); } } } diff --git a/admin/app/routes/authenticated/organizations/get/team.js b/admin/app/routes/authenticated/organizations/get/team.js index 43f0514d262..09d9c497f8d 100644 --- a/admin/app/routes/authenticated/organizations/get/team.js +++ b/admin/app/routes/authenticated/organizations/get/team.js @@ -4,7 +4,7 @@ import RSVP from 'rsvp'; export default class OrganizationTeamRoute extends Route { @service router; - @service notifications; + @service pixToast; queryParams = { pageNumber: { refreshModel: true }, @@ -68,15 +68,15 @@ export default class OrganizationTeamRoute extends Route { errors.map((error) => { switch (error.code) { case 403: - this.notifications.error(this.ERROR_MESSAGES.STATUS_403); + this.pixToast.sendErrorNotification({ message: this.ERROR_MESSAGES.STATUS_403 }); break; default: - this.notifications.error(this.ERROR_MESSAGES.DEFAULT); + this.pixToast.sendErrorNotification({ message: this.ERROR_MESSAGES.DEFAULT }); break; } }); } else { - this.notifications.error(this.ERROR_MESSAGES.DEFAULT); + this.pixToast.sendErrorNotification({ message: this.ERROR_MESSAGES.DEFAULT }); } } } diff --git a/admin/translations/en.json b/admin/translations/en.json index 72c8123ce5e..3a289b75e85 100644 --- a/admin/translations/en.json +++ b/admin/translations/en.json @@ -56,6 +56,9 @@ "mandatory-fields": "The fields marked ''*'' are required" }, "notifications": { + "close-button": { + "extra-information": "Close notification" + }, "generic-error": "An error occurred." }, "roles": { diff --git a/admin/translations/fr.json b/admin/translations/fr.json index 4e80b7680d5..a30970f1b4b 100644 --- a/admin/translations/fr.json +++ b/admin/translations/fr.json @@ -56,6 +56,9 @@ "mandatory-fields": "Les champs marqués de ''*'' sont obligatoires" }, "notifications": { + "close-button": { + "extra-information": "Fermer la notification" + }, "generic-error": "Une erreur est survenue." }, "roles": { From d18f44628c8ae69eb25eb94ab30027c4c5a777a9 Mon Sep 17 00:00:00 2001 From: AndreiaPena Date: Mon, 18 Nov 2024 18:00:22 +0100 Subject: [PATCH 05/10] =?UTF-8?q?=E2=9C=A8=20admin:=20use=20Pix=20Toast=20?= =?UTF-8?q?on=20certification=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../certification-scoring-configuration.gjs | 8 ++-- .../competence-scoring-configuration.gjs | 8 ++-- .../flash-algorithm-configuration/index.gjs | 6 +-- .../sco-whitelist-configuration.gjs | 14 +++++-- .../attach-badges/index.gjs | 10 ++--- .../certification-centers/new.js | 6 +-- .../certification/informations.js | 37 +++++++++---------- .../certification/neutralization.js | 26 +++++++------ .../attach-target-profile/new.js | 10 ++--- .../sessions/list/to-be-published.js | 22 +++++------ .../sessions/session/certifications.js | 11 +++--- .../sessions/session/informations.js | 24 +++++++----- .../get-next-challenge.js | 12 +++--- .../complementary-certifications/list.js | 5 ++- 14 files changed, 107 insertions(+), 92 deletions(-) diff --git a/admin/app/components/administration/certification/certification-scoring-configuration.gjs b/admin/app/components/administration/certification/certification-scoring-configuration.gjs index 4181f2fe473..a055a1bc520 100644 --- a/admin/app/components/administration/certification/certification-scoring-configuration.gjs +++ b/admin/app/components/administration/certification/certification-scoring-configuration.gjs @@ -10,7 +10,7 @@ import AdministrationBlockLayout from '../block-layout'; export default class CertificationScoringConfiguration extends Component { @service store; - @service notifications; + @service pixToast; certificationScoringConfiguration = ''; @action @@ -24,9 +24,9 @@ export default class CertificationScoringConfiguration extends Component { const adapter = this.store.adapterFor('scoring-configuration'); try { await adapter.updateCertificationScoringConfiguration(this.certificationScoringConfiguration); - this.notifications.success('Configuration enregistrée'); - } catch (e) { - this.notifications.error("La config n'a pas pu être ajoutée"); + this.pixToast.sendSuccessNotification({ message: 'Configuration enregistrée' }); + } catch (_) { + this.pixToast.sendErrorNotification({ message: "La config n'a pas pu être ajoutée" }); } } diff --git a/admin/app/components/administration/certification/competence-scoring-configuration.gjs b/admin/app/components/administration/certification/competence-scoring-configuration.gjs index a58f835f79e..6fabeb216ac 100644 --- a/admin/app/components/administration/certification/competence-scoring-configuration.gjs +++ b/admin/app/components/administration/certification/competence-scoring-configuration.gjs @@ -10,7 +10,7 @@ import AdministrationBlockLayout from '../block-layout'; export default class CompetenceScoringConfiguration extends Component { @service store; - @service notifications; + @service pixToast; competenceScoringConfiguration = ''; @action @@ -24,9 +24,9 @@ export default class CompetenceScoringConfiguration extends Component { const adapter = this.store.adapterFor('scoring-configuration'); try { await adapter.updateCompetenceScoringConfiguration(this.competenceScoringConfiguration); - this.notifications.success('Configuration enregistrée'); - } catch (e) { - this.notifications.error("La config n'a pas pu être ajoutée"); + this.pixToast.sendSuccessNotification({ message: 'Configuration enregistrée' }); + } catch (_) { + this.pixToast.sendErrorNotification({ message: "La config n'a pas pu être ajoutée" }); } } diff --git a/admin/app/components/administration/certification/flash-algorithm-configuration/index.gjs b/admin/app/components/administration/certification/flash-algorithm-configuration/index.gjs index 02cedd3e147..342a35e5a35 100644 --- a/admin/app/components/administration/certification/flash-algorithm-configuration/index.gjs +++ b/admin/app/components/administration/certification/flash-algorithm-configuration/index.gjs @@ -9,7 +9,7 @@ import Form from './form'; export default class FlashAlgorithmConfiguration extends Component { @service store; - @service notifications; + @service pixToast; @tracked form = { maximumAssessmentLength: this.args.model.maximumAssessmentLength, warmUpLength: this.args.model.warmUpLength, @@ -27,9 +27,9 @@ export default class FlashAlgorithmConfiguration extends Component { const adapter = this.store.adapterFor('flash-algorithm-configuration'); try { await adapter.createRecord(this.form); - this.notifications.success('La configuration a été créée'); + this.pixToast.sendSuccessNotification({ message: 'La configuration a été créée' }); } catch (errorResponse) { - this.notifications.error("La configuration n'a pu être créée"); + this.pixToast.sendErrorNotification({ message: "La configuration n'a pu être créée" }); } } diff --git a/admin/app/components/administration/certification/sco-whitelist-configuration.gjs b/admin/app/components/administration/certification/sco-whitelist-configuration.gjs index 0eaa203705d..490807fd067 100644 --- a/admin/app/components/administration/certification/sco-whitelist-configuration.gjs +++ b/admin/app/components/administration/certification/sco-whitelist-configuration.gjs @@ -11,7 +11,7 @@ import AdministrationBlockLayout from '../block-layout'; export default class ScoWhitelistConfiguration extends Component { @service intl; @service session; - @service notifications; + @service pixToast; @action async importScoWhitelist(files) { @@ -29,12 +29,18 @@ export default class ScoWhitelistConfiguration extends Component { body: fileContent, }); if (response.ok) { - this.notifications.success(this.intl.t('pages.administration.certification.sco-whitelist.import.success')); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('pages.administration.certification.sco-whitelist.import.success'), + }); } else { - this.notifications.error(this.intl.t('pages.administration.certification.sco-whitelist.import.error')); + this.pixToast.sendErrorNotification({ + message: this.intl.t('pages.administration.certification.sco-whitelist.import.error'), + }); } } catch (error) { - this.notifications.error(this.intl.t('pages.administration.certification.sco-whitelist.import.error')); + this.pixToast.sendErrorNotification({ + message: this.intl.t('pages.administration.certification.sco-whitelist.import.error'), + }); } finally { this.isLoading = false; } diff --git a/admin/app/components/complementary-certifications/attach-badges/index.gjs b/admin/app/components/complementary-certifications/attach-badges/index.gjs index 9af5e4fa766..67aafb679c4 100644 --- a/admin/app/components/complementary-certifications/attach-badges/index.gjs +++ b/admin/app/components/complementary-certifications/attach-badges/index.gjs @@ -17,7 +17,7 @@ import TargetProfileSelector from './target-profile-selector'; const DEFAULT_BADGE_LEVEL = '1'; export default class AttachBadges extends Component { - @service notifications; + @service pixToast; @service router; @service store; @@ -35,7 +35,7 @@ export default class AttachBadges extends Component { @action async onError(errorMessage) { if (errorMessage) { - this.notifications.error(errorMessage); + this.pixToast.sendErrorNotification({ message: errorMessage }); } } @@ -110,9 +110,9 @@ export default class AttachBadges extends Component { this.router.transitionTo('authenticated.complementary-certifications.complementary-certification.details'); - this.notifications.success( - `Profil cible rattaché à la certification ${complementaryCertification.label} mis à jour avec succès !`, - ); + this.pixToast.sendSuccessNotification({ + message: `Profil cible rattaché à la certification ${complementaryCertification.label} mis à jour avec succès !`, + }); } catch (error) { console.error({ error }); await this.onError("Une erreur est survenue lors de l'enregistrement du profil cible."); diff --git a/admin/app/controllers/authenticated/certification-centers/new.js b/admin/app/controllers/authenticated/certification-centers/new.js index 83387290a05..b2492381520 100644 --- a/admin/app/controllers/authenticated/certification-centers/new.js +++ b/admin/app/controllers/authenticated/certification-centers/new.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class NewController extends Controller { - @service notifications; + @service pixToast; @service router; @action @@ -22,10 +22,10 @@ export default class NewController extends Controller { try { await certificationCenter.save(); - this.notifications.success('Le centre de certification a été créé avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Le centre de certification a été créé avec succès.' }); this.router.transitionTo('authenticated.certification-centers.get', certificationCenter.id); } catch (error) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } } } diff --git a/admin/app/controllers/authenticated/certifications/certification/informations.js b/admin/app/controllers/authenticated/certifications/certification/informations.js index dd43c36d6da..5cbec156502 100644 --- a/admin/app/controllers/authenticated/certifications/certification/informations.js +++ b/admin/app/controllers/authenticated/certifications/certification/informations.js @@ -16,7 +16,7 @@ export default class CertificationInformationsController extends Controller { // Properties @alias('model.certification') certification; @alias('model.countries') countries; - @service notifications; + @service pixToast; @service intl; @tracked displayConfirm = false; @@ -80,9 +80,9 @@ export default class CertificationInformationsController extends Controller { async resolveIssueReport(issueReport, resolutionLabel) { try { await issueReport.save({ adapterOptions: { resolutionLabel } }); - this.notifications.success('Le signalement a été résolu.'); + this.pixToast.sendSuccessNotification({ message: 'Le signalement a été résolu.' }); } catch (error) { - this.notifications.error('Une erreur est survenue :\n' + error?.errors[0]?.detail); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue :\n' + error?.errors[0]?.detail }); } await this.certification.reload(); } @@ -98,8 +98,7 @@ export default class CertificationInformationsController extends Controller { } async saveCertificationCourse() { - const save = await this.certification.save({ adapterOptions: { updateJuryComment: false } }); - return save; + return await this.certification.save({ adapterOptions: { updateJuryComment: false } }); } @action @@ -164,7 +163,7 @@ export default class CertificationInformationsController extends Controller { await this.certification.save({ adapterOptions: { isCertificationCancel: true } }); await this.certification.reload(); } catch (error) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } this.displayConfirm = false; @@ -176,7 +175,7 @@ export default class CertificationInformationsController extends Controller { await this.certification.save({ adapterOptions: { isCertificationUncancel: true } }); await this.certification.reload(); } catch (error) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } this.displayConfirm = false; @@ -188,7 +187,7 @@ export default class CertificationInformationsController extends Controller { await this.certification.save({ adapterOptions: { isCertificationReject: true } }); await this.certification.reload(); } catch (error) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } this.displayConfirm = false; @@ -200,7 +199,7 @@ export default class CertificationInformationsController extends Controller { await this.certification.save({ adapterOptions: { isCertificationUnreject: true } }); await this.certification.reload(); } catch (error) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } this.displayConfirm = false; @@ -210,17 +209,17 @@ export default class CertificationInformationsController extends Controller { async onCandidateInformationSave() { try { await this.saveCertificationCourse(); - this.notifications.success('Les informations du candidat ont bien été enregistrées.'); + this.pixToast.sendSuccessNotification({ message: 'Les informations du candidat ont bien été enregistrées.' }); this.isCandidateEditModalOpen = false; - } catch (e) { - if (e.errors && e.errors.length > 0) { - e.errors.forEach((error) => { - this.notifications.error(error.detail); + } catch (error) { + if (error.errors && error.errors.length > 0) { + error.errors.forEach((error) => { + this.pixToast.sendErrorNotification({ message: error.detail }); }); } else { - this.notifications.error(e); + this.pixToast.sendErrorNotification({ message: error }); } - throw e; + throw error; } } @@ -228,10 +227,10 @@ export default class CertificationInformationsController extends Controller { async onJuryCommentSave(commentByJury) { try { await this.saveAssessmentResult(commentByJury); - this.notifications.success('Le commentaire du jury a bien été enregistré.'); + this.pixToast.sendSuccessNotification({ message: 'Le commentaire du jury a bien été enregistré.' }); return true; - } catch (e) { - this.notifications.error("Le commentaire du jury n'a pas pu être enregistré."); + } catch (_) { + this.pixToast.sendErrorNotification({ message: "Le commentaire du jury n'a pas pu être enregistré." }); return false; } } diff --git a/admin/app/controllers/authenticated/certifications/certification/neutralization.js b/admin/app/controllers/authenticated/certifications/certification/neutralization.js index e18169f2f53..62be2ecddaa 100644 --- a/admin/app/controllers/authenticated/certifications/certification/neutralization.js +++ b/admin/app/controllers/authenticated/certifications/certification/neutralization.js @@ -6,7 +6,7 @@ import { service } from '@ember/service'; export default class NeutralizationController extends Controller { @alias('model') certificationDetails; - @service notifications; + @service pixToast; @service accessControl; @action @@ -20,11 +20,13 @@ export default class NeutralizationController extends Controller { }, }); this._updateModel(challengeRecId, true); - return this.notifications.success(`La question n°${questionIndex} a été neutralisée avec succès.`); - } catch (e) { - return this.notifications.error( - `Une erreur est survenue lors de la neutralisation de la question n°${questionIndex}.`, - ); + return this.pixToast.sendSuccessNotification({ + message: `La question n°${questionIndex} a été neutralisée avec succès.`, + }); + } catch (_) { + return this.pixToast.sendErrorNotification({ + message: `Une erreur est survenue lors de la neutralisation de la question n°${questionIndex}.`, + }); } } @@ -39,11 +41,13 @@ export default class NeutralizationController extends Controller { }, }); this._updateModel(challengeRecId, false); - return this.notifications.success(`La question n°${questionIndex} a été dé-neutralisée avec succès.`); - } catch (e) { - return this.notifications.error( - `Une erreur est survenue lors de la dé-neutralisation de la question n°${questionIndex}.`, - ); + return this.pixToast.sendSuccessNotification({ + message: `La question n°${questionIndex} a été dé-neutralisée avec succès.`, + }); + } catch (_) { + return this.pixToast.sendErrorNotification({ + message: `Une erreur est survenue lors de la dé-neutralisation de la question n°${questionIndex}.`, + }); } } diff --git a/admin/app/controllers/authenticated/complementary-certifications/complementary-certification/attach-target-profile/new.js b/admin/app/controllers/authenticated/complementary-certifications/complementary-certification/attach-target-profile/new.js index 9517ac4e001..0e68bf1fb81 100644 --- a/admin/app/controllers/authenticated/complementary-certifications/complementary-certification/attach-target-profile/new.js +++ b/admin/app/controllers/authenticated/complementary-certifications/complementary-certification/attach-target-profile/new.js @@ -6,7 +6,7 @@ import { tracked } from '@glimmer/tracking'; const DEFAULT_BADGE_LEVEL = '1'; export default class AttachTargetProfileController extends Controller { - @service notifications; + @service pixToast; @service router; @service store; @@ -24,7 +24,7 @@ export default class AttachTargetProfileController extends Controller { @action async onError(errorMessage) { if (errorMessage) { - this.notifications.error(errorMessage); + this.pixToast.sendErrorNotification({ message: errorMessage }); } } @@ -99,9 +99,9 @@ export default class AttachTargetProfileController extends Controller { this.router.transitionTo('authenticated.complementary-certifications.complementary-certification.details'); - this.notifications.success( - `Profil cible rattaché à la certification ${complementaryCertification.label} mis à jour avec succès !`, - ); + this.pixToast.sendSuccessNotification({ + message: `Profil cible rattaché à la certification ${complementaryCertification.label} mis à jour avec succès !`, + }); } catch (error) { console.error({ error }); await this.onError("Une erreur est survenue lors de l'enregistrement du profil cible."); diff --git a/admin/app/controllers/authenticated/sessions/list/to-be-published.js b/admin/app/controllers/authenticated/sessions/list/to-be-published.js index 8c1afb1221f..fa1353acbb0 100644 --- a/admin/app/controllers/authenticated/sessions/list/to-be-published.js +++ b/admin/app/controllers/authenticated/sessions/list/to-be-published.js @@ -5,7 +5,7 @@ import { tracked } from '@glimmer/tracking'; import get from 'lodash/get'; export default class SessionToBePublishedController extends Controller { - @service notifications; + @service pixToast; @service store; @service accessControl; @tracked shouldShowModal = false; @@ -16,9 +16,9 @@ export default class SessionToBePublishedController extends Controller { try { await adapter.publishSession(toBePublishedSession.id); this.send('refreshModel'); - } catch (err) { - const finalErr = get(err, 'errors[0].detail', err); - this.notifications.error(finalErr); + } catch (error) { + const errorMessage = get(error, 'errors[0].detail', error); + this.pixToast.sendErrorNotification({ message: errorMessage }); } } @@ -33,10 +33,10 @@ export default class SessionToBePublishedController extends Controller { this.send('refreshModel'); } else { this._removePublishedSessionsFromStore(this.model); - this.notifications.success('Les sessions ont été publiées avec succès'); + this.pixToast.sendSuccessNotification({ message: 'Les sessions ont été publiées avec succès' }); } - } catch (err) { - this.notifications.error(err); + } catch (error) { + this.pixToast.sendErrorNotification({ message: error }); } this.hideConfirmModal(); } @@ -52,11 +52,11 @@ export default class SessionToBePublishedController extends Controller { } _notifyPublicationFailure(error) { - this.notifications.error( - "Une ou plusieurs erreurs se sont produites, veuillez conserver la référence suivante pour investigation auprès de l'équipe technique : " + + this.pixToast.sendErrorNotification({ + message: + "Une ou plusieurs erreurs se sont produites, veuillez conserver la référence suivante pour investigation auprès de l'équipe technique : " + get(error, 'errors[0].detail'), - { autoClear: false }, - ); + }); } _batchPublicationFailed(error) { diff --git a/admin/app/controllers/authenticated/sessions/session/certifications.js b/admin/app/controllers/authenticated/sessions/session/certifications.js index 526eff3062f..0e194062197 100644 --- a/admin/app/controllers/authenticated/sessions/session/certifications.js +++ b/admin/app/controllers/authenticated/sessions/session/certifications.js @@ -5,7 +5,7 @@ import { tracked } from '@glimmer/tracking'; const DEFAULT_PAGE_NUMBER = 1; export default class ListController extends Controller { - @service notifications; + @service pixToast; @service store; @service accessControl; @@ -58,7 +58,7 @@ export default class ListController extends Controller { try { await this.model.session.save({ adapterOptions: { updatePublishedCertifications: true, toPublish: false } }); await this.model.juryCertificationSummaries.reload(); - this.notifications.success('Les certifications ont été correctement dépubliées.'); + this.pixToast.sendSuccessNotification({ message: 'Les certifications ont été correctement dépubliées.' }); } catch (e) { this.notifyError(e); } @@ -75,17 +75,16 @@ export default class ListController extends Controller { await this.model.juryCertificationSummaries.reload(); if (this.model.session.isPublished) { - this.notifications.success('Les certifications ont été correctement publiées.'); + this.pixToast.sendSuccessNotification({ message: 'Les certifications ont été correctement publiées.' }); } this.hideConfirmationModal(); } notifyError(error) { if (error.errors && error.errors[0] && error.errors[0].detail) { - const autoClear = error.errors[0].status != 503; - this.notifications.error(error.errors[0].detail, { autoClear }); + this.pixToast.sendErrorNotification({ message: error.errors[0].detail }); } else { - this.notifications.error(error); + this.pixToast.sendErrorNotification({ message: error }); } } diff --git a/admin/app/controllers/authenticated/sessions/session/informations.js b/admin/app/controllers/authenticated/sessions/session/informations.js index 91c752772d8..1868bd80d02 100644 --- a/admin/app/controllers/authenticated/sessions/session/informations.js +++ b/admin/app/controllers/authenticated/sessions/session/informations.js @@ -8,7 +8,7 @@ import { tracked } from '@glimmer/tracking'; import { statusToDisplayName } from '../../../../models/session'; export default class IndexController extends Controller { - @service notifications; + @service pixToast; @service currentUser; @service accessControl; @service session; @@ -50,9 +50,9 @@ export default class IndexController extends Controller { try { await this.sessionModel.save({ adapterOptions: { unfinalize: true } }); await this.sessionModel.reload(); - this.notifications.success('La session a bien été définalisée'); + this.pixToast.sendSuccessNotification({ message: 'La session a bien été définalisée' }); } catch (err) { - this.notifications.error('Erreur lors de la définalisation de la session'); + this.pixToast.sendErrorNotification({ message: 'Erreur lors de la définalisation de la session' }); } this.cancelModal(); } @@ -113,7 +113,9 @@ export default class IndexController extends Controller { try { await this.fileSaver.save({ url, token }); } catch (error) { - this.notifications.error("Une erreur est survenue, les attestations n'ont pas pu être téléchargées."); + this.pixToast.sendErrorNotification({ + message: "Une erreur est survenue, les attestations n'ont pas pu être téléchargées.", + }); } } @@ -123,7 +125,9 @@ export default class IndexController extends Controller { await this.sessionModel.save({ adapterOptions: { isComment: true, comment } }); this.sessionModel.reload(); } catch (error) { - this.notifications.error("Une erreur est survenue pendant l'enregistrement du commentaire. "); + this.pixToast.sendErrorNotification({ + message: "Une erreur est survenue pendant l'enregistrement du commentaire. ", + }); } } @@ -133,7 +137,9 @@ export default class IndexController extends Controller { await this.sessionModel.save({ adapterOptions: { isDeleteComment: true } }); await this.sessionModel.reload(); } catch (error) { - this.notifications.error('Une erreur est survenue pendant la suppression du commentaire.'); + this.pixToast.sendErrorNotification({ + message: 'Une erreur est survenue pendant la suppression du commentaire.', + }); throw error; } } @@ -155,9 +161,9 @@ export default class IndexController extends Controller { async _assignSessionToCurrentUser() { try { await this.sessionModel.save({ adapterOptions: { certificationOfficerAssignment: true } }); - this.notifications.success('La session vous a correctement été assignée'); - } catch (err) { - this.notifications.error("Erreur lors de l'assignation à la session"); + this.pixToast.sendSuccessNotification({ message: 'La session vous a correctement été assignée' }); + } catch (_) { + this.pixToast.sendErrorNotification({ message: "Erreur lors de l'assignation à la session" }); } } } diff --git a/admin/app/controllers/authenticated/smart-random-simulator/get-next-challenge.js b/admin/app/controllers/authenticated/smart-random-simulator/get-next-challenge.js index 91c68a2bde3..1e5dbca68dc 100644 --- a/admin/app/controllers/authenticated/smart-random-simulator/get-next-challenge.js +++ b/admin/app/controllers/authenticated/smart-random-simulator/get-next-challenge.js @@ -12,7 +12,7 @@ const KNOWLEDGE_ELEMENTS_SOURCES = { DIRECT: 'direct', INFERRED: 'inferred' }; export default class SmartRandomSimulator extends Controller { @service session; - @service notifications; + @service pixToast; // Simulator parameters @tracked skills = []; @@ -76,15 +76,15 @@ export default class SmartRandomSimulator extends Controller { const responseBody = await apiResponse.json(); this.skills = responseBody.skills; this.challenges = responseBody.challenges; - this.notifications.success( - `Données chargées: ${this.skills.length} compétences et ${this.challenges.length} challenges`, - ); + this.pixToast.sendSuccessNotification({ + message: `Données chargées: ${this.skills.length} compétences et ${this.challenges.length} challenges`, + }); return; } const response = await apiResponse.json(); response.errors.map(({ detail }) => { - this.notifications.error(detail); + this.pixToast.sendErrorNotification({ message: detail }); }); } @@ -160,7 +160,7 @@ export default class SmartRandomSimulator extends Controller { default: { const response = await apiResponse.json(); return response.errors.map(({ detail }) => { - this.notifications.error(detail); + this.pixToast.sendErrorNotification({ message: detail }); }); } } diff --git a/admin/app/routes/authenticated/complementary-certifications/list.js b/admin/app/routes/authenticated/complementary-certifications/list.js index 8e8e0aab738..f223d768547 100644 --- a/admin/app/routes/authenticated/complementary-certifications/list.js +++ b/admin/app/routes/authenticated/complementary-certifications/list.js @@ -4,15 +4,16 @@ import isEmpty from 'lodash/isEmpty'; export default class ListRoute extends Route { @service store; + @service pixToast; async model() { try { return await this.store.findAll('complementary-certification'); } catch (errorResponse) { if (!isEmpty(errorResponse)) { - errorResponse.errors.forEach((error) => this.notifications.error(error.detail)); + errorResponse.errors.forEach((error) => this.pixToast.sendErrorNotification({ message: error.detail })); } else { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } } return []; From 26e3a9b8825f99a1c5cd76f95060804f73763760 Mon Sep 17 00:00:00 2001 From: AndreiaPena Date: Mon, 18 Nov 2024 18:01:29 +0100 Subject: [PATCH 06/10] =?UTF-8?q?=E2=9C=A8admin:=20use=20Pix=20Toast=20on?= =?UTF-8?q?=20prescription=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campaigns/campaigns-import.gjs | 13 +++---- .../campaigns/swap-campaign-codes.gjs | 24 +++++++------ .../campaigns/update-campaign-code.gjs | 34 ++++++++++++------- .../update-organization-import-format.gjs | 14 ++++---- admin/app/components/campaigns/update.gjs | 10 +++--- .../organizations/places/delete-modal.gjs | 10 ++++-- .../organizations/target-profiles-section.gjs | 12 +++---- .../target-profiles/organizations.gjs | 12 +++---- .../campaigns/campaign/participations.js | 10 +++--- .../organizations/get/places/new.js | 6 ++-- .../authenticated/organizations/new.js | 6 ++-- .../target-profile/organizations.js | 6 ++-- admin/app/controllers/authenticated/tools.js | 12 +++---- .../users/get/campaign-participations.js | 10 +++--- 14 files changed, 100 insertions(+), 79 deletions(-) diff --git a/admin/app/components/administration/campaigns/campaigns-import.gjs b/admin/app/components/administration/campaigns/campaigns-import.gjs index 9ac515046d4..6a9da61952b 100644 --- a/admin/app/components/administration/campaigns/campaigns-import.gjs +++ b/admin/app/components/administration/campaigns/campaigns-import.gjs @@ -8,30 +8,31 @@ import AdministrationBlockLayout from '../block-layout'; export default class CampaignsImport extends Component { @service intl; - @service notifications; + @service pixToast; @service router; @service store; @action async importCampaigns(files) { - const adapter = this.store.adapterFor('import-files'); try { await adapter.addCampaignsCsv(files); - this.notifications.success(this.intl.t('components.administration.campaigns-import.notifications.success')); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.campaigns-import.notifications.success'), + }); } catch (errorResponse) { const errors = errorResponse.errors; if (!errors) { - return this.notifications.error(this.intl.t('common.notifications.generic-error')); + return this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } errors.forEach((error) => { switch (error.code) { case 'MISSING_REQUIRED_FIELD_NAMES': - this.notifications.error(`${error.meta}`, { autoClear: false }); + this.pixToast.sendErrorNotification({ message: `${error.meta}` }); break; default: - this.notifications.error(error.detail, { autoClear: false }); + this.pixToast.sendErrorNotification({ message: error.detail }); } }); } finally { diff --git a/admin/app/components/administration/campaigns/swap-campaign-codes.gjs b/admin/app/components/administration/campaigns/swap-campaign-codes.gjs index 3393989a5ed..0b98fafcc41 100644 --- a/admin/app/components/administration/campaigns/swap-campaign-codes.gjs +++ b/admin/app/components/administration/campaigns/swap-campaign-codes.gjs @@ -12,7 +12,7 @@ import AdministrationBlockLayout from '../block-layout'; export default class SwapCampaignCodes extends Component { @service intl; - @service notifications; + @service pixToast; @service store; @tracked isLoading; @@ -25,25 +25,29 @@ export default class SwapCampaignCodes extends Component { const adapter = this.store.adapterFor('swap-campaign-code'); try { await adapter.swap({ firstCampaignId: this.firstCampaignId, secondCampaignId: this.secondCampaignId }); - this.notifications.success(this.intl.t('components.administration.swap-campaign-codes.notifications.success')); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.swap-campaign-codes.notifications.success'), + }); } catch (errorResponse) { const errors = errorResponse.errors; if (!errors) { - return this.notifications.error(this.intl.t('common.notifications.generic-error')); + return this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } else { const error = errors[0]; if (error.code === 'ORGANIZATION_MISMATCH') { - return this.notifications.error( - this.intl.t('components.administration.swap-campaign-codes.notifications.error.mismatch-organization'), - ); + return this.pixToast.sendErrorNotification({ + message: this.intl.t( + 'components.administration.swap-campaign-codes.notifications.error.mismatch-organization', + ), + }); } else if (error.code === 'UNKNOWN_CAMPAIGN_ID') { - this.notifications.error( - this.intl.t('components.administration.swap-campaign-codes.notifications.error.swap-code-error'), - ); + this.pixToast.sendErrorNotification({ + message: this.intl.t('components.administration.swap-campaign-codes.notifications.error.swap-code-error'), + }); } else { - this.notifications.error(this.intl.t('common.notifications.generic-error')); + this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } } } finally { diff --git a/admin/app/components/administration/campaigns/update-campaign-code.gjs b/admin/app/components/administration/campaigns/update-campaign-code.gjs index d805a6f22dd..c378ba1aec0 100644 --- a/admin/app/components/administration/campaigns/update-campaign-code.gjs +++ b/admin/app/components/administration/campaigns/update-campaign-code.gjs @@ -11,7 +11,7 @@ import AdministrationBlockLayout from '../block-layout'; export default class UpdateCampaignCode extends Component { @service intl; - @service notifications; + @service pixToast; @service store; @tracked isLoading; @@ -24,29 +24,37 @@ export default class UpdateCampaignCode extends Component { const adapter = this.store.adapterFor('update-campaign-code'); try { await adapter.updateCampaignCode({ campaignId: this.campaignId, campaignCode: this.campaignCode }); - this.notifications.success(this.intl.t('components.administration.update-campaign-code.notifications.success')); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.update-campaign-code.notifications.success'), + }); } catch (errorResponse) { const errors = errorResponse.errors; if (!errors) { - return this.notifications.error(this.intl.t('common.notifications.generic-error')); + return this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } else { const error = errors[0]; if (error.code === 'CAMPAIGN_CODE_BAD_FORMAT') { - return this.notifications.error( - this.intl.t('components.administration.update-campaign-code.notifications.error.campaign-code-format'), - ); + return this.pixToast.sendErrorNotification({ + message: this.intl.t( + 'components.administration.update-campaign-code.notifications.error.campaign-code-format', + ), + }); } else if (error.code === 'CAMPAIGN_CODE_NOT_UNIQUE') { - return this.notifications.error( - this.intl.t('components.administration.update-campaign-code.notifications.error.unique-code-error'), - ); + return this.pixToast.sendErrorNotification({ + message: this.intl.t( + 'components.administration.update-campaign-code.notifications.error.unique-code-error', + ), + }); } else if (error.code === 'UNKNOWN_CAMPAIGN_ID') { - this.notifications.error( - this.intl.t('components.administration.update-campaign-code.notifications.error.campaign-id-error'), - ); + this.pixToast.sendErrorNotification({ + message: this.intl.t( + 'components.administration.update-campaign-code.notifications.error.campaign-id-error', + ), + }); } else { - this.notifications.error(this.intl.t('common.notifications.generic-error')); + this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } } } finally { diff --git a/admin/app/components/administration/organizations/update-organization-import-format.gjs b/admin/app/components/administration/organizations/update-organization-import-format.gjs index 5f18208300c..81c3da4aca3 100644 --- a/admin/app/components/administration/organizations/update-organization-import-format.gjs +++ b/admin/app/components/administration/organizations/update-organization-import-format.gjs @@ -8,7 +8,7 @@ import AdministrationBlockLayout from '../block-layout'; export default class UpdateOrganizationImportFormat extends Component { @service intl; - @service notifications; + @service pixToast; @service router; @service store; @@ -17,22 +17,22 @@ export default class UpdateOrganizationImportFormat extends Component { const adapter = this.store.adapterFor('import-files'); try { await adapter.updateOrganizationImportFormat(files); - this.notifications.success( - this.intl.t('components.administration.organization-import-format.notifications.success'), - ); + this.pixToast.sendSuccessNotification({ + message: this.intl.t('components.administration.organization-import-format.notifications.success'), + }); } catch (errorResponse) { const errors = errorResponse.errors; if (!errors) { - return this.notifications.error(this.intl.t('common.notifications.generic-error')); + return this.pixToast.sendErrorNotification({ message: this.intl.t('common.notifications.generic-error') }); } errors.forEach((error) => { switch (error.code) { case 'MISSING_REQUIRED_FIELD_NAMES': - this.notifications.error(`${error.meta}`, { autoClear: false }); + this.pixToast.sendErrorNotification({ message: `${error.meta}` }); break; default: - this.notifications.error(error.detail, { autoClear: false }); + this.pixToast.sendErrorNotification({ message: error.detail }); } }); } finally { diff --git a/admin/app/components/campaigns/update.gjs b/admin/app/components/campaigns/update.gjs index f4bfc8b09f9..7c1a4bfb699 100644 --- a/admin/app/components/campaigns/update.gjs +++ b/admin/app/components/campaigns/update.gjs @@ -15,7 +15,7 @@ import { not } from 'ember-truth-helpers'; import PixFieldset from 'pix-admin/components/ui/pix-fieldset'; export default class Update extends Component { - @service notifications; + @service pixToast; @service accessControl; @service store; @service intl; @@ -117,7 +117,7 @@ export default class Update extends Component { try { await campaign.save(); - await this.notifications.success('Les modifications ont bien été enregistrées.'); + await this.pixToast.sendSuccessNotification({ message: 'Les modifications ont bien été enregistrées.' }); this.args.onExit(); } catch (errorResponse) { campaign.rollbackAttributes(); @@ -125,13 +125,13 @@ export default class Update extends Component { const genericErrorMessage = this.intl.t('common.notifications.generic-error'); if (!errors) { - return this.notifications.error(genericErrorMessage); + return this.pixToast.sendErrorNotification({ message: genericErrorMessage }); } return errorResponse.errors.forEach((error) => { if (error.status === '422') { - return this.notifications.error(error.detail); + return this.pixToast.sendErrorNotification({ message: error.detail }); } - return this.notifications.error(genericErrorMessage); + return this.pixToast.sendErrorNotification({ message: genericErrorMessage }); }); } } diff --git a/admin/app/components/organizations/places/delete-modal.gjs b/admin/app/components/organizations/places/delete-modal.gjs index 5e8981b465c..7654722c121 100644 --- a/admin/app/components/organizations/places/delete-modal.gjs +++ b/admin/app/components/organizations/places/delete-modal.gjs @@ -5,7 +5,7 @@ import Component from '@glimmer/component'; import ConfirmPopup from '../../confirm-popup'; export default class DeleteModal extends Component { - @service notifications; + @service pixToast; get message() { if (!this.args.show) return ''; @@ -18,10 +18,14 @@ export default class DeleteModal extends Component { await this.args.organizationPlacesLot.deleteRecord(); await this.args.organizationPlacesLot.save({ adapterOptions: { organizationId: this.args.organizationId } }); - this.notifications.success(`Le lot de place ${this.args.organizationPlacesLot.reference} a été supprimé.`); + this.pixToast.sendSuccessNotification({ + message: `Le lot de place ${this.args.organizationPlacesLot.reference} a été supprimé.`, + }); this.args.refreshModel(); } catch (error) { - this.notifications.error(`Le lot de place ${this.args.organizationPlacesLot.reference} n'a pas été supprimé.`); + this.pixToast.sendErrorNotification({ + message: `Le lot de place ${this.args.organizationPlacesLot.reference} n'a pas été supprimé.`, + }); } this.args.toggle(); diff --git a/admin/app/components/organizations/target-profiles-section.gjs b/admin/app/components/organizations/target-profiles-section.gjs index b9aae07db2e..93d3d5568ac 100644 --- a/admin/app/components/organizations/target-profiles-section.gjs +++ b/admin/app/components/organizations/target-profiles-section.gjs @@ -20,7 +20,7 @@ export default class OrganizationTargetProfilesSectionComponent extends Componen @tracked targetProfileToDetach; @service accessControl; - @service notifications; + @service pixToast; @service router; @service store; @service intl; @@ -76,7 +76,7 @@ export default class OrganizationTargetProfilesSectionComponent extends Componen ); } this.targetProfilesToAttach = ''; - return this.notifications.success(message.join(''), { htmlContent: true }); + return this.pixToast.sendSuccessNotification({ message: message.join('') }); } catch (responseError) { this._handleResponseError(responseError); } @@ -95,7 +95,7 @@ export default class OrganizationTargetProfilesSectionComponent extends Componen await adapter.detachOrganizations(targetProfilId, [this.args.organization.id]); this.closeModal(); await this.args.organization.get('targetProfileSummaries').reload(); - return this.notifications.success('Profil cible détaché avec succès.'); + return this.pixToast.sendSuccessNotification({ message: 'Profil cible détaché avec succès.' }); } catch (responseError) { this._handleResponseError(responseError); } @@ -117,13 +117,13 @@ export default class OrganizationTargetProfilesSectionComponent extends Componen const genericErrorMessage = this.intl.t('common.notifications.generic-error'); if (!errors) { - return this.notifications.error(genericErrorMessage); + return this.pixToast.sendErrorNotification({ message: genericErrorMessage }); } errors.forEach((error) => { if (['404', '412'].includes(error.status)) { - return this.notifications.error(error.detail); + return this.pixToast.sendErrorNotification({ message: error.detail }); } - return this.notifications.error(genericErrorMessage); + return this.pixToast.sendErrorNotification({ message: genericErrorMessage }); }); } diff --git a/admin/app/components/target-profiles/organizations.gjs b/admin/app/components/target-profiles/organizations.gjs index c6c4816a366..8e6e39a40db 100644 --- a/admin/app/components/target-profiles/organizations.gjs +++ b/admin/app/components/target-profiles/organizations.gjs @@ -14,7 +14,7 @@ import ListItems from '../organizations/list-items'; export default class Organizations extends Component { @service store; - @service notifications; + @service pixToast; @service router; @service currentUser; @service intl; @@ -68,7 +68,7 @@ export default class Organizations extends Component { ); } - await this.notifications.success(message.join(''), { htmlContent: true }); + await this.pixToast.sendSuccessNotification({ message: message.join('') }); return this.router.replaceWith('authenticated.target-profiles.target-profile.organizations'); } catch (responseError) { @@ -89,7 +89,7 @@ export default class Organizations extends Component { targetProfileIdToCopy: this.existingTargetProfile, }); this.existingTargetProfile = ''; - await this.notifications.success('Organisation(s) rattaché(es) avec succès.'); + await this.pixToast.sendSuccessNotification({ message: 'Organisation(s) rattaché(es) avec succès.' }); return this.router.replaceWith('authenticated.target-profiles.target-profile.organizations'); } catch (responseError) { this._handleResponseError(responseError); @@ -100,13 +100,13 @@ export default class Organizations extends Component { const genericErrorMessage = this.intl.t('common.notifications.generic-error'); if (!errors) { - return this.notifications.error(genericErrorMessage); + return this.pixToast.sendErrorNotification({ message: genericErrorMessage }); } errors.forEach((error) => { if (['404', '412'].includes(error.status)) { - return this.notifications.error(error.detail); + return this.pixToast.sendErrorNotification({ message: error.detail }); } - return this.notifications.error(genericErrorMessage); + return this.pixToast.sendErrorNotification({ message: genericErrorMessage }); }); } diff --git a/admin/app/controllers/authenticated/campaigns/campaign/participations.js b/admin/app/controllers/authenticated/campaigns/campaign/participations.js index fb2daed3db0..9f24be0ff2d 100644 --- a/admin/app/controllers/authenticated/campaigns/campaign/participations.js +++ b/admin/app/controllers/authenticated/campaigns/campaign/participations.js @@ -11,15 +11,17 @@ export default class CampaignParticipationsController extends Controller { @tracked pageNumber = DEFAULT_PAGE_NUMBER; @tracked pageSize = 10; - @service notifications; + @service pixToast; @action async updateParticipantExternalId(campaignParticipation) { try { await campaignParticipation.save(); - this.notifications.success("L'id externe du participant été mis à jour avec succès."); - } catch (e) { - this.notifications.error("Une erreur est survenue lors de la mise à jour de l'id externe du participant."); + this.pixToast.sendSuccessNotification({ message: "L'id externe du participant été mis à jour avec succès." }); + } catch (_) { + this.pixToast.sendErrorNotification({ + message: "Une erreur est survenue lors de la mise à jour de l'id externe du participant.", + }); } } } diff --git a/admin/app/controllers/authenticated/organizations/get/places/new.js b/admin/app/controllers/authenticated/organizations/get/places/new.js index c045f5b5570..ba14f9cb92c 100644 --- a/admin/app/controllers/authenticated/organizations/get/places/new.js +++ b/admin/app/controllers/authenticated/organizations/get/places/new.js @@ -6,7 +6,7 @@ import { tracked } from '@glimmer/tracking'; export default class New extends Controller { @service router; @service store; - @service notifications; + @service pixToast; @tracked errors; @@ -18,12 +18,12 @@ export default class New extends Controller { this.model.setProperties(attributes); await this.model.save({ adapterOptions: { organizationId: this.model.organizationId } }); } catch (errorResponse) { - this.notifications.error('Erreur lors de la création du lot de place.'); + this.pixToast.sendErrorNotification({ message: 'Erreur lors de la création du lot de place.' }); this.errors = this.model.errors; } if (!this.errors) { - this.notifications.success('Le lot de place est enregistré.'); + this.pixToast.sendSuccessNotification({ message: 'Le lot de place est enregistré.' }); this.router.transitionTo('authenticated.organizations.get.places', this.model.organizationId); } } diff --git a/admin/app/controllers/authenticated/organizations/new.js b/admin/app/controllers/authenticated/organizations/new.js index b04c746ea7b..4a09cf7cad7 100644 --- a/admin/app/controllers/authenticated/organizations/new.js +++ b/admin/app/controllers/authenticated/organizations/new.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class NewController extends Controller { - @service notifications; + @service pixToast; @service router; @action @@ -16,10 +16,10 @@ export default class NewController extends Controller { event.preventDefault(); try { await this.model.save(); - this.notifications.success('L’organisation a été créée avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'L’organisation a été créée avec succès.' }); this.router.transitionTo('authenticated.organizations.get.all-tags', this.model.id); } catch (error) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } } } diff --git a/admin/app/controllers/authenticated/target-profiles/target-profile/organizations.js b/admin/app/controllers/authenticated/target-profiles/target-profile/organizations.js index d1ed05163c0..bcc78ccf8bb 100644 --- a/admin/app/controllers/authenticated/target-profiles/target-profile/organizations.js +++ b/admin/app/controllers/authenticated/target-profiles/target-profile/organizations.js @@ -11,7 +11,7 @@ export default class TargetProfileOrganizationsController extends Controller { queryParams = ['pageNumber', 'pageSize', 'id', 'name', 'type', 'externalId']; DEBOUNCE_MS = config.pagination.debounce; @service router; - @service notifications; + @service pixToast; @service store; @tracked pageNumber = DEFAULT_PAGE_NUMBER; @@ -48,11 +48,11 @@ export default class TargetProfileOrganizationsController extends Controller { if (hasDetachedOrganizations) { const message = 'Organisation(s) détachée(s) avec succès : ' + detachedOrganizationIds.join(', '); - await this.notifications.success(message, { htmlContent: true }); + await this.pixToast.sendSuccessNotification({ message }); this.router.transitionTo('authenticated.target-profiles.target-profile.organizations'); } } catch (responseError) { - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } } } diff --git a/admin/app/controllers/authenticated/tools.js b/admin/app/controllers/authenticated/tools.js index 602dbf4a398..aa5f18525e1 100644 --- a/admin/app/controllers/authenticated/tools.js +++ b/admin/app/controllers/authenticated/tools.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class ToolsController extends Controller { - @service notifications; + @service pixToast; @service store; @service currentUser; @@ -15,17 +15,17 @@ export default class ToolsController extends Controller { try { await adapter.importCampaignsToArchive(files); this.isLoading = false; - this.notifications.success('Toutes les campagnes ont été archivées.'); + this.pixToast.sendSuccessNotification({ message: 'Toutes les campagnes ont été archivées.' }); } catch ({ errors: [error] }) { this.isLoading = false; if (error.code === 'HEADER_REQUIRED') { - this.notifications.error("La colonne campaignId n'est pas présente."); + this.pixToast.sendErrorNotification({ message: "La colonne campaignId n'est pas présente." }); } else if (error.code === 'HEADER_UNKNOWN') { - this.notifications.error('Une colonne dans le fichier ne devrait pas être présente.'); + this.pixToast.sendErrorNotification({ message: 'Une colonne dans le fichier ne devrait pas être présente.' }); } else if (error.code === 'ENCODING_NOT_SUPPORTED') { - this.notifications.error('Encodage non supporté.'); + this.pixToast.sendErrorNotification({ message: 'Encodage non supporté.' }); } else { - this.notifications.error('Une erreur est survenue. OUPS...'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue. OUPS...' }); } } } diff --git a/admin/app/controllers/authenticated/users/get/campaign-participations.js b/admin/app/controllers/authenticated/users/get/campaign-participations.js index 2af7804fada..0a9467801ce 100644 --- a/admin/app/controllers/authenticated/users/get/campaign-participations.js +++ b/admin/app/controllers/authenticated/users/get/campaign-participations.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class UserCampaignParticipationsController extends Controller { - @service notifications; + @service pixToast; @action async removeParticipation(campaignParticipation) { @@ -13,9 +13,11 @@ export default class UserCampaignParticipationsController extends Controller { await campaignParticipation.unloadRecord(); await this.model.reload(); this.send('refreshModel'); - this.notifications.success('La participation du prescrit a été supprimée avec succès.'); - } catch (e) { - this.notifications.error('Une erreur est survenue lors de la suppression de la participation.'); + this.pixToast.sendSuccessNotification({ message: 'La participation du prescrit a été supprimée avec succès.' }); + } catch (_) { + this.pixToast.sendErrorNotification({ + message: 'Une erreur est survenue lors de la suppression de la participation.', + }); } } } From 135dd9c986faf0ebec9a89e81b1fec7c4b9baf75 Mon Sep 17 00:00:00 2001 From: AndreiaPena Date: Mon, 18 Nov 2024 18:18:39 +0100 Subject: [PATCH 07/10] =?UTF-8?q?=E2=9C=A8=20admin:=20use=20Pix=20Toast=20?= =?UTF-8?q?on=20evaluation=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/components/autonomous-courses/details.gjs | 6 +++--- admin/app/components/badges/badge.gjs | 6 +++--- admin/app/components/badges/campaign-criterion.gjs | 10 ++++++---- .../app/components/target-profiles/badge-form.gjs | 14 +++++++++----- admin/app/components/target-profiles/badges.gjs | 8 ++++---- admin/app/components/target-profiles/stages.gjs | 9 +++++---- .../authenticated/autonomous-courses/new.js | 10 +++++----- .../authenticated/target-profiles/edit.js | 12 ++++++------ .../authenticated/target-profiles/new.js | 12 ++++++------ .../app/controllers/authenticated/trainings/new.js | 10 +++++----- .../authenticated/trainings/training.js | 6 +++--- .../trainings/training/target-profiles.js | 10 +++++----- .../trainings/training/triggers/edit.js | 6 +++--- .../routes/authenticated/target-profiles/list.js | 4 ++-- .../target-profile/training-summaries.js | 4 ++-- admin/app/routes/authenticated/trainings/list.js | 4 ++-- 16 files changed, 69 insertions(+), 62 deletions(-) diff --git a/admin/app/components/autonomous-courses/details.gjs b/admin/app/components/autonomous-courses/details.gjs index 5f983a1e82e..5257925de2f 100644 --- a/admin/app/components/autonomous-courses/details.gjs +++ b/admin/app/components/autonomous-courses/details.gjs @@ -12,7 +12,7 @@ import ViewAutonomousCourse from './view-autonomous-course'; export default class Details extends Component { @tracked isEditMode = false; @service intl; - @service notifications; + @service pixToast; @service router; @action @@ -28,12 +28,12 @@ export default class Details extends Component { this.isEditMode = false; try { await this.args.autonomousCourse.save(); - this.notifications.success('Parcours autonome modifié avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Parcours autonome modifié avec succès.' }); } catch ({ errors }) { this.args.autonomousCourse.rollbackAttributes(); if (errors[0]?.detail) { - return this.notifications.error(errors[0].detail); + return this.pixToast.sendErrorNotification({ message: errors[0].detail }); } } } diff --git a/admin/app/components/badges/badge.gjs b/admin/app/components/badges/badge.gjs index 75759b04d4e..4a8f3de855f 100644 --- a/admin/app/components/badges/badge.gjs +++ b/admin/app/components/badges/badge.gjs @@ -19,7 +19,7 @@ import CampaignCriterion from './campaign-criterion'; import CappedTubesCriterion from './capped-tubes-criterion'; export default class Badge extends Component { - @service notifications; + @service pixToast; @service store; @service intl; @@ -79,7 +79,7 @@ export default class Badge extends Component { imageUrl: this.IMAGE_BASE_URL + this.form.imageName, }; await this.args.onUpdateBadge(badgeDTO); - this.notifications.success('Le résultat thématique a été mis à jour.'); + this.pixToast.sendSuccessNotification({ message: 'Le résultat thématique a été mis à jour.' }); this.editMode = false; } catch (err) { let errorMessage; @@ -91,7 +91,7 @@ export default class Badge extends Component { } else { errorMessage = error.detail; } - this.notifications.error(errorMessage); + this.pixToast.sendErrorNotification({ message: errorMessage }); }); } } diff --git a/admin/app/components/badges/campaign-criterion.gjs b/admin/app/components/badges/campaign-criterion.gjs index d2b441624fc..389153ae4cf 100644 --- a/admin/app/components/badges/campaign-criterion.gjs +++ b/admin/app/components/badges/campaign-criterion.gjs @@ -10,7 +10,7 @@ import { t } from 'ember-intl'; import { not } from 'ember-truth-helpers'; export default class CampaignCriterion extends Component { - @service notifications; + @service pixToast; @tracked isEditModalVisible = false; @tracked thresholdInputValue = this.previousTreshold; @@ -36,14 +36,16 @@ export default class CampaignCriterion extends Component { try { await criterion.save(); - this.notifications.success("Seuil d'obtention du critère modifié avec succès."); + this.pixToast.sendSuccessNotification({ message: "Seuil d'obtention du critère modifié avec succès." }); this.toggleEditModal(); } catch (responseError) { responseError?.errors?.forEach((error) => { if (error?.detail) { - this.notifications.error(error.detail); + this.pixToast.sendErrorNotification({ message: error.detail }); } else { - this.notifications.error("Problème lors de la modification du seuil d'obtention du critère."); + this.pixToast.sendErrorNotification({ + message: "Problème lors de la modification du seuil d'obtention du critère.", + }); } }); } diff --git a/admin/app/components/target-profiles/badge-form.gjs b/admin/app/components/target-profiles/badge-form.gjs index 88cd15d0c37..b4592992c41 100644 --- a/admin/app/components/target-profiles/badge-form.gjs +++ b/admin/app/components/target-profiles/badge-form.gjs @@ -14,7 +14,7 @@ import Card from '../card'; import Criteria from './badge-form/criteria'; export default class BadgeForm extends Component { - @service notifications; + @service pixToast; @service store; @service router; @@ -55,13 +55,17 @@ export default class BadgeForm extends Component { const hasCappedTubesCriteria = this.badge.cappedTubesCriteria.length; if (!hasCampaignCriteria && !hasCappedTubesCriteria) { - return this.notifications.error("Vous devez sélectionner au moins un critère d'obtention de résultat thématique"); + return this.pixToast.sendErrorNotification({ + message: "Vous devez sélectionner au moins un critère d'obtention de résultat thématique", + }); } const hasSelectedCappedTubes = this.badge.cappedTubesCriteria[0]?.cappedTubes?.length; if (hasCappedTubesCriteria && !hasSelectedCappedTubes) { - return this.notifications.error('Vous devez sélectionner au moins un sujet du profil cible'); + return this.pixToast.sendErrorNotification({ + message: 'Vous devez sélectionner au moins un sujet du profil cible', + }); } await this._createBadge(); @@ -81,12 +85,12 @@ export default class BadgeForm extends Component { }); await this.args.targetProfile.reload(); - this.notifications.success('Le résultat thématique a été créé.'); + this.pixToast.sendSuccessNotification({ message: 'Le résultat thématique a été créé.' }); this.router.transitionTo('authenticated.target-profiles.target-profile.insights'); return badge; } catch (error) { console.error(error); - this.notifications.error(`${error.errors[0].detail}`); + this.pixToast.sendErrorNotification({ message: `${error.errors[0].detail}` }); } } diff --git a/admin/app/components/target-profiles/badges.gjs b/admin/app/components/target-profiles/badges.gjs index 619efc9ae80..69011301d36 100644 --- a/admin/app/components/target-profiles/badges.gjs +++ b/admin/app/components/target-profiles/badges.gjs @@ -16,7 +16,7 @@ import ConfirmPopup from '../confirm-popup'; export default class Badges extends Component { @tracked displayConfirm = false; @service store; - @service notifications; + @service pixToast; badgeIdToDelete; get hasBadges() { @@ -36,9 +36,9 @@ export default class Badges extends Component { try { badge = this.store.peekRecord('badge', this.badgeIdToDelete); await badge.destroyRecord(); - this.notifications.success('Le résultat thématique a été supprimé avec succès.'); - } catch (e) { - this.notifications.error(e.errors[0].detail); + this.pixToast.sendSuccessNotification({ message: 'Le résultat thématique a été supprimé avec succès.' }); + } catch (error) { + this.pixToast.sendErrorNotification({ message: error.errors[0].detail }); badge.rollbackAttributes(); } this.toggleDisplayConfirm(); diff --git a/admin/app/components/target-profiles/stages.gjs b/admin/app/components/target-profiles/stages.gjs index 21920f8fb47..223ce68c543 100644 --- a/admin/app/components/target-profiles/stages.gjs +++ b/admin/app/components/target-profiles/stages.gjs @@ -19,7 +19,7 @@ const THRESHOLD_COLUMN_NAME = 'Seuil'; export default class Stages extends Component { @service store; @service intl; - @service notifications; + @service pixToast; @tracked stageType = undefined; @@ -155,10 +155,11 @@ export default class Stages extends Component { this.stages.removeObject(stage); stage.deleteRecord(); }); - this.notifications.success('Palier(s) ajouté(s) avec succès.'); - } catch (e) { + this.pixToast.sendSuccessNotification({ message: 'Palier(s) ajouté(s) avec succès.' }); + } catch (error) { const genericErrorMessage = this.intl.t('common.notifications.generic-error'); - this.notifications.error(e.errors?.[0]?.detail ?? genericErrorMessage); + const message = error.errors?.[0]?.detail ?? genericErrorMessage; + this.pixToast.sendErrorNotification({ message }); } } diff --git a/admin/app/controllers/authenticated/autonomous-courses/new.js b/admin/app/controllers/authenticated/autonomous-courses/new.js index add8a0cdebe..8e609ef1ee6 100644 --- a/admin/app/controllers/authenticated/autonomous-courses/new.js +++ b/admin/app/controllers/authenticated/autonomous-courses/new.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class NewController extends Controller { - @service notifications; + @service pixToast; @service store; @service router; @@ -22,16 +22,16 @@ export default class NewController extends Controller { event.preventDefault(); try { const { id: autonomousCourseId } = await this.store.createRecord('autonomous-course', autonomousCourse).save(); - this.notifications.success('Le parcours autonome a été créé avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Le parcours autonome a été créé avec succès.' }); this.goToAutonomousCourseDetails(autonomousCourseId); } catch (error) { if (!autonomousCourse.targetProfileId) { - return this.notifications.error('Aucun profil cible sélectionné !'); + return this.pixToast.sendErrorNotification({ message: 'Aucun profil cible sélectionné !' }); } if (error.errors[0]?.detail) { - return this.notifications.error(error.errors[0].detail); + return this.pixToast.sendErrorNotification({ message: error.errors[0].detail }); } else { - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } } } diff --git a/admin/app/controllers/authenticated/target-profiles/edit.js b/admin/app/controllers/authenticated/target-profiles/edit.js index 8d9dcc40ed7..648ca063415 100644 --- a/admin/app/controllers/authenticated/target-profiles/edit.js +++ b/admin/app/controllers/authenticated/target-profiles/edit.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class EditController extends Controller { - @service notifications; + @service pixToast; @service store; @service router; @@ -16,13 +16,13 @@ export default class EditController extends Controller { const targetProfile = this.model.targetProfile; if (!targetProfile.hasLinkedCampaign && selectedTubes.length === 0) { - this.notifications.error('Vous devez sélectionner au moins 1 sujet !'); + this.pixToast.sendErrorNotification({ message: 'Vous devez sélectionner au moins 1 sujet !' }); return; } try { await targetProfile.save({ adapterOptions: { tubes: selectedTubes } }); - this.notifications.success('Le profil cible a été modifié avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Le profil cible a été modifié avec succès.' }); this.router.transitionTo('authenticated.target-profiles.target-profile', targetProfile.id); } catch (error) { this._handleResponseError(error); @@ -36,13 +36,13 @@ export default class EditController extends Controller { _handleResponseError({ errors }) { if (!errors) { - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } errors.forEach((error) => { if (['400', '404', '412', '422'].includes(error.status)) { - return this.notifications.error(error.detail); + return this.pixToast.sendErrorNotification({ message: error.detail }); } - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); }); } } diff --git a/admin/app/controllers/authenticated/target-profiles/new.js b/admin/app/controllers/authenticated/target-profiles/new.js index 161408d4e06..7803f13a5f2 100644 --- a/admin/app/controllers/authenticated/target-profiles/new.js +++ b/admin/app/controllers/authenticated/target-profiles/new.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class NewController extends Controller { - @service notifications; + @service pixToast; @service store; @service router; @@ -18,13 +18,13 @@ export default class NewController extends Controller { const targetProfile = this.model.targetProfile; if (selectedTubes === 0) { - this.notifications.error('Aucun sujet sélectionné !'); + this.pixToast.sendErrorNotification({ message: 'Aucun sujet sélectionné !' }); return; } try { await targetProfile.save({ adapterOptions: { tubes: selectedTubes } }); - this.notifications.success('Le profil cible a été créé avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Le profil cible a été créé avec succès.' }); this.router.transitionTo('authenticated.target-profiles.target-profile', targetProfile.id); } catch (error) { this._handleResponseError(error); @@ -33,13 +33,13 @@ export default class NewController extends Controller { _handleResponseError({ errors }) { if (!errors) { - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } errors.forEach((error) => { if (['404', '412', '422'].includes(error.status)) { - return this.notifications.error(error.detail); + return this.pixToast.sendErrorNotification({ message: error.detail }); } - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); }); } } diff --git a/admin/app/controllers/authenticated/trainings/new.js b/admin/app/controllers/authenticated/trainings/new.js index 461763b1d30..bb71ef26c64 100644 --- a/admin/app/controllers/authenticated/trainings/new.js +++ b/admin/app/controllers/authenticated/trainings/new.js @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { service } from '@ember/service'; export default class NewController extends Controller { - @service notifications; + @service pixToast; @service store; @service router; @@ -21,7 +21,7 @@ export default class NewController extends Controller { async createOrUpdateTraining(trainingFormData) { try { const { id } = await this.store.createRecord('training', trainingFormData).save(); - this.notifications.success('Le contenu formatif a été créé avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Le contenu formatif a été créé avec succès.' }); this.goToTrainingDetails(id); } catch (error) { this._handleResponseError(error); @@ -30,13 +30,13 @@ export default class NewController extends Controller { _handleResponseError({ errors }) { if (!errors) { - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } errors.forEach((error) => { if (['400', '404', '412', '422'].includes(error.status)) { - return this.notifications.error(error.detail); + return this.pixToast.sendErrorNotification({ message: error.detail }); } - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); }); } } diff --git a/admin/app/controllers/authenticated/trainings/training.js b/admin/app/controllers/authenticated/trainings/training.js index dafb6e56ef3..d1054fa4d1b 100644 --- a/admin/app/controllers/authenticated/trainings/training.js +++ b/admin/app/controllers/authenticated/trainings/training.js @@ -4,7 +4,7 @@ import { service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; export default class Training extends Controller { - @service notifications; + @service pixToast; @service accessControl; @tracked isEditMode = false; @@ -25,10 +25,10 @@ export default class Training extends Controller { this.model[key] = trainingFormData[key]; } await this.model.save(); - this.notifications.success('Le contenu formatif a été mis à jour avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Le contenu formatif a été mis à jour avec succès.' }); this.toggleEditMode(); } catch (error) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } } } diff --git a/admin/app/controllers/authenticated/trainings/training/target-profiles.js b/admin/app/controllers/authenticated/trainings/training/target-profiles.js index 02a35a97507..dded32adfec 100644 --- a/admin/app/controllers/authenticated/trainings/training/target-profiles.js +++ b/admin/app/controllers/authenticated/trainings/training/target-profiles.js @@ -9,7 +9,7 @@ export default class TrainingDetailsTargetProfilesController extends Controller @tracked targetProfilesToAttach = ''; @service accessControl; - @service notifications; + @service pixToast; get canAttachTargetProfiles() { return this.accessControl.hasAccessToTrainingsActionsScope; @@ -55,7 +55,7 @@ export default class TrainingDetailsTargetProfilesController extends Controller ); } this.targetProfilesToAttach = ''; - return this.notifications.success(message.join(''), { htmlContent: true }); + return this.pixToast.sendSuccessNotification({ message: message.join('') }); } catch (responseError) { this._handleResponseError(responseError); } @@ -63,13 +63,13 @@ export default class TrainingDetailsTargetProfilesController extends Controller _handleResponseError({ errors }) { if (!errors) { - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } errors.forEach((error) => { if (['404', '412'].includes(error.status)) { - return this.notifications.error(error.detail); + return this.pixToast.sendErrorNotification({ message: error.detail }); } - return this.notifications.error('Une erreur est survenue.'); + return this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); }); } diff --git a/admin/app/controllers/authenticated/trainings/training/triggers/edit.js b/admin/app/controllers/authenticated/trainings/training/triggers/edit.js index e9f2ae484d9..10bd5604068 100644 --- a/admin/app/controllers/authenticated/trainings/training/triggers/edit.js +++ b/admin/app/controllers/authenticated/trainings/training/triggers/edit.js @@ -7,7 +7,7 @@ export default class TrainingEditTriggersController extends Controller { @service intl; @service router; @service store; - @service notifications; + @service pixToast; queryParams = ['type']; @@ -43,10 +43,10 @@ export default class TrainingEditTriggersController extends Controller { await this.store .createRecord('training-trigger', { ...data, type: this.type, training: this.model.training }) .save({ adapterOptions: { tubes: this.selectedTubes, trainingId: this.model.training.id } }); - this.notifications.success('Le déclencheur a été créé avec succès.'); + this.pixToast.sendSuccessNotification({ message: 'Le déclencheur a été créé avec succès.' }); this.goBackToTraining(); } catch (error) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } } diff --git a/admin/app/routes/authenticated/target-profiles/list.js b/admin/app/routes/authenticated/target-profiles/list.js index 777463ce0e1..013d81fb944 100644 --- a/admin/app/routes/authenticated/target-profiles/list.js +++ b/admin/app/routes/authenticated/target-profiles/list.js @@ -3,7 +3,7 @@ import { service } from '@ember/service'; import isEmpty from 'lodash/isEmpty'; export default class ListRoute extends Route { - @service notifications; + @service pixToast; @service store; @service accessControl; @@ -35,7 +35,7 @@ export default class ListRoute extends Route { }); } catch (errorResponse) { if (!isEmpty(errorResponse)) { - errorResponse.errors.forEach((error) => this.notifications.error(error.detail)); + errorResponse.errors.forEach((error) => this.pixToast.sendErrorNotification({ message: error.detail })); } return []; } diff --git a/admin/app/routes/authenticated/target-profiles/target-profile/training-summaries.js b/admin/app/routes/authenticated/target-profiles/target-profile/training-summaries.js index a28a908daf8..103668e3f82 100644 --- a/admin/app/routes/authenticated/target-profiles/target-profile/training-summaries.js +++ b/admin/app/routes/authenticated/target-profiles/target-profile/training-summaries.js @@ -4,7 +4,7 @@ import isEmpty from 'lodash/isEmpty'; export default class TargetProfileTrainingsRoute extends Route { @service accessControl; - @service notifications; + @service pixToast; @service store; queryParams = { @@ -30,7 +30,7 @@ export default class TargetProfileTrainingsRoute extends Route { }); } catch (errorResponse) { if (!isEmpty(errorResponse)) { - errorResponse.errors.forEach((error) => this.notifications.error(error.detail)); + errorResponse.errors.forEach((error) => this.pixToast.sendErrorNotification({ message: error.detail })); } return []; } diff --git a/admin/app/routes/authenticated/trainings/list.js b/admin/app/routes/authenticated/trainings/list.js index 61eee93da0e..0bf41aca025 100644 --- a/admin/app/routes/authenticated/trainings/list.js +++ b/admin/app/routes/authenticated/trainings/list.js @@ -4,7 +4,7 @@ import isEmpty from 'lodash/isEmpty'; export default class ListRoute extends Route { @service accessControl; - @service notifications; + @service pixToast; @service store; queryParams = { @@ -34,7 +34,7 @@ export default class ListRoute extends Route { }); } catch (errorResponse) { if (!isEmpty(errorResponse)) { - errorResponse.errors.forEach((error) => this.notifications.error(error.detail)); + errorResponse.errors.forEach((error) => this.pixToast.sendErrorNotification({ message: error.detail })); } return []; } From f6f21647c62dea9625648aac0368dfe7b182ddc3 Mon Sep 17 00:00:00 2001 From: AndreiaPena Date: Mon, 18 Nov 2024 18:15:45 +0100 Subject: [PATCH 08/10] =?UTF-8?q?=E2=9C=A8=20admin:=20use=20Pix=20Toast=20?= =?UTF-8?q?on=20cross=20team=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/learning-content.gjs | 20 +++++++++------- .../app/components/common/tubes-selection.gjs | 8 +++---- admin/app/components/stages/update-stage.gjs | 9 +++---- .../target-profiles/target-profile.gjs | 24 ++++++++++--------- admin/app/services/error-notifier.js | 8 ++++--- admin/app/services/error-response-handler.js | 10 ++++---- 6 files changed, 43 insertions(+), 36 deletions(-) diff --git a/admin/app/components/administration/common/learning-content.gjs b/admin/app/components/administration/common/learning-content.gjs index 635458bde70..df085a01bde 100644 --- a/admin/app/components/administration/common/learning-content.gjs +++ b/admin/app/components/administration/common/learning-content.gjs @@ -7,7 +7,7 @@ import Component from '@glimmer/component'; import AdministrationBlockLayout from '../block-layout'; export default class LearningContent extends Component { - @service notifications; + @service pixToast; @service store; @service intl; @@ -15,10 +15,12 @@ export default class LearningContent extends Component { async refreshLearningContent() { try { await this.store.adapterFor('learning-content-cache').refreshCacheEntries(); - this.notifications.success('La demande de rechargement du cache a bien été prise en compte.'); - } catch (err) { + this.pixToast.sendSuccessNotification({ + message: 'La demande de rechargement du cache a bien été prise en compte.', + }); + } catch (_) { const genericErrorMessage = this.intl.t('common.notifications.generic-error'); - this.notifications.error(genericErrorMessage); + this.pixToast.sendErrorNotification({ message: genericErrorMessage }); } } @@ -26,11 +28,11 @@ export default class LearningContent extends Component { async createLearningContentReleaseAndRefreshCache() { try { await this.store.adapterFor('learning-content-cache').createLearningContentReleaseAndRefreshCache(); - this.notifications.success( - 'La création de la version du référentiel et le rechargement du cache a bien été prise en compte.', - ); - } catch (err) { - this.notifications.error('Une erreur est survenue.'); + this.pixToast.sendSuccessNotification({ + message: 'La création de la version du référentiel et le rechargement du cache a bien été prise en compte.', + }); + } catch (_) { + this.pixToast.sendErrorNotification({ message: 'Une erreur est survenue.' }); } }