From 925a3a868edda0258f46c290c76a98561568cb79 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Mon, 30 Dec 2019 10:47:29 +0200 Subject: [PATCH] Some more minor fixes --- packages/app/components/auth/AuthTitle.tsx | 2 +- .../profile/changeEmail/ChangeEmail.tsx | 2 +- .../changePassword/ChangePassword.test.js | 2 +- .../{ChangePassword.js => ChangePassword.tsx} | 23 +++++++-------- .../{ChangeUsername.js => ChangeUsername.tsx} | 29 ++++++++----------- .../multiFactorAuth/MultiFactorAuth.tsx | 2 +- packages/app/package.json | 1 + .../404/{PageNotFound.js => PageNotFound.tsx} | 6 ++-- packages/app/pages/auth/SuccessOauthPage.tsx | 2 +- packages/app/pages/rules/RulesPage.tsx | 2 +- packages/app/shell/App.tsx | 5 ++-- yarn.lock | 9 +++++- 12 files changed, 42 insertions(+), 43 deletions(-) rename packages/app/components/profile/changePassword/{ChangePassword.js => ChangePassword.tsx} (84%) rename packages/app/components/profile/changeUsername/{ChangeUsername.js => ChangeUsername.tsx} (79%) rename packages/app/pages/404/{PageNotFound.js => PageNotFound.tsx} (96%) diff --git a/packages/app/components/auth/AuthTitle.tsx b/packages/app/components/auth/AuthTitle.tsx index 769e400..c51028d 100644 --- a/packages/app/components/auth/AuthTitle.tsx +++ b/packages/app/components/auth/AuthTitle.tsx @@ -8,7 +8,7 @@ export default function AuthTitle({ title }: { title: MessageDescriptor }) { {msg => ( {msg} - + )} diff --git a/packages/app/components/profile/changeEmail/ChangeEmail.tsx b/packages/app/components/profile/changeEmail/ChangeEmail.tsx index 3000ba9..d685d0e 100644 --- a/packages/app/components/profile/changeEmail/ChangeEmail.tsx +++ b/packages/app/components/profile/changeEmail/ChangeEmail.tsx @@ -86,7 +86,7 @@ export default class ChangeEmail extends React.Component { {pageTitle => (

- + {pageTitle}

)} diff --git a/packages/app/components/profile/changePassword/ChangePassword.test.js b/packages/app/components/profile/changePassword/ChangePassword.test.js index 2491a4c..7172aca 100644 --- a/packages/app/components/profile/changePassword/ChangePassword.test.js +++ b/packages/app/components/profile/changePassword/ChangePassword.test.js @@ -8,7 +8,7 @@ import ChangePassword from 'app/components/profile/changePassword/ChangePassword describe('', () => { it('renders two components', () => { - const component = shallow( {}} />); + const component = shallow( {}} />); expect(component.find('Input'), 'to satisfy', { length: 2 }); }); diff --git a/packages/app/components/profile/changePassword/ChangePassword.js b/packages/app/components/profile/changePassword/ChangePassword.tsx similarity index 84% rename from packages/app/components/profile/changePassword/ChangePassword.js rename to packages/app/components/profile/changePassword/ChangePassword.tsx index fed03fd..6d2ddb2 100644 --- a/packages/app/components/profile/changePassword/ChangePassword.js +++ b/packages/app/components/profile/changePassword/ChangePassword.tsx @@ -1,5 +1,4 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; +import React from 'react'; import { FormattedMessage as Message } from 'react-intl'; import { Helmet } from 'react-helmet-async'; import { @@ -9,20 +8,18 @@ import { Form, FormModel, } from 'app/components/ui/form'; -import { BackButton } from 'app/components/profile/ProfileForm'; -import styles from 'app/components/profile/profileForm.scss'; +import { BackButton } from '../ProfileForm'; +import styles from '../profileForm.scss'; import messages from './ChangePassword.intl.json'; -export default class ChangePassword extends Component { - static displayName = 'ChangePassword'; +interface Props { + form: FormModel; + onSubmit: (form: FormModel) => Promise; +} - static propTypes = { - form: PropTypes.instanceOf(FormModel), - onSubmit: PropTypes.func.isRequired, - }; - - static get defaultProps() { +export default class ChangePassword extends React.Component { + static get defaultProps(): Partial { return { form: new FormModel(), }; @@ -41,7 +38,7 @@ export default class ChangePassword extends Component { {pageTitle => (

- + {pageTitle}

)} diff --git a/packages/app/components/profile/changeUsername/ChangeUsername.js b/packages/app/components/profile/changeUsername/ChangeUsername.tsx similarity index 79% rename from packages/app/components/profile/changeUsername/ChangeUsername.js rename to packages/app/components/profile/changeUsername/ChangeUsername.tsx index cfd1903..a363408 100644 --- a/packages/app/components/profile/changeUsername/ChangeUsername.js +++ b/packages/app/components/profile/changeUsername/ChangeUsername.tsx @@ -1,26 +1,21 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; - +import React from 'react'; import { FormattedMessage as Message } from 'react-intl'; import { Helmet } from 'react-helmet-async'; - import { Input, Button, Form, FormModel } from 'app/components/ui/form'; import { BackButton } from 'app/components/profile/ProfileForm'; -import styles from 'app/components/profile/profileForm.scss'; +import styles from '../profileForm.scss'; import messages from './ChangeUsername.intl.json'; -export default class ChangeUsername extends Component { - static displayName = 'ChangeUsername'; +interface Props { + username: string; + form: FormModel; + onChange: (name: string) => void; + onSubmit: (form: FormModel) => Promise; +} - static propTypes = { - username: PropTypes.string.isRequired, - form: PropTypes.instanceOf(FormModel), - onChange: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - }; - - static get defaultProps() { +export default class ChangeUsername extends React.Component { + static get defaultProps(): Partial { return { form: new FormModel(), }; @@ -39,7 +34,7 @@ export default class ChangeUsername extends Component { {pageTitle => (

- + {pageTitle}

)} @@ -80,7 +75,7 @@ export default class ChangeUsername extends Component { ); } - onUsernameChange = event => { + onUsernameChange = (event: React.ChangeEvent) => { this.props.onChange(event.target.value); }; diff --git a/packages/app/components/profile/multiFactorAuth/MultiFactorAuth.tsx b/packages/app/components/profile/multiFactorAuth/MultiFactorAuth.tsx index ed91e90..9aa6e97 100644 --- a/packages/app/components/profile/multiFactorAuth/MultiFactorAuth.tsx +++ b/packages/app/components/profile/multiFactorAuth/MultiFactorAuth.tsx @@ -34,7 +34,7 @@ class MultiFactorAuth extends React.Component<{ {pageTitle => (

- + {pageTitle}

)} diff --git a/packages/app/package.json b/packages/app/package.json index d5810fc..0da909c 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -35,6 +35,7 @@ "whatwg-fetch": "^3.0.0" }, "devDependencies": { + "@types/react-helmet": "^5.0.14", "@types/webpack-env": "^1.14.1", "enzyme": "^3.8.0", "enzyme-adapter-react-16": "^1.15.1" diff --git a/packages/app/pages/404/PageNotFound.js b/packages/app/pages/404/PageNotFound.tsx similarity index 96% rename from packages/app/pages/404/PageNotFound.js rename to packages/app/pages/404/PageNotFound.tsx index 7197416..d8ad3ab 100644 --- a/packages/app/pages/404/PageNotFound.js +++ b/packages/app/pages/404/PageNotFound.tsx @@ -1,10 +1,8 @@ import React from 'react'; - -import { FooterMenu } from 'app/components/footerMenu'; - import { Link } from 'react-router-dom'; import { FormattedMessage as Message } from 'react-intl'; import { Helmet } from 'react-helmet-async'; +import { FooterMenu } from 'app/components/footerMenu'; import styles from './404.scss'; import messages from './PageNotFound.intl.json'; @@ -14,7 +12,7 @@ export default function PageNotFound() { return (
- {pageTitle => } + {pageTitle => }
diff --git a/packages/app/pages/auth/SuccessOauthPage.tsx b/packages/app/pages/auth/SuccessOauthPage.tsx index ce36e64..f392ba1 100644 --- a/packages/app/pages/auth/SuccessOauthPage.tsx +++ b/packages/app/pages/auth/SuccessOauthPage.tsx @@ -42,7 +42,7 @@ export default class SuccessOauthPage extends React.Component<{ return (
- {pageTitle => } + {pageTitle => }
diff --git a/packages/app/pages/rules/RulesPage.tsx b/packages/app/pages/rules/RulesPage.tsx index 2dd1652..027596a 100644 --- a/packages/app/pages/rules/RulesPage.tsx +++ b/packages/app/pages/rules/RulesPage.tsx @@ -98,7 +98,7 @@ export default class RulesPage extends Component<{ return (
- {pageTitle => } + {pageTitle => }
diff --git a/packages/app/shell/App.tsx b/packages/app/shell/App.tsx index 4765d37..501eae1 100644 --- a/packages/app/shell/App.tsx +++ b/packages/app/shell/App.tsx @@ -1,6 +1,7 @@ -import React from 'react'; import { hot } from 'react-hot-loader/root'; +import React from 'react'; import { Route, Switch } from 'react-router-dom'; +import { History } from 'history'; import { Store } from 'app/reducers'; import AuthFlowRoute from 'app/containers/AuthFlowRoute'; import RootPage from 'app/pages/root/RootPage'; @@ -14,7 +15,7 @@ const SuccessOauthPage = React.lazy(() => ), ); -const App = ({ store, history }: { store: Store; history: any }) => ( +const App = ({ store, history }: { store: Store; history: History }) => ( }> diff --git a/yarn.lock b/yarn.lock index 7b3bdc3..357654c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2161,7 +2161,7 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== -"@types/node@*", "@types/node@^12.0.0": +"@types/node@*": version "12.12.22" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.22.tgz#b8d9eae3328b96910a373cf06ac8d3c5abe9c200" integrity sha512-r5i93jqbPWGXYXxianGATOxTelkp6ih/U0WVnvaqAvTqM+0U6J3kw6Xk6uq/dWNRkEVw/0SLcO5ORXbVNz4FMQ== @@ -2194,6 +2194,13 @@ "@types/history" "*" "@types/react" "*" +"@types/react-helmet@^5.0.14": + version "5.0.14" + resolved "https://registry.yarnpkg.com/@types/react-helmet/-/react-helmet-5.0.14.tgz#a07979ccb2cee088e74e735c84058fc8607d32e4" + integrity sha512-Q73FFg7+LjblfSQUNbnjrwy2T1avBP8yevEgNrkDjyz1rBbnXkuOQcEV7I5wvmAic9FLUk0CnkLieEDej84Zkw== + dependencies: + "@types/react" "*" + "@types/react-redux@^7.1.5": version "7.1.5" resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.5.tgz#c7a528d538969250347aa53c52241051cf886bd3"