-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
283 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
@import 'top-banners'; | ||
@import 'sco-communication' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
70
orga/tests/integration/components/banner/certification-test.gjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
152
orga/tests/integration/components/banner/information_test.gjs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.