summaryrefslogtreecommitdiff
path: root/web-ui/src/account_recovery/user_recovery_code_form
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/src/account_recovery/user_recovery_code_form')
-rw-r--r--web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js55
-rw-r--r--web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.scss39
-rw-r--r--web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js47
3 files changed, 141 insertions, 0 deletions
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..a4119885
--- /dev/null
+++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.js
@@ -0,0 +1,55 @@
+/*
+ * 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/>.
+ */
+
+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 }) => (
+ <form className='account-recovery-form user-code' onSubmit={next}>
+ <img
+ className='account-recovery-progress'
+ src='/public/images/account-recovery/step_2.svg'
+ alt={t('account-recovery.user-form.image-description')}
+ />
+ <h1>{t('account-recovery.user-form.title')}</h1>
+ <div className='user-code-form-content'>
+ <img
+ 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.button-next')} />
+ <BackLink text={t('account-recovery.back')} onClick={previous} />
+ </form>
+);
+
+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 <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/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..e47f2e6c
--- /dev/null
+++ b/web-ui/src/account_recovery/user_recovery_code_form/user_recovery_code_form.spec.js
@@ -0,0 +1,47 @@
+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(
+ <UserRecoveryCodeForm
+ t={mockTranslations} next={mockNext} previous={mockPrevious}
+ />
+ );
+ });
+
+ 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.button-next');
+ });
+
+ 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();
+ });
+});