From e2a782f0b7af58a93de3570fbc14faf071c16726 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Sun, 1 May 2016 20:50:55 +0300 Subject: [PATCH] Complete change password flow prototype --- .babelrc | 4 + package.json | 7 +- .../profile/changePassword/ChangePassword.jsx | 102 +++++++++------ .../PasswordRequestForm.jsx | 43 +++++++ .../PasswordRequestForm.messages.js | 12 ++ src/components/ui/form.scss | 30 +++-- src/components/ui/popup/PopupStack.jsx | 60 +++++++++ src/components/ui/popup/actions.js | 29 +++++ src/components/ui/popup/popup.scss | 42 +++++++ src/components/ui/popup/reducer.js | 44 +++++++ src/models/Form.js | 9 ++ src/pages/profile/ChangePasswordPage.jsx | 52 ++++++++ src/pages/root/RootPage.jsx | 34 +++-- src/pages/root/root.scss | 6 + src/reducers.js | 4 +- src/routes.js | 5 +- .../changePassword/ChangePassword.test.jsx | 23 ++++ tests/components/ui/popup/PopupStack.test.jsx | 118 ++++++++++++++++++ tests/components/ui/popup/reducer.test.js | 98 +++++++++++++++ tests/index.js | 2 +- webpack.config.js | 15 +++ 21 files changed, 672 insertions(+), 67 deletions(-) create mode 100644 src/components/profile/passwordRequestForm/PasswordRequestForm.jsx create mode 100644 src/components/profile/passwordRequestForm/PasswordRequestForm.messages.js create mode 100644 src/components/ui/popup/PopupStack.jsx create mode 100644 src/components/ui/popup/actions.js create mode 100644 src/components/ui/popup/popup.scss create mode 100644 src/components/ui/popup/reducer.js create mode 100644 src/pages/profile/ChangePasswordPage.jsx create mode 100644 tests/components/profile/changePassword/ChangePassword.test.jsx create mode 100644 tests/components/ui/popup/PopupStack.test.jsx create mode 100644 tests/components/ui/popup/reducer.test.js diff --git a/.babelrc b/.babelrc index 0afdcb9..985adfb 100644 --- a/.babelrc +++ b/.babelrc @@ -4,6 +4,10 @@ "env": { "development": { "presets": ["react-hmre"] + }, + "test": { + // airbnb some how disables stage-0, so forcing it after airbnb + "presets": ["airbnb", "stage-0"] } } } diff --git a/package.json b/package.json index 3ded895..2a60968 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "intl-format-cache": "^2.0.4", "intl-messageformat": "^1.1.0", "react": "^15.0.0", - "react-dom": "^15.0.0-rc.2", + "react-dom": "^15.0.0", "react-helmet": "^2.3.1", "react-intl": "^2.0.0", "react-motion": "^0.4.0", @@ -38,6 +38,7 @@ "babel-loader": "^6.0.0", "babel-plugin-react-intl": "~2.0.0", "babel-plugin-transform-runtime": "^6.3.13", + "babel-preset-airbnb": "^1.1.1", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.3.13", "babel-preset-react-hmre": "^1.0.1", @@ -47,6 +48,7 @@ "chokidar": "^1.2.0", "css-loader": "^0.23.0", "cssnano": "^3.4.0", + "enzyme": "^2.2.0", "eslint": "^1.10.3", "eslint-plugin-react": "^3.13.1", "exports-loader": "^0.6.3", @@ -54,6 +56,7 @@ "file-loader": "^0.8.5", "html-webpack-plugin": "^1.7.0", "imports-loader": "^0.6.5", + "json-loader": "^0.5.4", "karma": "*", "karma-chai": "*", "karma-es5-shim": "*", @@ -70,7 +73,7 @@ "phantomjs-prebuilt": "^2.0.0", "postcss-loader": "^0.8.0", "postcss-url": "^5.1.1", - "react-addons-test-utils": "^15.0.0", + "react-addons-test-utils": "^15.0.2", "sass-loader": "^3.1.2", "sinon": "^1.15.3", "style-loader": "^0.13.0", diff --git a/src/components/profile/changePassword/ChangePassword.jsx b/src/components/profile/changePassword/ChangePassword.jsx index b0db038..27c9faa 100644 --- a/src/components/profile/changePassword/ChangePassword.jsx +++ b/src/components/profile/changePassword/ChangePassword.jsx @@ -1,61 +1,87 @@ -import React, { Component } from 'react'; +import React, { Component, PropTypes } from 'react'; import { FormattedMessage as Message } from 'react-intl'; import { Link } from 'react-router'; import Helmet from 'react-helmet'; import { LabeledInput, Button } from 'components/ui/Form'; +import FormModel from 'models/Form'; +import { Form } from 'components/ui/Form'; import styles from 'components/profile/profileForm.scss'; import messages from './ChangePassword.messages'; export default class ChangePassword extends Component { - displayName = 'ChangePassword'; + static displayName = 'ChangePassword'; + + static propTypes = { + onSubmit: PropTypes.func.isRequired + }; + + form = new FormModel(); render() { + const {form} = this; + return ( -
- +
+
+ -
-
- - {(pageTitle) => ( -

- - {pageTitle} -

- )} -
+
+
+ + {(pageTitle) => ( +

+ + {pageTitle} +

+ )} +
-
-

- -
- - - -

+
+

+ +
+ + + +

+
+ +
+ +
+ +
+

+ +

+
+ +
+ +
-
- -
- -
-

- -

-
- -
- -
+
- -
-
+ ); } + + onFormSubmit = () => { + this.props.onSubmit(this.form.serialize()); + }; } diff --git a/src/components/profile/passwordRequestForm/PasswordRequestForm.jsx b/src/components/profile/passwordRequestForm/PasswordRequestForm.jsx new file mode 100644 index 0000000..f0f6b36 --- /dev/null +++ b/src/components/profile/passwordRequestForm/PasswordRequestForm.jsx @@ -0,0 +1,43 @@ +import React, { Component, PropTypes } from 'react'; + +import { FormattedMessage as Message } from 'react-intl'; + +import FormModel from 'models/Form'; +import { Form, Button, Input } from 'components/ui/Form'; + +import messages from './PasswordRequestForm.messages'; + +export default class PasswordRequestForm extends Component { + static displayName = 'PasswordRequestForm'; + + static propTypes = { + onSubmit: PropTypes.func.isRequired + }; + + form = new FormModel(); + + render() { + return ( +
+

+ +

+ + +