diff --git a/api/db/seeds/data/common/organization-builder.js b/api/db/seeds/data/common/organization-builder.js index a938d366fa9..f14a87b537b 100644 --- a/api/db/seeds/data/common/organization-builder.js +++ b/api/db/seeds/data/common/organization-builder.js @@ -96,7 +96,7 @@ async function _createProOrganization(databaseBuilder) { type: 'PRO', name: 'PRO Classic', isManagingStudents: false, - externalId: 'PRO_NOT_MANAGING', + externalId: null, adminIds: [USER_ID_ADMIN_ORGANIZATION], memberIds: [USER_ID_MEMBER_ORGANIZATION], features: [ diff --git a/orga/app/components/layout/sidebar.gjs b/orga/app/components/layout/sidebar.gjs new file mode 100644 index 00000000000..51ccda806a8 --- /dev/null +++ b/orga/app/components/layout/sidebar.gjs @@ -0,0 +1,164 @@ +import PixNavigation from '@1024pix/pix-ui/components/pix-navigation'; +import PixNavigationButton from '@1024pix/pix-ui/components/pix-navigation-button'; +import PixNavigationSeparator from '@1024pix/pix-ui/components/pix-navigation-separator'; +import { LinkTo } from '@ember/routing'; +import { service } from '@ember/service'; +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { t } from 'ember-intl'; + +import OrganizationPlacesOrCreditInfo from './organization-places-or-credit-info'; +import SchoolSessionManagement from './school-session-management'; +import UserLoggedMenu from './user-logged-menu'; + +export default class SidebarMenu extends Component { + @service currentUser; + @service url; + + @tracked canShowCredit; + + handleCanShowCredit = (value) => { + this.canShowCredit = value; + }; + + get redirectionRoute() { + if (this.shouldDisplayMissionsEntry) { + return 'authenticated.missions'; + } else { + return 'authenticated.campaigns'; + } + } + + get documentationUrl() { + return this.currentUser.organization.documentationUrl; + } + + get shouldDisplayCertificationsEntry() { + return this.currentUser.isAdminInOrganization && this.currentUser.isSCOManagingStudents; + } + + get shouldDisplayAttestationsEntry() { + return this.currentUser.canAccessAttestationsPage; + } + + get shouldDisplayPlacesEntry() { + return this.currentUser.canAccessPlacesPage; + } + + get shouldDisplayMissionsEntry() { + return this.currentUser.canAccessMissionsPage; + } + + get shouldDisplayCampaignsEntry() { + return this.currentUser.canAccessCampaignsPage; + } + + get shouldDisplayStatisticsEntry() { + return this.currentUser.canAccessStatisticsPage; + } + + get shouldDisplaySeparator() { + return this.shouldDisplayMissionsEntry || this.shouldDisplayPlacesEntry || this.canShowCredit; + } + + get organizationLearnersList() { + if (this.currentUser.isSCOManagingStudents) { + return { + route: 'authenticated.sco-organization-participants', + label: 'navigation.main.sco-organization-participants', + }; + } else if (this.currentUser.isSUPManagingStudents) { + return { + route: 'authenticated.sup-organization-participants', + label: 'navigation.main.sup-organization-participants', + }; + } else if (this.currentUser.canAccessMissionsPage) { + return { + route: 'authenticated.organization-participants', + label: 'navigation.main.sco-organization-participants', + }; + } else { + return { + route: 'authenticated.organization-participants', + label: 'navigation.main.organization-participants', + }; + } + } + + +} diff --git a/orga/app/components/layout/sidebar.hbs b/orga/app/components/layout/sidebar.hbs deleted file mode 100644 index 271dc13a21a..00000000000 --- a/orga/app/components/layout/sidebar.hbs +++ /dev/null @@ -1,77 +0,0 @@ - - <:brand> - - - - - <:navElements> - {{#if this.shouldDisplayCampaignsEntry}} - - {{t "navigation.main.campaigns"}} - {{/if}} - - {{#if this.shouldDisplayCertificationsEntry}} - - {{t "navigation.main.certifications"}} - {{/if}} - - {{#if this.shouldDisplayAttestationsEntry}} - - {{t "navigation.main.attestations"}} - {{/if}} - - {{#if this.shouldDisplayMissionsEntry}} - - {{t "navigation.main.missions"}} - - {{/if}} - - - {{t this.organizationLearnersList.label}} - - - - {{t "navigation.main.team"}} - - - {{#if this.shouldDisplayStatisticsEntry}} - - {{t "navigation.main.statistics"}} - - {{/if}} - - {{#if this.shouldDisplayPlacesEntry}} - - {{t "navigation.main.places"}} - - {{/if}} - - {{#if this.documentationUrl}} - - {{t "navigation.main.documentation"}} - - {{/if}} - - {{#if this.shouldDisplayMissionsEntry}} - - {{t "navigation.main.support"}} - - {{/if}} - - <:footer> - - - {{#if this.shouldDisplaySeparator}} - - {{/if}} - - - \ No newline at end of file diff --git a/orga/app/components/layout/sidebar.js b/orga/app/components/layout/sidebar.js deleted file mode 100644 index b840065fc7b..00000000000 --- a/orga/app/components/layout/sidebar.js +++ /dev/null @@ -1,78 +0,0 @@ -import { service } from '@ember/service'; -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; - -export default class SidebarMenu extends Component { - @service currentUser; - @service url; - - @tracked canShowCredit; - - handleCanShowCredit = (value) => { - this.canShowCredit = value; - }; - - get redirectionRoute() { - if (this.shouldDisplayMissionsEntry) { - return 'authenticated.missions'; - } else { - return 'authenticated.campaigns'; - } - } - - get documentationUrl() { - return this.currentUser.organization.documentationUrl; - } - - get shouldDisplayCertificationsEntry() { - return this.currentUser.isAdminInOrganization && this.currentUser.isSCOManagingStudents; - } - - get shouldDisplayAttestationsEntry() { - return this.currentUser.canAccessAttestationsPage; - } - - get shouldDisplayPlacesEntry() { - return this.currentUser.canAccessPlacesPage; - } - - get shouldDisplayMissionsEntry() { - return this.currentUser.canAccessMissionsPage; - } - - get shouldDisplayCampaignsEntry() { - return this.currentUser.canAccessCampaignsPage; - } - - get shouldDisplayStatisticsEntry() { - return this.currentUser.canAccessStatisticsPage; - } - - get shouldDisplaySeparator() { - return this.shouldDisplayMissionsEntry || this.shouldDisplayPlacesEntry || this.canShowCredit; - } - - get organizationLearnersList() { - if (this.currentUser.isSCOManagingStudents) { - return { - route: 'authenticated.sco-organization-participants', - label: 'navigation.main.sco-organization-participants', - }; - } else if (this.currentUser.isSUPManagingStudents) { - return { - route: 'authenticated.sup-organization-participants', - label: 'navigation.main.sup-organization-participants', - }; - } else if (this.currentUser.canAccessMissionsPage) { - return { - route: 'authenticated.organization-participants', - label: 'navigation.main.sco-organization-participants', - }; - } else { - return { - route: 'authenticated.organization-participants', - label: 'navigation.main.organization-participants', - }; - } - } -} diff --git a/orga/app/components/layout/user-logged-menu.js b/orga/app/components/layout/user-logged-menu.gjs similarity index 56% rename from orga/app/components/layout/user-logged-menu.js rename to orga/app/components/layout/user-logged-menu.gjs index b371e362710..e47a750e47a 100644 --- a/orga/app/components/layout/user-logged-menu.js +++ b/orga/app/components/layout/user-logged-menu.gjs @@ -1,6 +1,9 @@ +import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link'; +import PixStructureSwitcher from '@1024pix/pix-ui/components/pix-structure-switcher'; import { action } from '@ember/object'; import { service } from '@ember/service'; import Component from '@glimmer/component'; +import { t } from 'ember-intl'; export default class UserLoggedMenu extends Component { @service currentUser; @@ -22,10 +25,18 @@ export default class UserLoggedMenu extends Component { } return memberships .slice() - .map((membership) => ({ - label: `${membership.organization.get('name')} (${membership.organization.get('externalId')})`, - value: membership.organization.get('id'), - })) + .map((membership) => { + let label = `${membership.organization.get('name')}`; + + if (membership.organization.get('externalId')) { + label = label.concat(` (${membership.organization.get('externalId')})`); + } + + return { + label, + value: membership.organization.get('id'), + }; + }) .sort((a, b) => a.label.localeCompare(b.label)); } @@ -51,4 +62,26 @@ export default class UserLoggedMenu extends Component { await this.currentUser.load(); this.args.onChangeOrganization(); } + + } diff --git a/orga/app/components/layout/user-logged-menu.hbs b/orga/app/components/layout/user-logged-menu.hbs deleted file mode 100644 index ed421ecd16a..00000000000 --- a/orga/app/components/layout/user-logged-menu.hbs +++ /dev/null @@ -1,17 +0,0 @@ -

- - {{this.currentUser.prescriber.firstName}} - {{this.currentUser.prescriber.lastName}} - -
- {{this.organizationNameAndExternalId}} -

-{{#if this.belongsToSeveralOrganizations}} - -{{/if}} -{{t "navigation.user-logged-menu.logout"}} \ No newline at end of file diff --git a/orga/tests/integration/components/layout/user-logged-menu-test.js b/orga/tests/integration/components/layout/user-logged-menu-test.js index 34dae84780e..91ec9fa4dd9 100644 --- a/orga/tests/integration/components/layout/user-logged-menu-test.js +++ b/orga/tests/integration/components/layout/user-logged-menu-test.js @@ -24,7 +24,7 @@ module('Integration | Component | Layout::UserLoggedMenu', function () { }), }); organization2 = Object.create({ id: '2', name: 'Organization 2', externalId: 'EXT2' }); - organization3 = Object.create({ id: '3', name: 'Organization 3', externalId: 'EXT3' }); + organization3 = Object.create({ id: '3', name: 'Organization 3' }); loadStub = sinon.stub(); class CurrentUserStub extends Service { @@ -75,7 +75,7 @@ module('Integration | Component | Layout::UserLoggedMenu', function () { // then assert.ok(await screen.findByRole('option', { name: `${organization2.name} (${organization2.externalId})` })); - assert.ok(await screen.findByRole('option', { name: `${organization3.name} (${organization3.externalId})` })); + assert.ok(await screen.findByRole('option', { name: `${organization3.name}` })); }); test('should redirect to authenticated route before reload the current user', async function (assert) { diff --git a/orga/tests/unit/components/user-logged-menu-test.js b/orga/tests/unit/components/user-logged-menu-test.js deleted file mode 100644 index 6f86f24bfe5..00000000000 --- a/orga/tests/unit/components/user-logged-menu-test.js +++ /dev/null @@ -1,41 +0,0 @@ -import { setupTest } from 'ember-qunit'; -import { module, test } from 'qunit'; - -import createGlimmerComponent from '../../helpers/create-glimmer-component'; - -module('Unit | Component | user-logged-menu', (hooks) => { - setupTest(hooks); - - let component; - - hooks.beforeEach(function () { - component = createGlimmerComponent('component:layout/user-logged-menu'); - }); - - module('organizationNameAndExternalId', () => { - test('should return the organization name if the externalId is not defined', function (assert) { - // given - const expectedOrganizationName = 'expectedOrganizationName'; - const currentUser = { organization: { name: expectedOrganizationName } }; - component.currentUser = currentUser; - - // when - const computedOrganizationName = component.organizationNameAndExternalId; - // then - assert.strictEqual(computedOrganizationName, expectedOrganizationName); - }); - - test('should return the organization name and externalId if the externalId is defined', function (assert) { - // given - const expectedOrganizationName = 'expectedOrganizationName'; - const expectedExternalId = 'expectedExternalId'; - const currentUser = { organization: { name: expectedOrganizationName, externalId: expectedExternalId } }; - component.currentUser = currentUser; - - // when - const computedOrganizationName = component.organizationNameAndExternalId; - // then - assert.strictEqual(computedOrganizationName, `${expectedOrganizationName} (${expectedExternalId})`); - }); - }); -});