Repository navigation
Remove Vuetify from Forgot password page #6334
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
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,63 +1,89 @@ | ||
| <template> | ||
|
|
||
| <MessageLayout | ||
| <StudioMessageLayout | ||
| :header="$tr('forgotPasswordTitle')" | ||
| :text="$tr('forgotPasswordPrompt')" | ||
| > | ||
| <VForm | ||
| ref="form" | ||
| lazy-validation | ||
| <form | ||
| class="forgot-password-form" | ||
| novalidate | ||
| @submit.prevent="submit" | ||
| > | ||
| <Banner | ||
| :text="$tr('forgotPasswordFailed')" | ||
| :value="error" | ||
| <StudioBanner | ||
|
Member
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. suggestion: Screen readers do not announce this banner when it appears, because |
||
| v-if="error" | ||
| error | ||
| class="mb-4" | ||
| class="banner" | ||
| data-testid="error-banner" | ||
| /> | ||
| <EmailField | ||
| > | ||
| {{ $tr('forgotPasswordFailed') }} | ||
| </StudioBanner> | ||
| <StudioEmailField | ||
| v-model="email" | ||
| autofocus | ||
| data-testid="email-field" | ||
| :label="$tr('emailLabel')" | ||
| :errorMessages="showEmailError && errors.email ? [emailErrorText] : []" | ||
| @blur="showEmailError = true" | ||
| /> | ||
| <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: 'ForgotPassword', | ||
| components: { | ||
| MessageLayout, | ||
| EmailField, | ||
| Banner, | ||
| StudioMessageLayout, | ||
| StudioEmailField, | ||
| StudioBanner, | ||
| }, | ||
| mixins: [formMixin], | ||
| data() { | ||
| return { | ||
| email: '', | ||
| error: false, | ||
| showEmailError: 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', ['sendPasswordResetLink']), | ||
| submit() { | ||
| this.error = false; | ||
| if (this.$refs.form.validate()) { | ||
| this.sendPasswordResetLink(this.email) | ||
| this.showEmailError = true; | ||
| const formData = this.clean(); | ||
| if (this.validate(formData)) { | ||
| this.sendPasswordResetLink(formData.email) | ||
| .then(() => { | ||
| this.$router | ||
| .push({ | ||
|
|
@@ -77,6 +103,8 @@ | |
| 'Please enter your email address to receive instructions for resetting your password', | ||
| submitButton: 'Submit', | ||
| forgotPasswordFailed: 'Failed to send a password reset link. Please try again.', | ||
| emailLabel: 'Email', | ||
| emailValidationMessage: 'Please enter a valid email', | ||
| }, | ||
| }; | ||
|
|
||
|
|
@@ -85,6 +113,17 @@ | |
|
|
||
| <style lang="scss" scoped> | ||
|
|
||
| .forgot-password-form { | ||
| width: 400px; | ||
|
Member
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. blocking: At 360px the form does not fit the screen, which fails "Mobile experience is reasonable" in #5932. The form is 400px wide inside a 328px column. On load, The cause is in |
||
| 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.
nitpick: These two new tests use
fireEventand read strings straight fromForgotPassword.$trs. The unit testing guide recommendsuserEvent, which types and tabs like a real user, andcreateTranslatorfor strings. With those changes all 7 tests pass and lint passes. The two tests also still fail when the blur gate or the blur handler is removed. The older tests in this file usefireEventand hard-coded strings too, so you can convert them in the same pass if you like.