From 8d49edac6af9dd08f1bb7b1727aee36af413a4a2 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Tue, 28 Mar 2017 18:59:33 -0300 Subject: [#932] Moves form componentes to separate directories with @deniscostadsc --- .../user_recovery_code_form.js | 59 ++++++++++++++++++++++ .../user_recovery_code_form.scss | 39 ++++++++++++++ .../user_recovery_code_form.spec.js | 52 +++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js create mode 100644 web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.scss create mode 100644 web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js (limited to 'web-ui/src/account_recovery/user_recovery_code_form') diff --git a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js new file mode 100644 index 00000000..cfdcdc26 --- /dev/null +++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js @@ -0,0 +1,59 @@ +/* + * 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 . + */ + +import React from 'react'; +import { translate } from 'react-i18next'; + +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 './user_recovery_code_form.scss'; + +export const UserRecoveryCodeForm = ({ t, previous, next }) => ( +
+ {t('account-recovery.user-form.image-description')} +

{t('account-recovery.user-form.title')}

+
+ +

{t('account-recovery.user-form.description')}

+
+ + + + +); + +UserRecoveryCodeForm.propTypes = { + t: React.PropTypes.func.isRequired, + previous: React.PropTypes.func.isRequired, + next: React.PropTypes.func.isRequired +}; + +export default translate('', { wait: true })(UserRecoveryCodeForm); 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 . + */ + +.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/user_recovery_code_form/user_recovery_code_form.spec.js b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js new file mode 100644 index 00000000..cb6998c8 --- /dev/null +++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js @@ -0,0 +1,52 @@ +import { shallow } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import { UserRecoveryCodeForm } from './user_recovery_code_form'; + +describe('UserRecoveryCodeForm', () => { + let userRecoveryCodeForm; + let mockNext; + let mockPrevious; + + beforeEach(() => { + const mockTranslations = key => key; + mockNext = expect.createSpy(); + mockPrevious = expect.createSpy(); + userRecoveryCodeForm = shallow( + + ); + }); + + it('renders title for user recovery code', () => { + expect(userRecoveryCodeForm.find('h1').text()).toEqual('account-recovery.user-form.title'); + }); + + it('renders description', () => { + expect(userRecoveryCodeForm.find('p').text()).toEqual('account-recovery.user-form.description'); + }); + + it('renders input for user code', () => { + expect(userRecoveryCodeForm.find('InputField').props().label).toEqual('account-recovery.user-form.input-label'); + }); + + it('renders submit button', () => { + expect(userRecoveryCodeForm.find('SubmitButton').props().buttonText).toEqual('account-recovery.user-form.button'); + }); + + it('submits form to next step', () => { + userRecoveryCodeForm.find('form').simulate('submit'); + expect(mockNext).toHaveBeenCalled(); + }); + + it('returns to previous step on link click', () => { + userRecoveryCodeForm.find('BackLink').simulate('click'); + expect(mockPrevious).toHaveBeenCalled(); + }); + + it('returns to previous step on key down', () => { + userRecoveryCodeForm.find('BackLink').simulate('keyDown'); + expect(mockPrevious).toHaveBeenCalled(); + }); +}); -- cgit v1.2.3 From 9a2a9cf5f4d13e2bc9bb0bd997ecd22ec5241b4b Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Wed, 29 Mar 2017 17:10:19 -0300 Subject: [#932] Makes back link a button --- .../user_recovery_code_form/user_recovery_code_form.js | 6 +----- .../user_recovery_code_form/user_recovery_code_form.spec.js | 5 ----- 2 files changed, 1 insertion(+), 10 deletions(-) (limited to 'web-ui/src/account_recovery/user_recovery_code_form') diff --git a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js index cfdcdc26..0df40a6e 100644 --- a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js +++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js @@ -42,11 +42,7 @@ export const UserRecoveryCodeForm = ({ t, previous, next }) => ( - + ); diff --git a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js index cb6998c8..6ecb22e4 100644 --- a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js +++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js @@ -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(); - }); }); -- cgit v1.2.3 From af0f6b1e655bba9fd42317b0332d7a314d673228 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Thu, 30 Mar 2017 15:07:09 -0300 Subject: [#932] Combines button label for account recovery forms with @deniscostadsc --- .../account_recovery/user_recovery_code_form/user_recovery_code_form.js | 2 +- .../user_recovery_code_form/user_recovery_code_form.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'web-ui/src/account_recovery/user_recovery_code_form') diff --git a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js index 0df40a6e..a4119885 100644 --- a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js +++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js @@ -41,7 +41,7 @@ export const UserRecoveryCodeForm = ({ t, previous, next }) => (

{t('account-recovery.user-form.description')}

- + ); diff --git a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js index 6ecb22e4..e47f2e6c 100644 --- a/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js +++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js @@ -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', () => { -- cgit v1.2.3