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/services | |
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/services')
-rw-r--r-- | src/components/services/content/Services.js | 32 |
1 files changed, 30 insertions, 2 deletions
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> |