-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(orga): add generate username password modal component
- Loading branch information
Showing
8 changed files
with
151 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
orga/app/components/sco-organization-participant/generate-username-password-modal.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,39 @@ | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import PixMessage from '@1024pix/pix-ui/components/pix-message'; | ||
import PixModal from '@1024pix/pix-ui/components/pix-modal'; | ||
import Component from '@glimmer/component'; | ||
import { t } from 'ember-intl'; | ||
import { not } from 'ember-truth-helpers'; | ||
|
||
export default class GenerateUsernamePasswordModal extends Component { | ||
get isEnabled() { | ||
return this.args.totalAffectedStudents > 0; | ||
} | ||
|
||
<template> | ||
<PixModal | ||
@title={{t "pages.sco-organization-participants.generate-username-password-modal.title"}} | ||
@showModal={{@showModal}} | ||
@onCloseButtonClick={{@onCloseModal}} | ||
> | ||
<:content> | ||
<section class="generate-username-password-modal__content"> | ||
<PixMessage @type="warning" @withIcon={{true}}>{{t | ||
"pages.sco-organization-participants.generate-username-password-modal.warning-message" | ||
}}</PixMessage> | ||
<p>{{t "pages.sco-organization-participants.generate-username-password-modal.content-message-1"}}</p> | ||
<p>{{t "pages.sco-organization-participants.generate-username-password-modal.content-message-2"}}</p> | ||
<p>{{t "pages.sco-organization-participants.generate-username-password-modal.content-message-3"}}</p> | ||
</section> | ||
</:content> | ||
<:footer> | ||
<PixButton @variant="secondary" @triggerAction={{@onCloseModal}}> | ||
{{t "common.actions.cancel"}} | ||
</PixButton> | ||
<PixButton @triggerAction={{@onTriggerAction}} @isDisabled={{not this.isEnabled}}> | ||
{{t "common.actions.confirm"}} | ||
</PixButton> | ||
</:footer> | ||
</PixModal> | ||
</template> | ||
} |
5 changes: 5 additions & 0 deletions
5
orga/app/components/sco-organization-participant/generate-username-password-modal.scss
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,5 @@ | ||
.generate-username-password-modal__content { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--pix-spacing-4x); | ||
} |
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
82 changes: 82 additions & 0 deletions
82
...gration/components/sco-organization-participant/generate-username-password-modal-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,82 @@ | ||
import { clickByName, render } from '@1024pix/ember-testing-library'; | ||
import { t } from 'ember-intl/test-support'; | ||
import GenerateUsernamePasswordModal from 'pix-orga/components/sco-organization-participant/generate-username-password-modal'; | ||
import { module, test } from 'qunit'; | ||
import sinon from 'sinon'; | ||
|
||
import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering'; | ||
|
||
module('Integration | Component | ScoOrganizationParticipant::GenerateUsernamePasswordModal', function (hooks) { | ||
setupIntlRenderingTest(hooks); | ||
|
||
test('renders the modal', async function (assert) { | ||
const onCloseModal = sinon.spy(); | ||
const onTriggerAction = sinon.spy(); | ||
const totalAffectedStudents = 1; | ||
|
||
const screen = await render( | ||
<template> | ||
<GenerateUsernamePasswordModal | ||
@showModal={{true}} | ||
@onCloseModal={{onCloseModal}} | ||
@onTriggerAction={{onTriggerAction}} | ||
@totalAffectedStudents={{totalAffectedStudents}} | ||
/> | ||
</template>, | ||
); | ||
|
||
assert.ok( | ||
screen.getByRole('heading', { | ||
name: t('pages.sco-organization-participants.generate-username-password-modal.title'), | ||
}), | ||
); | ||
|
||
await clickByName(t('common.actions.confirm')); | ||
assert.ok(onTriggerAction.calledOnce); | ||
}); | ||
|
||
test('disable submit button when no affected students', async function (assert) { | ||
const onCloseModal = sinon.spy(); | ||
const onTriggerAction = sinon.spy(); | ||
const totalAffectedStudents = 0; | ||
|
||
const screen = await render( | ||
<template> | ||
<GenerateUsernamePasswordModal | ||
@showModal={{true}} | ||
@onCloseModal={{onCloseModal}} | ||
@onTriggerAction={{onTriggerAction}} | ||
@totalAffectedStudents={{totalAffectedStudents}} | ||
/> | ||
</template>, | ||
); | ||
|
||
const heading = screen.getByRole('heading', { | ||
name: t('pages.sco-organization-participants.generate-username-password-modal.title'), | ||
}); | ||
const button = screen.getByRole('button', { name: t('common.actions.confirm') }); | ||
|
||
assert.ok(heading); | ||
assert.dom(button).hasAttribute('disabled'); | ||
}); | ||
|
||
test('close the modal', async function (assert) { | ||
const onCloseModal = sinon.spy(); | ||
const onTriggerAction = sinon.spy(); | ||
const totalAffectedStudents = 1; | ||
|
||
await render( | ||
<template> | ||
<GenerateUsernamePasswordModal | ||
@showModal={{true}} | ||
@onCloseModal={{onCloseModal}} | ||
@onTriggerAction={{onTriggerAction}} | ||
@totalAffectedStudents={{totalAffectedStudents}} | ||
/> | ||
</template>, | ||
); | ||
|
||
await clickByName(t('common.actions.cancel')); | ||
assert.ok(onCloseModal.calledOnce); | ||
}); | ||
}); |
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
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