-
-
Notifications
You must be signed in to change notification settings - Fork 303
[Remove Vuetify from Studio] 'Activation failed' page #6026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: unstable
Are you sure you want to change the base?
Changes from all commits
03897c4
04827f1
790052e
6c76e37
308dbdb
cd5a893
265ce0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,62 +1,84 @@ | ||
| <template> | ||
|
|
||
| <MessageLayout | ||
| <StudioMessageLayout | ||
| :header="$tr('activationExpiredTitle')" | ||
| :text="$tr('activationExpiredText')" | ||
| > | ||
| <VForm | ||
| ref="form" | ||
| lazy-validation | ||
| <form | ||
| class="request-activation-form" | ||
| novalidate | ||
| @submit.prevent="requestActivationLink" | ||
| > | ||
| <Banner | ||
| :text="$tr('activationRequestFailed')" | ||
| :value="error" | ||
| <StudioBanner | ||
| v-if="error" | ||
| error | ||
| class="mb-4" | ||
| /> | ||
| <EmailField | ||
| class="banner" | ||
| > | ||
| {{ $tr('activationRequestFailed') }} | ||
| </StudioBanner> | ||
| <StudioEmailField | ||
| v-model="email" | ||
| autofocus | ||
| :label="$tr('emailLabel')" | ||
| :errorMessages="errors.email ? [emailErrorText] : []" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Resolved — addressed in the current code. suggestion: With
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Resolved — addressed in the current code. suggestion: With |
||
| /> | ||
| <KButton | ||
| primary | ||
| class="w-100" | ||
| :text="$tr('submitButton')" | ||
| type="submit" | ||
| /> | ||
| </VForm> | ||
| </MessageLayout> | ||
| </form> | ||
| </StudioMessageLayout> | ||
|
|
||
| </template> | ||
|
|
||
|
|
||
| <script> | ||
|
|
||
| import { mapActions } from 'vuex'; | ||
| import MessageLayout from '../../components/MessageLayout'; | ||
| import EmailField from 'shared/views/form/EmailField'; | ||
| import Banner from 'shared/views/Banner'; | ||
| import StudioMessageLayout from '../../components/StudioMessageLayout'; | ||
| import StudioEmailField from '../../components/form/StudioEmailField'; | ||
| import StudioBanner from 'shared/views/StudioBanner'; | ||
| import commonStrings from 'shared/translator'; | ||
| import { generateFormMixin } from 'shared/mixins'; | ||
|
|
||
| const formMixin = generateFormMixin({ | ||
| email: { | ||
| required: true, | ||
| validator: v => Boolean(v && v.trim()) && /.+@.+\..+/.test(v), | ||
| }, | ||
| }); | ||
|
|
||
| export default { | ||
| name: 'RequestNewActivationLink', | ||
| components: { | ||
| MessageLayout, | ||
| EmailField, | ||
| Banner, | ||
| StudioMessageLayout, | ||
| StudioEmailField, | ||
| StudioBanner, | ||
| }, | ||
| mixins: [formMixin], | ||
| data() { | ||
| return { | ||
| email: '', | ||
| error: false, | ||
| }; | ||
| }, | ||
| computed: { | ||
| emailErrorText() { | ||
| if (!this.email || !this.email.trim()) { | ||
| /* eslint-disable-next-line kolibri/vue-no-undefined-string-uses */ | ||
| return commonStrings.$tr('fieldRequired'); | ||
| } | ||
| return this.$tr('emailValidationMessage'); | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...mapActions('account', ['sendActivationLink']), | ||
| requestActivationLink() { | ||
| this.error = false; | ||
| if (this.$refs.form.validate()) { | ||
| this.sendActivationLink(this.email) | ||
| const formData = this.clean(); | ||
| if (this.validate(formData)) { | ||
| this.sendActivationLink(formData.email) | ||
| .then(() => { | ||
| this.$router.replace({ name: 'ActivationLinkReSent' }).catch(() => {}); | ||
| }) | ||
|
|
@@ -71,6 +93,8 @@ | |
| activationExpiredText: 'This activation link has been used already or has expired.', | ||
| submitButton: 'Submit', | ||
| activationRequestFailed: 'Failed to send a new activation link. Please try again.', | ||
| emailLabel: 'Email', | ||
| emailValidationMessage: 'Please enter a valid email address', | ||
| }, | ||
| }; | ||
|
|
||
|
|
@@ -79,6 +103,17 @@ | |
|
|
||
| <style lang="scss" scoped> | ||
|
|
||
| .request-activation-form { | ||
| width: 400px; | ||
| max-width: 100%; | ||
| text-align: left; | ||
| } | ||
|
|
||
| .banner { | ||
| width: 100%; | ||
| margin-bottom: 16px; | ||
| } | ||
|
|
||
| .w-100 { | ||
| width: 100%; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: The validation tests don't assert the submit was blocked.
generateFormMixin's field setter validates on everyv-modelupdate (shared/mixins.js:406-413), so the message is already rendered by the end ofuser.type— theclickis incidental and the assertion passes regardless of whatrequestActivationLinkdoes. Both this test and the empty-email one would stay green if submit dispatched with invalid data.Adding
expect(sendActivationLink).not.toHaveBeenCalled()closes the gap;renderComponentalready accepts an injectable mock, so it just needs hoisting into the test.forgotPassword.spec.js:45-56is the existing pattern.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LightCreator1007, this seems like a valid add that would make the test more robust. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably worth adding the
expect(sendActivationLink).not.toHaveBeenCalled()as suggested to close the gap.