summaryrefslogtreecommitdiff
path: root/web-ui/src/backup_account
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/src/backup_account')
-rw-r--r--web-ui/src/backup_account/backup_account.html14
-rw-r--r--web-ui/src/backup_account/backup_account.js30
-rw-r--r--web-ui/src/backup_account/page.js89
-rw-r--r--web-ui/src/backup_account/page.scss133
-rw-r--r--web-ui/src/backup_account/page.spec.js80
5 files changed, 346 insertions, 0 deletions
diff --git a/web-ui/src/backup_account/backup_account.html b/web-ui/src/backup_account/backup_account.html
new file mode 100644
index 00000000..084824f2
--- /dev/null
+++ b/web-ui/src/backup_account/backup_account.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <link rel="icon" type="image/png" href="public/images/favicon.png" />
+ <meta charset="utf-8"/>
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
+ <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
+ <title>Pixelated</title>
+ </head>
+ <body>
+ <div id="root"/>
+ <script type="text/javascript" src="/assets/backup_account.js"></script>
+ </body>
+</html>
diff --git a/web-ui/src/backup_account/backup_account.js b/web-ui/src/backup_account/backup_account.js
new file mode 100644
index 00000000..ac218a39
--- /dev/null
+++ b/web-ui/src/backup_account/backup_account.js
@@ -0,0 +1,30 @@
+/*
+ * 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 { render } from 'react-dom';
+import a11y from 'react-a11y';
+
+import App from 'src/common/app';
+import PageWrapper from './page';
+
+if (process.env.NODE_ENV === 'development') a11y(React);
+
+render(
+ <App child={<PageWrapper />} />,
+ document.getElementById('root')
+);
diff --git a/web-ui/src/backup_account/page.js b/web-ui/src/backup_account/page.js
new file mode 100644
index 00000000..c7554cfb
--- /dev/null
+++ b/web-ui/src/backup_account/page.js
@@ -0,0 +1,89 @@
+/*
+ * 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 DocumentTitle from 'react-document-title';
+import SubmitButton from 'src/common/submit_button/submit_button';
+import InputField from 'src/common/input_field/input_field';
+import Footer from 'src/common/footer/footer';
+import Header from 'src/common/header/header';
+import validator from 'validator';
+
+import 'font-awesome/scss/font-awesome.scss';
+import './page.scss';
+
+
+export class Page extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.state = { error: '', submitButtonDisabled: true };
+ this.validateEmail = this.validateEmail.bind(this);
+ }
+
+ validateEmail(event) {
+ const validEmail = validator.isEmail(event.target.value);
+ const emptyEmail = validator.isEmpty(event.target.value);
+ const t = this.props.t;
+ this.setState({
+ error: !emptyEmail && !validEmail ? t('backup-account.error.invalid-email') : '',
+ submitButtonDisabled: !validEmail || emptyEmail
+ });
+ }
+
+ render() {
+ const t = this.props.t;
+ return (
+ <DocumentTitle title={t('backup-account.page-title')}>
+ <div className='page'>
+ <Header />
+ <section>
+ <div className='container'>
+ <img
+ className='backup-account-image'
+ src='/public/images/forgot-my-password.svg'
+ alt={t('backup-account.image-description')}
+ />
+ <form>
+ <h1>{t('backup-account.title')}</h1>
+ <p>{t('backup-account.paragraph1')}</p>
+ <p>{t('backup-account.paragraph2')}</p>
+ <InputField name='email' label={t('backup-account.input-label')} errorText={this.state.error} onChange={this.validateEmail} />
+ <SubmitButton buttonText={t('backup-account.button')} disabled={this.state.submitButtonDisabled} />
+ <div className='link-content'>
+ <a href='/' className='link'>
+ <i className='fa fa-angle-left' aria-hidden='true' />
+ <span>{t('back-to-inbox')}</span>
+ </a>
+ </div>
+ </form>
+ </div>
+ </section>
+ <Footer />
+ </div>
+ </DocumentTitle>
+ );
+ }
+}
+
+
+Page.propTypes = {
+ t: React.PropTypes.func.isRequired
+};
+
+export default translate('', { wait: true })(Page);
diff --git a/web-ui/src/backup_account/page.scss b/web-ui/src/backup_account/page.scss
new file mode 100644
index 00000000..aa973fcd
--- /dev/null
+++ b/web-ui/src/backup_account/page.scss
@@ -0,0 +1,133 @@
+/*
+ * 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 "~scss/vendor/reset";
+@import "~scss/base/colors";
+@import "~scss/base/fonts";
+
+html, body, #root {
+ height: 100%;
+}
+
+body, #root {
+ min-height: 100%;
+}
+
+a {
+ text-decoration: none;
+}
+
+.page {
+ font-family: "Open Sans", "Microsoft YaHei", "Hiragino Sans GB", "Hiragino Sans GB W3", "微软雅黑", "Helvetica Neue", Arial, sans-serif;
+ background: $dark_blue; /* For browsers that do not support gradients */
+ background: -webkit-linear-gradient(left top, $dark_blue, $middle_blue); /* For Safari 5.1 to 6.0 */
+ background: -o-linear-gradient(bottom right, $dark_blue, $middle_blue); /* For Opera 11.1 to 12.0 */
+ background: -moz-linear-gradient(bottom right, $dark_blue, $middle_blue); /* For Firefox 3.6 to 15 */
+ background: linear-gradient(to bottom right, $dark_blue, $middle_blue); /* Standard syntax */
+ color: $dark_grey_text;
+ min-height: 100%;
+ display: flex;
+ flex-direction: column;
+}
+
+section {
+ flex: 1 0 auto;
+}
+
+form {
+ width: 100%;
+}
+
+h1 {
+ font-size: 1.3em;
+ font-weight: 600;
+}
+
+p {
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+}
+
+.link {
+ color: $dark_blue;
+ font-style: italic;
+
+ .fa {
+ font-size: 1.6em;
+ position: relative;
+ top: 3px;
+ margin-right: 0.3em;
+ }
+
+}
+
+.container {
+ background: $white;
+ width: 84%;
+ margin: 3% auto;
+ padding: 6% 5%;
+ display: flex;
+ align-items: flex-start;
+ flex-direction: column;
+ box-shadow: 0 2px 3px 0 $shadow;
+}
+
+.backup-account-image {
+ width: 50%;
+ height: 100%;
+ align-self: center;
+}
+
+@media only screen and (min-width : 500px) {
+ body {
+ font-size: 1.3em;
+ }
+
+ form {
+ display: flex;
+ flex-direction: column;
+
+ .input-field-group, .submit-button, .link-content {
+ width: 70%;
+ align-self: center;
+ }
+ }
+}
+
+@media only screen and (min-width : 960px) {
+ .container{
+ width: 60%;
+ padding: 3em;
+ align-items: flex-start;
+ flex-direction: row;
+ max-width: 700px;
+ }
+
+ form {
+ margin-left: 2.5em;
+ min-height: 492px;
+
+ .input-field-group, .submit-button, .link-content {
+ width: 300px;
+ align-self: flex-start;
+ }
+ }
+
+ .backup-account-image {
+ width: 300px;
+ }
+}
diff --git a/web-ui/src/backup_account/page.spec.js b/web-ui/src/backup_account/page.spec.js
new file mode 100644
index 00000000..334d3ba8
--- /dev/null
+++ b/web-ui/src/backup_account/page.spec.js
@@ -0,0 +1,80 @@
+import { shallow } from 'enzyme';
+import expect from 'expect';
+import React from 'react';
+import { Page } from 'src/backup_account/page';
+
+describe('BackupAccount', () => {
+ let page;
+
+ beforeEach(() => {
+ const mockTranslations = key => key;
+ page = shallow(<Page t={mockTranslations} />);
+ });
+
+ it('renders backup email page title', () => {
+ expect(page.find('h1').text()).toEqual('backup-account.title');
+ });
+
+ it('renders backup account email input field', () => {
+ expect(page.find('InputField').props().name).toEqual('email');
+ });
+
+ it('renders backup account submit button', () => {
+ expect(page.find('SubmitButton').props().buttonText).toEqual('backup-account.button');
+ });
+
+ describe('Email validation', () => {
+ let pageInstance;
+
+ beforeEach(() => {
+ pageInstance = page.instance();
+ });
+
+ it('verify initial state', () => {
+ expect(pageInstance.state.error).toEqual('');
+ expect(page.find('SubmitButton').props().disabled).toEqual(true);
+ });
+
+ context('with invalid email', () => {
+ beforeEach(() => {
+ pageInstance.validateEmail({ target: { value: 'test' } });
+ });
+
+ it('sets error in state', () => {
+ expect(pageInstance.state.error).toEqual('backup-account.error.invalid-email');
+ });
+
+ it('disables submit button', () => {
+ expect(page.find('SubmitButton').props().disabled).toEqual(true);
+ });
+ });
+
+ context('with valid email', () => {
+ beforeEach(() => {
+ pageInstance.validateEmail({ target: { value: 'test@test.com' } });
+ });
+
+ it('does not set error in state', () => {
+ expect(pageInstance.state.error).toEqual('');
+ });
+
+ it('submit button is enabled', () => {
+ expect(page.find('SubmitButton').props().disabled).toEqual(false);
+ });
+ });
+
+ context('with empty email', () => {
+ beforeEach(() => {
+ pageInstance.validateEmail({ target: { value: '' } });
+ });
+
+ it('not set error in state', () => {
+ expect(pageInstance.state.error).toEqual('');
+ });
+
+ it('disables submit button', () => {
+ expect(page.find('SubmitButton').props().disabled).toEqual(true);
+ });
+ });
+ });
+});