diff options
author | Anike Arni <anikarni@gmail.com> | 2017-03-30 15:31:52 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-30 15:31:52 -0300 |
commit | 9f0cd9888c3b435a44a5d3ea1e1484618099cc84 (patch) | |
tree | 643d5442e50734ef43716769935e75062aabaddb /web-ui/src/account_recovery | |
parent | 7acb6843bd21dbf29cc7903964b52f6e21188df4 (diff) | |
parent | af0f6b1e655bba9fd42317b0332d7a314d673228 (diff) |
Merge pull request #1034 from pixelated/forgot-password-page
Makes account recovery flow public
Diffstat (limited to 'web-ui/src/account_recovery')
14 files changed, 157 insertions, 142 deletions
diff --git a/web-ui/src/account_recovery/account_recovery.html b/web-ui/src/account_recovery/account_recovery.html index f4601239..35054455 100644 --- a/web-ui/src/account_recovery/account_recovery.html +++ b/web-ui/src/account_recovery/account_recovery.html @@ -9,6 +9,6 @@ </head> <body> <div id="root"/> - <script type="text/javascript" src="/assets/account_recovery.js"></script> + <script type="text/javascript" src="/public/account_recovery.js"></script> </body> </html> diff --git a/web-ui/src/account_recovery/forms/admin_recovery_code_form.js b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.js index 3d97b191..5b9da350 100644 --- a/web-ui/src/account_recovery/forms/admin_recovery_code_form.js +++ b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.js @@ -21,7 +21,7 @@ import { translate } from 'react-i18next'; import InputField from 'src/common/input_field/input_field'; import SubmitButton from 'src/common/submit_button/submit_button'; -import './forms.scss'; +import './admin_recovery_code_form.scss'; export const AdminRecoveryCodeForm = ({ t, next }) => ( <form className='account-recovery-form admin-code' onSubmit={next}> @@ -32,7 +32,7 @@ export const AdminRecoveryCodeForm = ({ t, next }) => ( /> <h1>{t('account-recovery.admin-form.title')}</h1> <img - className='admin-codes-image' + className='admin-code-image' src='/public/images/account-recovery/admins_contact.svg' alt='' /> @@ -42,7 +42,7 @@ export const AdminRecoveryCodeForm = ({ t, next }) => ( <li>{t('account-recovery.admin-form.tip3')}</li> </ul> <InputField name='admin-code' label={t('account-recovery.admin-form.input-label')} /> - <SubmitButton buttonText={t('account-recovery.admin-form.button')} /> + <SubmitButton buttonText={t('account-recovery.button-next')} /> </form> ); diff --git a/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.scss b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.scss new file mode 100644 index 00000000..6dcbcc67 --- /dev/null +++ b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.scss @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. + */ + +.admin-code-image { + margin: 1em 0; + align-self: center; + height: 2.7em; +} diff --git a/web-ui/src/account_recovery/forms/admin_recovery_code_form.spec.js b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.spec.js index 0e922212..73c4c1e0 100644 --- a/web-ui/src/account_recovery/forms/admin_recovery_code_form.spec.js +++ b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.spec.js @@ -1,7 +1,7 @@ import { shallow } from 'enzyme'; import expect from 'expect'; import React from 'react'; -import { AdminRecoveryCodeForm } from 'src/account_recovery/forms/admin_recovery_code_form'; +import { AdminRecoveryCodeForm } from './admin_recovery_code_form'; describe('AdminRecoveryCodeForm', () => { let adminRecoveryCodeForm; @@ -28,7 +28,7 @@ describe('AdminRecoveryCodeForm', () => { }); it('renders button for next step', () => { - expect(adminRecoveryCodeForm.find('SubmitButton').props().buttonText).toEqual('account-recovery.admin-form.button'); + expect(adminRecoveryCodeForm.find('SubmitButton').props().buttonText).toEqual('account-recovery.button-next'); }); it('submits form to next step', () => { diff --git a/web-ui/src/account_recovery/forms/forms.scss b/web-ui/src/account_recovery/forms/forms.scss deleted file mode 100644 index 09d8f2ce..00000000 --- a/web-ui/src/account_recovery/forms/forms.scss +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2017 ThoughtWorks, Inc. - * - * Pixelated is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Pixelated is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. - */ - -.account-recovery-form { - display: flex; - flex-direction: column; - - img { - margin: 1em 0; - align-self: center; - } - - .user-code-form-content { - display: flex; - flex-direction: column; - align-items: center; - } - - .account-recovery-progress { - width: 100%; - } - - .admin-code-image { - height: 2.7em; - } - - .user-code-image { - height: 4em; - } - - .input-field-group { - margin-top: 0; - } -} - -.new-password { - .input-field-group:first-of-type { - margin-bottom: 0; - } -} - -@media only screen and (min-width : 500px) { - .account-recovery-form { - align-items: center; - - .account-recovery-progress, h1 { - width: 80%; - } - - .user-code-form-content { - flex-direction: row; - width: 80%; - - img { - margin: 1.6em; - } - } - } -} - -@media only screen and (min-width : 960px) { - .account-recovery-form { - .account-recovery-progress { - width: 80%; - margin-top: 0; - } - - h1 { - max-width: 80%; - width: auto; - } - - .input-field-group, .submit-button { - width: 60%; - align-self: center; - } - } -} diff --git a/web-ui/src/account_recovery/forms/new_password_form.js b/web-ui/src/account_recovery/new_password_form/new_password_form.js index 114366b3..f1097b0b 100644 --- a/web-ui/src/account_recovery/forms/new_password_form.js +++ b/web-ui/src/account_recovery/new_password_form/new_password_form.js @@ -22,12 +22,14 @@ import InputField from 'src/common/input_field/input_field'; import SubmitButton from 'src/common/submit_button/submit_button'; import BackLink from 'src/common/back_link/back_link'; +import './new_password_form.scss'; + export const NewPasswordForm = ({ t, previous }) => ( <form className='account-recovery-form new-password'> <img className='account-recovery-progress' src='/public/images/account-recovery/step_3.svg' - alt={t('account-recovery.new-password.image-description')} + alt={t('account-recovery.new-password-form.image-description')} /> <h1>{t('account-recovery.new-password-form.title')}</h1> <InputField @@ -38,12 +40,8 @@ export const NewPasswordForm = ({ t, previous }) => ( type='password' name='confirm-password' label={t('account-recovery.new-password-form.input-label2')} /> - <SubmitButton buttonText={t('account-recovery.new-password-form.button')} /> - <BackLink - text={t('account-recovery.back')} - onClick={previous} onKeyDown={previous} - role='button' - /> + <SubmitButton buttonText={t('account-recovery.button-next')} /> + <BackLink text={t('account-recovery.back')} onClick={previous} /> </form> ); diff --git a/web-ui/src/account_recovery/new_password_form/new_password_form.scss b/web-ui/src/account_recovery/new_password_form/new_password_form.scss new file mode 100644 index 00000000..77623262 --- /dev/null +++ b/web-ui/src/account_recovery/new_password_form/new_password_form.scss @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. + */ + +.new-password { + .input-field-group:first-of-type { + margin-bottom: 0; + } +} diff --git a/web-ui/src/account_recovery/forms/new_password_form.spec.js b/web-ui/src/account_recovery/new_password_form/new_password_form.spec.js index 5ac96b40..d2bd350c 100644 --- a/web-ui/src/account_recovery/forms/new_password_form.spec.js +++ b/web-ui/src/account_recovery/new_password_form/new_password_form.spec.js @@ -1,7 +1,7 @@ import { shallow } from 'enzyme'; import expect from 'expect'; import React from 'react'; -import { NewPasswordForm } from 'src/account_recovery/forms/new_password_form'; +import { NewPasswordForm } from './new_password_form'; describe('NewPasswordForm', () => { let newPasswordForm; @@ -30,16 +30,11 @@ describe('NewPasswordForm', () => { }); it('renders submit button', () => { - expect(newPasswordForm.find('SubmitButton').props().buttonText).toEqual('account-recovery.new-password-form.button'); + expect(newPasswordForm.find('SubmitButton').props().buttonText).toEqual('account-recovery.button-next'); }); it('returns to previous step on link click', () => { newPasswordForm.find('BackLink').simulate('click'); expect(mockPrevious).toHaveBeenCalled(); }); - - it('returns to previous step on key down', () => { - newPasswordForm.find('BackLink').simulate('keyDown'); - expect(mockPrevious).toHaveBeenCalled(); - }); }); diff --git a/web-ui/src/account_recovery/page.js b/web-ui/src/account_recovery/page.js index 3043a38b..579f17cc 100644 --- a/web-ui/src/account_recovery/page.js +++ b/web-ui/src/account_recovery/page.js @@ -19,9 +19,9 @@ import React from 'react'; import { translate } from 'react-i18next'; import DocumentTitle from 'react-document-title'; import Header from 'src/common/header/header'; -import AdminRecoveryCodeForm from 'src/account_recovery/forms/admin_recovery_code_form'; -import UserRecoveryCodeForm from 'src/account_recovery/forms/user_recovery_code_form'; -import NewPasswordForm from 'src/account_recovery/forms/new_password_form'; +import AdminRecoveryCodeForm from 'src/account_recovery/admin_recovery_code_form/admin_recovery_code_form'; +import UserRecoveryCodeForm from 'src/account_recovery/user_recovery_code_form/user_recovery_code_form'; +import NewPasswordForm from 'src/account_recovery/new_password_form/new_password_form'; import Footer from 'src/common/footer/footer'; import 'font-awesome/scss/font-awesome.scss'; diff --git a/web-ui/src/account_recovery/page.scss b/web-ui/src/account_recovery/page.scss index 20604b70..c61c855e 100644 --- a/web-ui/src/account_recovery/page.scss +++ b/web-ui/src/account_recovery/page.scss @@ -66,10 +66,37 @@ p { margin-bottom: 0.5em; } +.account-recovery-form { + display: flex; + flex-direction: column; + + .account-recovery-progress { + align-self: center; + width: 100%; + } + + .input-field-group { + margin-top: 0; + } +} + @media only screen and (min-width : 500px) { body { font-size: 1.3em; } + + .account-recovery-form { + align-items: center; + + .account-recovery-progress { + margin-bottom: 1.4em; + width: 80%; + } + + h1 { + width: 80%; + } + } } @media only screen and (min-width : 960px) { @@ -78,4 +105,16 @@ p { max-width: 700px; padding: 3em; } + + .account-recovery-form { + h1 { + max-width: 80%; + width: auto; + } + + .input-field-group, .submit-button { + width: 60%; + align-self: center; + } + } } diff --git a/web-ui/src/account_recovery/page.spec.js b/web-ui/src/account_recovery/page.spec.js index 32e1477c..68debba0 100644 --- a/web-ui/src/account_recovery/page.spec.js +++ b/web-ui/src/account_recovery/page.spec.js @@ -4,11 +4,12 @@ import React from 'react'; import { Page } from 'src/account_recovery/page'; import Header from 'src/common/header/header'; -import AdminRecoveryCodeForm from 'src/account_recovery/forms/admin_recovery_code_form'; -import UserRecoveryCodeForm from 'src/account_recovery/forms/user_recovery_code_form'; -import NewPasswordForm from 'src/account_recovery/forms/new_password_form'; import Footer from 'src/common/footer/footer'; +import AdminRecoveryCodeFormWrapper from './admin_recovery_code_form/admin_recovery_code_form'; +import UserRecoveryCodeFormWrapper from './user_recovery_code_form/user_recovery_code_form'; +import NewPasswordFormWrapper from './new_password_form/new_password_form'; + describe('Account Recovery Page', () => { let page; @@ -21,8 +22,8 @@ describe('Account Recovery Page', () => { expect(page.props().title).toEqual('account-recovery.page-title'); }); - it('renders header', () => { - expect(page.find(Header).length).toEqual(1); + it('renders header without logout button', () => { + expect(page.find(Header).props().renderLogout).toEqual(false); }); it('renders footer', () => { @@ -37,29 +38,29 @@ describe('Account Recovery Page', () => { }); it('renders admin recovery code form as default form', () => { - expect(page.find(AdminRecoveryCodeForm).length).toEqual(1); - expect(page.find(UserRecoveryCodeForm).length).toEqual(0); - expect(page.find(NewPasswordForm).length).toEqual(0); + expect(page.find(AdminRecoveryCodeFormWrapper).length).toEqual(1); + expect(page.find(UserRecoveryCodeFormWrapper).length).toEqual(0); + expect(page.find(NewPasswordFormWrapper).length).toEqual(0); }); it('renders user recovery code form when admin code submitted', () => { pageInstance.nextStep({ preventDefault: () => {} }); - expect(page.find(UserRecoveryCodeForm).length).toEqual(1); + expect(page.find(UserRecoveryCodeFormWrapper).length).toEqual(1); }); it('returns to admin code form on user code form back link', () => { pageInstance.nextStep({ preventDefault: () => {} }); pageInstance.previousStep(); - expect(page.find(AdminRecoveryCodeForm).length).toEqual(1); + expect(page.find(AdminRecoveryCodeFormWrapper).length).toEqual(1); }); it('renders new password form when user code submitted', () => { pageInstance.nextStep({ preventDefault: () => {} }); pageInstance.nextStep({ preventDefault: () => {} }); - expect(page.find(NewPasswordForm).length).toEqual(1); + expect(page.find(NewPasswordFormWrapper).length).toEqual(1); }); it('returns to user code form on new password form back link', () => { @@ -67,7 +68,7 @@ describe('Account Recovery Page', () => { pageInstance.nextStep({ preventDefault: () => {} }); pageInstance.previousStep(); - expect(page.find(UserRecoveryCodeForm).length).toEqual(1); + expect(page.find(UserRecoveryCodeFormWrapper).length).toEqual(1); }); }); }); diff --git a/web-ui/src/account_recovery/forms/user_recovery_code_form.js b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js index 30525cdf..a4119885 100644 --- a/web-ui/src/account_recovery/forms/user_recovery_code_form.js +++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js @@ -22,7 +22,7 @@ import InputField from 'src/common/input_field/input_field'; import SubmitButton from 'src/common/submit_button/submit_button'; import BackLink from 'src/common/back_link/back_link'; -import './forms.scss'; +import './user_recovery_code_form.scss'; export const UserRecoveryCodeForm = ({ t, previous, next }) => ( <form className='account-recovery-form user-code' onSubmit={next}> @@ -34,19 +34,15 @@ export const UserRecoveryCodeForm = ({ t, previous, next }) => ( <h1>{t('account-recovery.user-form.title')}</h1> <div className='user-code-form-content'> <img - className='user-codes-image' + className='user-code-image' src='/public/images/account-recovery/codes.svg' alt='' /> <p>{t('account-recovery.user-form.description')}</p> </div> <InputField name='admin-code' label={t('account-recovery.user-form.input-label')} /> - <SubmitButton buttonText={t('account-recovery.user-form.button')} /> - <BackLink - text={t('account-recovery.back')} - onClick={previous} onKeyDown={previous} - role='button' - /> + <SubmitButton buttonText={t('account-recovery.button-next')} /> + <BackLink text={t('account-recovery.back')} onClick={previous} /> </form> ); diff --git a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.scss b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.scss new file mode 100644 index 00000000..55f5621b --- /dev/null +++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.scss @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see <http://www.gnu.org/licenses/>. + */ + +.user-code-form-content { + display: flex; + flex-direction: column; + align-items: center; +} + +.user-code-image { + margin: 1em 0; + align-self: center; + height: 4em; +} + +@media only screen and (min-width : 500px) { + .user-code-form-content { + flex-direction: row; + width: 80%; + } + + .user-code-image { + margin-right: 1.6em; + } +} diff --git a/web-ui/src/account_recovery/forms/user_recovery_code_form.spec.js b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js index 1aebb814..e47f2e6c 100644 --- a/web-ui/src/account_recovery/forms/user_recovery_code_form.spec.js +++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js @@ -1,7 +1,7 @@ import { shallow } from 'enzyme'; import expect from 'expect'; import React from 'react'; -import { UserRecoveryCodeForm } from 'src/account_recovery/forms/user_recovery_code_form'; +import { UserRecoveryCodeForm } from './user_recovery_code_form'; describe('UserRecoveryCodeForm', () => { let userRecoveryCodeForm; @@ -32,7 +32,7 @@ describe('UserRecoveryCodeForm', () => { }); it('renders submit button', () => { - expect(userRecoveryCodeForm.find('SubmitButton').props().buttonText).toEqual('account-recovery.user-form.button'); + expect(userRecoveryCodeForm.find('SubmitButton').props().buttonText).toEqual('account-recovery.button-next'); }); it('submits form to next step', () => { @@ -44,9 +44,4 @@ describe('UserRecoveryCodeForm', () => { userRecoveryCodeForm.find('BackLink').simulate('click'); expect(mockPrevious).toHaveBeenCalled(); }); - - it('returns to previous step on key down', () => { - userRecoveryCodeForm.find('BackLink').simulate('keyDown'); - expect(mockPrevious).toHaveBeenCalled(); - }); }); |