Skip to content

Commit

Permalink
[FEATURE] simplifie les bannière d'info sur orga (PIX-13968) (#10139)
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelB committed Sep 19, 2024
1 parent 7b61678 commit e314c3c
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 222 deletions.
35 changes: 35 additions & 0 deletions orga/app/components/banner/certification.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import PixBanner from '@1024pix/pix-ui/components/pix-banner';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { t } from 'ember-intl';
import ENV from 'pix-orga/config/environment';

export default class InformationBanner extends Component {
@service currentUser;
@service router;
@service dayjs;

get displayCertificationBanner() {
const timeToDisplay = ENV.APP.CERTIFICATION_BANNER_DISPLAY_DATES.split(' ');
const actualMonth = this.dayjs.self().format('MM');
return this.currentUser.isSCOManagingStudents && timeToDisplay.includes(actualMonth);
}

get year() {
return this.dayjs.self().format('YYYY');
}

<template>
{{#if this.displayCertificationBanner}}
<PixBanner @type="warning">
{{t
"banners.certification.message"
documentationLink="https://cloud.pix.fr/s/DEarDXyxFxM78ps"
linkClasses="link link--banner link--bold link--underlined"
htmlSafe=true
year=this.year
}}
</PixBanner>
{{/if}}
</template>
}
64 changes: 0 additions & 64 deletions orga/app/components/banner/information.gjs

This file was deleted.

46 changes: 46 additions & 0 deletions orga/app/components/banner/sco-communication.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import PixBanner from '@1024pix/pix-ui/components/pix-banner';
import { LinkTo } from '@ember/routing';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { t } from 'ember-intl';

export default class ScommunicationBanner extends Component {
@service currentUser;
@service router;

get shouldDisplayBanner() {
return (
[
'authenticated.campaigns.list.my-campaigns',
'authenticated.campaigns.list.all-campaigns',
'authenticated.team.list.members',
'authenticated.sco-organization-participants.list',
].includes(this.router.currentRouteName) && this.currentUser.isSCOManagingStudents
);
}
get importParticipantUrl() {
return this.router.urlFor('authenticated.import-organization-participants');
}

<template>
{{#if this.shouldDisplayBanner}}
<PixBanner @type="communication-orga">
{{t "banners.import.message"}}
<ol class="banner-list">
<li>
{{t "banners.import.step1a" htmlSafe=true}}
<LinkTo
@route="authenticated.import-organization-participants"
class="link link--banner link--bold link--underlined"
>
{{t "banners.import.step1b"}}
</LinkTo>
{{t "banners.import.step1c"}}
</li>
<li>{{t "banners.import.step2" htmlSafe=true}}</li>
<li>{{t "banners.import.step3" htmlSafe=true}}</li>
</ol>
</PixBanner>
{{/if}}
</template>
}
6 changes: 4 additions & 2 deletions orga/app/components/banner/top-banners.gjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Information from './information';
import Certification from './certification';
import LanguageAvailability from './language-availability';
import Scommunication from './sco-communication';
import Survey from './survey';

<template>
<div class="top-banners">
<Information />
<Certification />
<Scommunication />
<LanguageAvailability />
<Survey />
</div>
Expand Down
1 change: 1 addition & 0 deletions orga/app/styles/components/banner/index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import 'top-banners';
@import 'sco-communication'
4 changes: 4 additions & 0 deletions orga/app/styles/components/banner/sco-communication.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.banner-list {
margin-left: var(--pix-spacing-4x);
list-style: decimal
}
70 changes: 70 additions & 0 deletions orga/tests/integration/components/banner/certification-test.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { render } from '@1024pix/ember-testing-library';
import Service from '@ember/service';
import Certification from 'pix-orga/components/banner/certification';
import { module, test } from 'qunit';
import sinon from 'sinon';

import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering';

module('Integration | Component | Banner::Certification', function (hooks) {
setupIntlRenderingTest(hooks);

module('When it is certification period', function (hooks) {
let dayjs;

hooks.beforeEach(function () {
dayjs = this.owner.lookup('service:dayjs');
sinon.stub(dayjs.self.prototype, 'format').withArgs('MM').returns('04').withArgs('YYYY').returns('2001');
});

hooks.afterEach(function () {
sinon.restore();
});

module('when prescriber’s organization is of type SCO that manages students', function () {
class CurrentUserStub extends Service {
organization = { isSco: true };
isSCOManagingStudents = true;
}
test('should render the current year', async function (assert) {
// given
this.owner.register('service:current-user', CurrentUserStub);

// when
const screen = await render(<template><Certification /></template>);

// then
assert.ok(screen.getByText(/2001/));
});
test('should render the info link for finalize certification session', async function (assert) {
// given
this.owner.register('service:current-user', CurrentUserStub);

// when
const screen = await render(<template><Certification /></template>);

const link = screen.getByRole('link', { name: 'finaliser les sessions dans Pix Certif' });

// then
assert.strictEqual(link.href, 'https://cloud.pix.fr/s/DEarDXyxFxM78ps');
});
});

module('when prescriber’s organization is not of type SCO that manages students', function () {
test('should not render the banner regardless of the period', async function (assert) {
// given
class CurrentUserStub extends Service {
organization = { isSco: false };
isSCOManagingStudents = false;
}
this.owner.register('service:current-user', CurrentUserStub);

// when
await render(<template><Certification /></template>);

// then
assert.dom('.pix-banner').doesNotExist();
});
});
});
});
152 changes: 0 additions & 152 deletions orga/tests/integration/components/banner/information_test.gjs

This file was deleted.

Loading

0 comments on commit e314c3c

Please sign in to comment.