diff options
author | 2019-10-14 10:38:27 +0200 | |
---|---|---|
committer | 2019-10-14 10:38:27 +0200 | |
commit | c84edee908d40a9cab45b9ae3c5dc899fbb3eb11 (patch) | |
tree | 80158d14869b59723d09535558358d62b2612c2b /src/components | |
parent | Add indicator for hibernating services (diff) | |
download | ferdium-app-c84edee908d40a9cab45b9ae3c5dc899fbb3eb11.tar.gz ferdium-app-c84edee908d40a9cab45b9ae3c5dc899fbb3eb11.tar.zst ferdium-app-c84edee908d40a9cab45b9ae3c5dc899fbb3eb11.zip |
Add local server to allow serverlesss usage
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/auth/Login.js | 22 | ||||
-rw-r--r-- | src/components/auth/Signup.js | 22 | ||||
-rw-r--r-- | src/components/auth/Welcome.js | 21 | ||||
-rw-r--r-- | src/components/services/content/Services.js | 32 |
4 files changed, 87 insertions, 10 deletions
diff --git a/src/components/auth/Login.js b/src/components/auth/Login.js index eea5a09bf..e58016e25 100644 --- a/src/components/auth/Login.js +++ b/src/components/auth/Login.js | |||
@@ -1,11 +1,13 @@ | |||
1 | /* eslint jsx-a11y/anchor-is-valid: 0 */ | ||
1 | import React, { Component } from 'react'; | 2 | import React, { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | 3 | import PropTypes from 'prop-types'; |
3 | import { observer } from 'mobx-react'; | 4 | import { observer, inject } from 'mobx-react'; |
4 | import { defineMessages, intlShape } from 'react-intl'; | 5 | import { defineMessages, intlShape } from 'react-intl'; |
5 | 6 | ||
6 | import { isDevMode, useLiveAPI } from '../../environment'; | 7 | import { isDevMode, useLiveAPI } from '../../environment'; |
7 | import Form from '../../lib/Form'; | 8 | import Form from '../../lib/Form'; |
8 | import { required, email } from '../../helpers/validation-helpers'; | 9 | import { required, email } from '../../helpers/validation-helpers'; |
10 | import serverlessLogin from '../../helpers/serverless-helpers'; | ||
9 | import Input from '../ui/Input'; | 11 | import Input from '../ui/Input'; |
10 | import Button from '../ui/Button'; | 12 | import Button from '../ui/Button'; |
11 | import Link from '../ui/Link'; | 13 | import Link from '../ui/Link'; |
@@ -54,13 +56,21 @@ const messages = defineMessages({ | |||
54 | id: 'login.link.signup', | 56 | id: 'login.link.signup', |
55 | defaultMessage: '!!!Create a free account', | 57 | defaultMessage: '!!!Create a free account', |
56 | }, | 58 | }, |
59 | changeServer: { | ||
60 | id: 'login.changeServer', | ||
61 | defaultMessage: '!!!Change server', | ||
62 | }, | ||
63 | serverless: { | ||
64 | id: 'services.serverless', | ||
65 | defaultMessage: '!!!Use Ferdi without an Account', | ||
66 | }, | ||
57 | passwordLink: { | 67 | passwordLink: { |
58 | id: 'login.link.password', | 68 | id: 'login.link.password', |
59 | defaultMessage: '!!!Forgot password', | 69 | defaultMessage: '!!!Forgot password', |
60 | }, | 70 | }, |
61 | }); | 71 | }); |
62 | 72 | ||
63 | export default @observer class Login extends Component { | 73 | export default @observer @inject('actions') class Login extends Component { |
64 | static propTypes = { | 74 | static propTypes = { |
65 | onSubmit: PropTypes.func.isRequired, | 75 | onSubmit: PropTypes.func.isRequired, |
66 | isSubmitting: PropTypes.bool.isRequired, | 76 | isSubmitting: PropTypes.bool.isRequired, |
@@ -69,6 +79,7 @@ export default @observer class Login extends Component { | |||
69 | signupRoute: PropTypes.string.isRequired, | 79 | signupRoute: PropTypes.string.isRequired, |
70 | passwordRoute: PropTypes.string.isRequired, | 80 | passwordRoute: PropTypes.string.isRequired, |
71 | error: globalErrorPropType.isRequired, | 81 | error: globalErrorPropType.isRequired, |
82 | actions: PropTypes.object.isRequired, | ||
72 | }; | 83 | }; |
73 | 84 | ||
74 | static contextTypes = { | 85 | static contextTypes = { |
@@ -103,6 +114,10 @@ export default @observer class Login extends Component { | |||
103 | }); | 114 | }); |
104 | } | 115 | } |
105 | 116 | ||
117 | useLocalServer() { | ||
118 | serverlessLogin(this.props.actions); | ||
119 | } | ||
120 | |||
106 | render() { | 121 | render() { |
107 | const { form } = this; | 122 | const { form } = this; |
108 | const { intl } = this.context; | 123 | const { intl } = this.context; |
@@ -179,7 +194,8 @@ export default @observer class Login extends Component { | |||
179 | )} | 194 | )} |
180 | </form> | 195 | </form> |
181 | <div className="auth__links"> | 196 | <div className="auth__links"> |
182 | <Link to="/settings/app">Change server</Link> | 197 | <Link to="/settings/app">{intl.formatMessage(messages.changeServer)}</Link> |
198 | <a onClick={this.useLocalServer.bind(this)}>{intl.formatMessage(messages.serverless)}</a> | ||
183 | <Link to={signupRoute}>{intl.formatMessage(messages.signupLink)}</Link> | 199 | <Link to={signupRoute}>{intl.formatMessage(messages.signupLink)}</Link> |
184 | <Link to={passwordRoute}>{intl.formatMessage(messages.passwordLink)}</Link> | 200 | <Link to={passwordRoute}>{intl.formatMessage(messages.passwordLink)}</Link> |
185 | </div> | 201 | </div> |
diff --git a/src/components/auth/Signup.js b/src/components/auth/Signup.js index b36e71ce1..47e9daf18 100644 --- a/src/components/auth/Signup.js +++ b/src/components/auth/Signup.js | |||
@@ -1,11 +1,13 @@ | |||
1 | /* eslint jsx-a11y/anchor-is-valid: 0 */ | ||
1 | import React, { Component } from 'react'; | 2 | import React, { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | 3 | import PropTypes from 'prop-types'; |
3 | import { observer } from 'mobx-react'; | 4 | import { observer, inject } from 'mobx-react'; |
4 | import { defineMessages, intlShape } from 'react-intl'; | 5 | import { defineMessages, intlShape } from 'react-intl'; |
5 | 6 | ||
6 | import { isDevMode, useLiveAPI } from '../../environment'; | 7 | import { isDevMode, useLiveAPI } from '../../environment'; |
7 | import Form from '../../lib/Form'; | 8 | import Form from '../../lib/Form'; |
8 | import { required, email, minLength } from '../../helpers/validation-helpers'; | 9 | import { required, email, minLength } from '../../helpers/validation-helpers'; |
10 | import serverlessLogin from '../../helpers/serverless-helpers'; | ||
9 | import Input from '../ui/Input'; | 11 | import Input from '../ui/Input'; |
10 | import Button from '../ui/Button'; | 12 | import Button from '../ui/Button'; |
11 | import Link from '../ui/Link'; | 13 | import Link from '../ui/Link'; |
@@ -58,18 +60,27 @@ const messages = defineMessages({ | |||
58 | id: 'signup.link.login', | 60 | id: 'signup.link.login', |
59 | defaultMessage: '!!!Already have an account, sign in?', | 61 | defaultMessage: '!!!Already have an account, sign in?', |
60 | }, | 62 | }, |
63 | changeServer: { | ||
64 | id: 'login.changeServer', | ||
65 | defaultMessage: '!!!Change server', | ||
66 | }, | ||
67 | serverless: { | ||
68 | id: 'services.serverless', | ||
69 | defaultMessage: '!!!Use Ferdi without an Account', | ||
70 | }, | ||
61 | emailDuplicate: { | 71 | emailDuplicate: { |
62 | id: 'signup.emailDuplicate', | 72 | id: 'signup.emailDuplicate', |
63 | defaultMessage: '!!!A user with that email address already exists', | 73 | defaultMessage: '!!!A user with that email address already exists', |
64 | }, | 74 | }, |
65 | }); | 75 | }); |
66 | 76 | ||
67 | export default @observer class Signup extends Component { | 77 | export default @observer @inject('actions') class Signup extends Component { |
68 | static propTypes = { | 78 | static propTypes = { |
69 | onSubmit: PropTypes.func.isRequired, | 79 | onSubmit: PropTypes.func.isRequired, |
70 | isSubmitting: PropTypes.bool.isRequired, | 80 | isSubmitting: PropTypes.bool.isRequired, |
71 | loginRoute: PropTypes.string.isRequired, | 81 | loginRoute: PropTypes.string.isRequired, |
72 | error: globalErrorPropType.isRequired, | 82 | error: globalErrorPropType.isRequired, |
83 | actions: PropTypes.object.isRequired, | ||
73 | }; | 84 | }; |
74 | 85 | ||
75 | static contextTypes = { | 86 | static contextTypes = { |
@@ -112,6 +123,10 @@ export default @observer class Signup extends Component { | |||
112 | }); | 123 | }); |
113 | } | 124 | } |
114 | 125 | ||
126 | useLocalServer() { | ||
127 | serverlessLogin(this.props.actions); | ||
128 | } | ||
129 | |||
115 | render() { | 130 | render() { |
116 | const { form } = this; | 131 | const { form } = this; |
117 | const { intl } = this.context; | 132 | const { intl } = this.context; |
@@ -183,7 +198,8 @@ export default @observer class Signup extends Component { | |||
183 | </p> | 198 | </p> |
184 | </form> | 199 | </form> |
185 | <div className="auth__links"> | 200 | <div className="auth__links"> |
186 | <Link to="/settings/app">Change server</Link> | 201 | <Link to="/settings/app">{intl.formatMessage(messages.changeServer)}</Link> |
202 | <a onClick={this.useLocalServer.bind(this)}>{intl.formatMessage(messages.serverless)}</a> | ||
187 | <Link to={loginRoute}>{intl.formatMessage(messages.loginLink)}</Link> | 203 | <Link to={loginRoute}>{intl.formatMessage(messages.loginLink)}</Link> |
188 | </div> | 204 | </div> |
189 | </div> | 205 | </div> |
diff --git a/src/components/auth/Welcome.js b/src/components/auth/Welcome.js index ef917e336..2ca8b430f 100644 --- a/src/components/auth/Welcome.js +++ b/src/components/auth/Welcome.js | |||
@@ -1,7 +1,9 @@ | |||
1 | /* eslint jsx-a11y/anchor-is-valid: 0 */ | ||
1 | import React, { Component } from 'react'; | 2 | import React, { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | 3 | import PropTypes from 'prop-types'; |
3 | import { observer, PropTypes as MobxPropTypes } from 'mobx-react'; | 4 | import { observer, PropTypes as MobxPropTypes, inject } from 'mobx-react'; |
4 | import { defineMessages, intlShape } from 'react-intl'; | 5 | import { defineMessages, intlShape } from 'react-intl'; |
6 | import serverlessLogin from '../../helpers/serverless-helpers'; | ||
5 | 7 | ||
6 | import Link from '../ui/Link'; | 8 | import Link from '../ui/Link'; |
7 | 9 | ||
@@ -14,19 +16,28 @@ const messages = defineMessages({ | |||
14 | id: 'welcome.loginButton', | 16 | id: 'welcome.loginButton', |
15 | defaultMessage: '!!!Login to your account', | 17 | defaultMessage: '!!!Login to your account', |
16 | }, | 18 | }, |
19 | serverless: { | ||
20 | id: 'services.serverless', | ||
21 | defaultMessage: '!!!Use Ferdi without an Account', | ||
22 | }, | ||
17 | }); | 23 | }); |
18 | 24 | ||
19 | export default @observer class Login extends Component { | 25 | export default @observer @inject('actions') class Login extends Component { |
20 | static propTypes = { | 26 | static propTypes = { |
21 | loginRoute: PropTypes.string.isRequired, | 27 | loginRoute: PropTypes.string.isRequired, |
22 | signupRoute: PropTypes.string.isRequired, | 28 | signupRoute: PropTypes.string.isRequired, |
23 | recipes: MobxPropTypes.arrayOrObservableArray.isRequired, | 29 | recipes: MobxPropTypes.arrayOrObservableArray.isRequired, |
30 | actions: PropTypes.object.isRequired, | ||
24 | }; | 31 | }; |
25 | 32 | ||
26 | static contextTypes = { | 33 | static contextTypes = { |
27 | intl: intlShape, | 34 | intl: intlShape, |
28 | }; | 35 | }; |
29 | 36 | ||
37 | useLocalServer() { | ||
38 | serverlessLogin(this.props.actions); | ||
39 | } | ||
40 | |||
30 | render() { | 41 | render() { |
31 | const { intl } = this.context; | 42 | const { intl } = this.context; |
32 | const { | 43 | const { |
@@ -53,6 +64,12 @@ export default @observer class Login extends Component { | |||
53 | </Link> | 64 | </Link> |
54 | <br /> | 65 | <br /> |
55 | <br /> | 66 | <br /> |
67 | <a className="button" onClick={this.useLocalServer.bind(this)}> | ||
68 | {intl.formatMessage(messages.serverless)} | ||
69 | </a> | ||
70 | <br /> | ||
71 | <br /> | ||
72 | |||
56 | 73 | ||
57 | <Link to="settings/app"> | 74 | <Link to="settings/app"> |
58 | <span style={{ | 75 | <span style={{ |
diff --git a/src/components/services/content/Services.js b/src/components/services/content/Services.js index edff29ae8..6d7909362 100644 --- a/src/components/services/content/Services.js +++ b/src/components/services/content/Services.js | |||
@@ -1,6 +1,6 @@ | |||
1 | import React, { Component } from 'react'; | 1 | import React, { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | 2 | import PropTypes from 'prop-types'; |
3 | import { observer, PropTypes as MobxPropTypes } from 'mobx-react'; | 3 | import { observer, PropTypes as MobxPropTypes, inject } from 'mobx-react'; |
4 | import { Link } from 'react-router'; | 4 | import { Link } from 'react-router'; |
5 | import { defineMessages, intlShape } from 'react-intl'; | 5 | import { defineMessages, intlShape } from 'react-intl'; |
6 | import Confetti from 'react-confetti'; | 6 | import Confetti from 'react-confetti'; |
@@ -9,6 +9,7 @@ import injectSheet from 'react-jss'; | |||
9 | 9 | ||
10 | import ServiceView from './ServiceView'; | 10 | import ServiceView from './ServiceView'; |
11 | import Appear from '../../ui/effects/Appear'; | 11 | import Appear from '../../ui/effects/Appear'; |
12 | import serverlessLogin from '../../../helpers/serverless-helpers'; | ||
12 | 13 | ||
13 | const messages = defineMessages({ | 14 | const messages = defineMessages({ |
14 | welcome: { | 15 | welcome: { |
@@ -23,6 +24,10 @@ const messages = defineMessages({ | |||
23 | id: 'services.login', | 24 | id: 'services.login', |
24 | defaultMessage: '!!!Please login to use Ferdi.', | 25 | defaultMessage: '!!!Please login to use Ferdi.', |
25 | }, | 26 | }, |
27 | serverless: { | ||
28 | id: 'services.serverless', | ||
29 | defaultMessage: '!!!Use Ferdi without an Account', | ||
30 | }, | ||
26 | serverInfo: { | 31 | serverInfo: { |
27 | id: 'services.serverInfo', | 32 | id: 'services.serverInfo', |
28 | defaultMessage: '!!!Optionally, you can change your Ferdi server by clicking the cog in the bottom left corner.', | 33 | defaultMessage: '!!!Optionally, you can change your Ferdi server by clicking the cog in the bottom left corner.', |
@@ -39,7 +44,7 @@ const styles = { | |||
39 | }, | 44 | }, |
40 | }; | 45 | }; |
41 | 46 | ||
42 | export default @observer @injectSheet(styles) class Services extends Component { | 47 | export default @observer @inject('actions') @injectSheet(styles) class Services extends Component { |
43 | static propTypes = { | 48 | static propTypes = { |
44 | services: MobxPropTypes.arrayOrObservableArray, | 49 | services: MobxPropTypes.arrayOrObservableArray, |
45 | setWebviewReference: PropTypes.func.isRequired, | 50 | setWebviewReference: PropTypes.func.isRequired, |
@@ -52,6 +57,7 @@ export default @observer @injectSheet(styles) class Services extends Component { | |||
52 | userHasCompletedSignup: PropTypes.bool.isRequired, | 57 | userHasCompletedSignup: PropTypes.bool.isRequired, |
53 | hasActivatedTrial: PropTypes.bool.isRequired, | 58 | hasActivatedTrial: PropTypes.bool.isRequired, |
54 | classes: PropTypes.object.isRequired, | 59 | classes: PropTypes.object.isRequired, |
60 | actions: PropTypes.object.isRequired, | ||
55 | }; | 61 | }; |
56 | 62 | ||
57 | static defaultProps = { | 63 | static defaultProps = { |
@@ -68,6 +74,12 @@ export default @observer @injectSheet(styles) class Services extends Component { | |||
68 | 74 | ||
69 | _confettiTimeout = null; | 75 | _confettiTimeout = null; |
70 | 76 | ||
77 | constructor(props) { | ||
78 | super(props); | ||
79 | |||
80 | this.useLocalServer = this.useLocalServer.bind(this); | ||
81 | } | ||
82 | |||
71 | componentDidMount() { | 83 | componentDidMount() { |
72 | this._confettiTimeout = window.setTimeout(() => { | 84 | this._confettiTimeout = window.setTimeout(() => { |
73 | this.setState({ | 85 | this.setState({ |
@@ -82,6 +94,10 @@ export default @observer @injectSheet(styles) class Services extends Component { | |||
82 | } | 94 | } |
83 | } | 95 | } |
84 | 96 | ||
97 | useLocalServer() { | ||
98 | serverlessLogin(this.props.actions); | ||
99 | } | ||
100 | |||
85 | render() { | 101 | render() { |
86 | const { | 102 | const { |
87 | services, | 103 | services, |
@@ -136,6 +152,18 @@ export default @observer @injectSheet(styles) class Services extends Component { | |||
136 | <Link to={isLoggedIn ? '/settings/services' : '/auth/welcome'} className="button"> | 152 | <Link to={isLoggedIn ? '/settings/services' : '/auth/welcome'} className="button"> |
137 | { isLoggedIn ? intl.formatMessage(messages.getStarted) : 'Login' } | 153 | { isLoggedIn ? intl.formatMessage(messages.getStarted) : 'Login' } |
138 | </Link> | 154 | </Link> |
155 | {!isLoggedIn && ( | ||
156 | <button | ||
157 | type="button" | ||
158 | className="button" | ||
159 | style={{ | ||
160 | marginLeft: 10, | ||
161 | }} | ||
162 | onClick={this.useLocalServer} | ||
163 | > | ||
164 | {intl.formatMessage(messages.serverless)} | ||
165 | </button> | ||
166 | )} | ||
139 | </Appear> | 167 | </Appear> |
140 | </div> | 168 | </div> |
141 | </Appear> | 169 | </Appear> |