diff options
author | 2020-05-17 08:51:58 +0000 | |
---|---|---|
committer | 2020-05-17 08:51:58 +0000 | |
commit | 820094bea7f19f987c545515243337a83c6cbb86 (patch) | |
tree | effc5be058034ab714a5cb41754d12e9146ac58e /src | |
parent | docs: add kris7t as a contributor (#749) (diff) | |
download | ferdium-app-820094bea7f19f987c545515243337a83c6cbb86.tar.gz ferdium-app-820094bea7f19f987c545515243337a83c6cbb86.tar.zst ferdium-app-820094bea7f19f987c545515243337a83c6cbb86.zip |
Replace change server input with a dropdown menu (#717)
Diffstat (limited to 'src')
-rw-r--r-- | src/components/auth/ChangeServer.js | 66 | ||||
-rw-r--r-- | src/components/ui/Input.js | 2 | ||||
-rw-r--r-- | src/i18n/locales/defaultMessages.json | 63 | ||||
-rw-r--r-- | src/i18n/locales/en-US.json | 5 | ||||
-rw-r--r-- | src/i18n/messages/src/components/auth/ChangeServer.json | 51 |
5 files changed, 158 insertions, 29 deletions
diff --git a/src/components/auth/ChangeServer.js b/src/components/auth/ChangeServer.js index 433334b6c..68c2303a4 100644 --- a/src/components/auth/ChangeServer.js +++ b/src/components/auth/ChangeServer.js | |||
@@ -2,10 +2,12 @@ import React, { Component } from 'react'; | |||
2 | import PropTypes from 'prop-types'; | 2 | import PropTypes from 'prop-types'; |
3 | import { observer } from 'mobx-react'; | 3 | import { observer } from 'mobx-react'; |
4 | import { defineMessages, intlShape } from 'react-intl'; | 4 | import { defineMessages, intlShape } from 'react-intl'; |
5 | |||
6 | import Form from '../../lib/Form'; | 5 | import Form from '../../lib/Form'; |
7 | import Input from '../ui/Input'; | 6 | import Input from '../ui/Input'; |
7 | import Select from '../ui/Select'; | ||
8 | import Button from '../ui/Button'; | 8 | import Button from '../ui/Button'; |
9 | import Infobox from '../ui/Infobox'; | ||
10 | import { url, required } from '../../helpers/validation-helpers'; | ||
9 | 11 | ||
10 | const messages = defineMessages({ | 12 | const messages = defineMessages({ |
11 | headline: { | 13 | headline: { |
@@ -16,10 +18,23 @@ const messages = defineMessages({ | |||
16 | id: 'changeserver.label', | 18 | id: 'changeserver.label', |
17 | defaultMessage: '!!!Server', | 19 | defaultMessage: '!!!Server', |
18 | }, | 20 | }, |
21 | warning: { | ||
22 | id: 'changeserver.warning', | ||
23 | defaultMessage: '!!!Extra settings offered by Ferdi will not be saved', | ||
24 | }, | ||
25 | customServerLabel: { | ||
26 | id: 'changeserver.customServerLabel', | ||
27 | defaultMessage: '!!!Custom server', | ||
28 | }, | ||
29 | urlError: { | ||
30 | id: 'changeserver.urlError', | ||
31 | defaultMessage: '!!!Enter a valid URL', | ||
32 | }, | ||
19 | submit: { | 33 | submit: { |
20 | id: 'changeserver.submit', | 34 | id: 'changeserver.submit', |
21 | defaultMessage: '!!!Submit', | 35 | defaultMessage: '!!!Submit', |
22 | }, | 36 | }, |
37 | |||
23 | }); | 38 | }); |
24 | 39 | ||
25 | export default @observer class ChangeServer extends Component { | 40 | export default @observer class ChangeServer extends Component { |
@@ -32,42 +47,75 @@ export default @observer class ChangeServer extends Component { | |||
32 | intl: intlShape, | 47 | intl: intlShape, |
33 | }; | 48 | }; |
34 | 49 | ||
50 | ferdiServer='https://api.getferdi.com'; | ||
51 | |||
52 | franzServer='https://api.franzinfra.com'; | ||
53 | |||
54 | defaultServers=[this.franzServer, this.ferdiServer]; | ||
55 | |||
35 | form = new Form({ | 56 | form = new Form({ |
36 | fields: { | 57 | fields: { |
37 | server: { | 58 | server: { |
38 | label: this.context.intl.formatMessage(messages.label), | 59 | label: this.context.intl.formatMessage(messages.label), |
60 | value: this.props.server, | ||
61 | options: [{ value: this.ferdiServer, label: 'Ferdi' }, { value: this.franzServer, label: 'Franz' }, { value: this.defaultServers.includes(this.props.server) ? '' : this.props.server, label: 'Custom' }], | ||
62 | }, | ||
63 | customServer: { | ||
64 | label: this.context.intl.formatMessage(messages.customServerLabel), | ||
39 | value: '', | 65 | value: '', |
66 | validators: [url, required], | ||
40 | }, | 67 | }, |
41 | }, | 68 | }, |
42 | }, this.context.intl); | 69 | }, this.context.intl); |
43 | 70 | ||
44 | componentDidMount() { | 71 | componentDidMount() { |
45 | this.form.$('server').value = this.props.server; | 72 | if (this.defaultServers.includes(this.props.server)) { |
73 | this.form.$('server').value = this.props.server; | ||
74 | } else { | ||
75 | this.form.$('server').value = ''; | ||
76 | this.form.$('customServer').value = this.props.server; | ||
77 | } | ||
46 | } | 78 | } |
47 | 79 | ||
48 | submit(e) { | 80 | submit(e) { |
49 | e.preventDefault(); | 81 | e.preventDefault(); |
50 | this.form.submit({ | 82 | this.form.submit({ |
51 | onSuccess: (form) => { | 83 | onSuccess: (form) => { |
84 | if (!this.defaultServers.includes(form.values().server)) { | ||
85 | form.$('server').onChange(form.values().customServer); | ||
86 | } | ||
52 | this.props.onSubmit(form.values()); | 87 | this.props.onSubmit(form.values()); |
53 | }, | 88 | }, |
54 | onError: () => { }, | 89 | onError: (form) => { |
90 | if (this.defaultServers.includes(form.values().server)) { | ||
91 | this.props.onSubmit(form.values()); | ||
92 | } | ||
93 | }, | ||
55 | }); | 94 | }); |
56 | } | 95 | } |
57 | 96 | ||
58 | render() { | 97 | render() { |
59 | const { form } = this; | 98 | const { form } = this; |
60 | const { intl } = this.context; | 99 | const { intl } = this.context; |
61 | |||
62 | return ( | 100 | return ( |
63 | <div className="auth__container"> | 101 | <div className="auth__container"> |
64 | <form className="franz-form auth__form" onSubmit={e => this.submit(e)}> | 102 | <form className="franz-form auth__form" onSubmit={e => this.submit(e)}> |
65 | <h1>{intl.formatMessage(messages.headline)}</h1> | 103 | <h1>{intl.formatMessage(messages.headline)}</h1> |
66 | 104 | {form.$('server').value === this.franzServer | |
67 | <Input | 105 | && ( |
68 | field={form.$('server')} | 106 | <Infobox type="warning"> |
69 | focus | 107 | {intl.formatMessage(messages.warning)} |
70 | /> | 108 | </Infobox> |
109 | )} | ||
110 | <Select field={form.$('server')} /> | ||
111 | {!this.defaultServers.includes(form.$('server').value) | ||
112 | && ( | ||
113 | <Input | ||
114 | placeholder="Custom Server" | ||
115 | onChange={e => this.submit(e)} | ||
116 | field={form.$('customServer')} | ||
117 | /> | ||
118 | )} | ||
71 | <Button | 119 | <Button |
72 | type="submit" | 120 | type="submit" |
73 | className="auth__button" | 121 | className="auth__button" |
diff --git a/src/components/ui/Input.js b/src/components/ui/Input.js index 4e3eb4ab8..387086eb9 100644 --- a/src/components/ui/Input.js +++ b/src/components/ui/Input.js | |||
@@ -72,7 +72,7 @@ export default @observer class Input extends Component { | |||
72 | if (type === 'password' && this.state.showPassword) { | 72 | if (type === 'password' && this.state.showPassword) { |
73 | type = 'text'; | 73 | type = 'text'; |
74 | } | 74 | } |
75 | 75 | ||
76 | return ( | 76 | return ( |
77 | <div | 77 | <div |
78 | className={classnames({ | 78 | className={classnames({ |
diff --git a/src/i18n/locales/defaultMessages.json b/src/i18n/locales/defaultMessages.json index 6b3f3066c..619269a64 100644 --- a/src/i18n/locales/defaultMessages.json +++ b/src/i18n/locales/defaultMessages.json | |||
@@ -49,39 +49,78 @@ | |||
49 | "defaultMessage": "!!!Change server", | 49 | "defaultMessage": "!!!Change server", |
50 | "end": { | 50 | "end": { |
51 | "column": 3, | 51 | "column": 3, |
52 | "line": 14 | 52 | "line": 16 |
53 | }, | 53 | }, |
54 | "file": "src/components/auth/ChangeServer.js", | 54 | "file": "src/components/auth/ChangeServer.js", |
55 | "id": "changeserver.headline", | 55 | "id": "changeserver.headline", |
56 | "start": { | 56 | "start": { |
57 | "column": 12, | 57 | "column": 12, |
58 | "line": 11 | 58 | "line": 13 |
59 | } | 59 | } |
60 | }, | 60 | }, |
61 | { | 61 | { |
62 | "defaultMessage": "!!!Server", | 62 | "defaultMessage": "!!!Server", |
63 | "end": { | 63 | "end": { |
64 | "column": 3, | 64 | "column": 3, |
65 | "line": 18 | 65 | "line": 20 |
66 | }, | 66 | }, |
67 | "file": "src/components/auth/ChangeServer.js", | 67 | "file": "src/components/auth/ChangeServer.js", |
68 | "id": "changeserver.label", | 68 | "id": "changeserver.label", |
69 | "start": { | 69 | "start": { |
70 | "column": 9, | 70 | "column": 9, |
71 | "line": 15 | 71 | "line": 17 |
72 | } | ||
73 | }, | ||
74 | { | ||
75 | "defaultMessage": "!!!Extra settings offered by Ferdi will not be saved", | ||
76 | "end": { | ||
77 | "column": 3, | ||
78 | "line": 24 | ||
79 | }, | ||
80 | "file": "src/components/auth/ChangeServer.js", | ||
81 | "id": "changeserver.warning", | ||
82 | "start": { | ||
83 | "column": 11, | ||
84 | "line": 21 | ||
85 | } | ||
86 | }, | ||
87 | { | ||
88 | "defaultMessage": "!!!Custom server", | ||
89 | "end": { | ||
90 | "column": 3, | ||
91 | "line": 28 | ||
92 | }, | ||
93 | "file": "src/components/auth/ChangeServer.js", | ||
94 | "id": "changeserver.customServerLabel", | ||
95 | "start": { | ||
96 | "column": 21, | ||
97 | "line": 25 | ||
98 | } | ||
99 | }, | ||
100 | { | ||
101 | "defaultMessage": "!!!Enter a valid URL", | ||
102 | "end": { | ||
103 | "column": 3, | ||
104 | "line": 32 | ||
105 | }, | ||
106 | "file": "src/components/auth/ChangeServer.js", | ||
107 | "id": "changeserver.urlError", | ||
108 | "start": { | ||
109 | "column": 12, | ||
110 | "line": 29 | ||
72 | } | 111 | } |
73 | }, | 112 | }, |
74 | { | 113 | { |
75 | "defaultMessage": "!!!Submit", | 114 | "defaultMessage": "!!!Submit", |
76 | "end": { | 115 | "end": { |
77 | "column": 3, | 116 | "column": 3, |
78 | "line": 22 | 117 | "line": 36 |
79 | }, | 118 | }, |
80 | "file": "src/components/auth/ChangeServer.js", | 119 | "file": "src/components/auth/ChangeServer.js", |
81 | "id": "changeserver.submit", | 120 | "id": "changeserver.submit", |
82 | "start": { | 121 | "start": { |
83 | "column": 10, | 122 | "column": 10, |
84 | "line": 19 | 123 | "line": 33 |
85 | } | 124 | } |
86 | } | 125 | } |
87 | ], | 126 | ], |
@@ -5916,39 +5955,39 @@ | |||
5916 | "defaultMessage": "!!!Franz Todos are available to premium users now!", | 5955 | "defaultMessage": "!!!Franz Todos are available to premium users now!", |
5917 | "end": { | 5956 | "end": { |
5918 | "column": 3, | 5957 | "column": 3, |
5919 | "line": 30 | 5958 | "line": 34 |
5920 | }, | 5959 | }, |
5921 | "file": "src/features/todos/components/TodosWebview.js", | 5960 | "file": "src/features/todos/components/TodosWebview.js", |
5922 | "id": "feature.todos.premium.info", | 5961 | "id": "feature.todos.premium.info", |
5923 | "start": { | 5962 | "start": { |
5924 | "column": 15, | 5963 | "column": 15, |
5925 | "line": 27 | 5964 | "line": 31 |
5926 | } | 5965 | } |
5927 | }, | 5966 | }, |
5928 | { | 5967 | { |
5929 | "defaultMessage": "!!!Upgrade Account", | 5968 | "defaultMessage": "!!!Upgrade Account", |
5930 | "end": { | 5969 | "end": { |
5931 | "column": 3, | 5970 | "column": 3, |
5932 | "line": 34 | 5971 | "line": 38 |
5933 | }, | 5972 | }, |
5934 | "file": "src/features/todos/components/TodosWebview.js", | 5973 | "file": "src/features/todos/components/TodosWebview.js", |
5935 | "id": "feature.todos.premium.upgrade", | 5974 | "id": "feature.todos.premium.upgrade", |
5936 | "start": { | 5975 | "start": { |
5937 | "column": 14, | 5976 | "column": 14, |
5938 | "line": 31 | 5977 | "line": 35 |
5939 | } | 5978 | } |
5940 | }, | 5979 | }, |
5941 | { | 5980 | { |
5942 | "defaultMessage": "!!!Everyone else will have to wait a little longer.", | 5981 | "defaultMessage": "!!!Everyone else will have to wait a little longer.", |
5943 | "end": { | 5982 | "end": { |
5944 | "column": 3, | 5983 | "column": 3, |
5945 | "line": 38 | 5984 | "line": 42 |
5946 | }, | 5985 | }, |
5947 | "file": "src/features/todos/components/TodosWebview.js", | 5986 | "file": "src/features/todos/components/TodosWebview.js", |
5948 | "id": "feature.todos.premium.rollout", | 5987 | "id": "feature.todos.premium.rollout", |
5949 | "start": { | 5988 | "start": { |
5950 | "column": 15, | 5989 | "column": 15, |
5951 | "line": 35 | 5990 | "line": 39 |
5952 | } | 5991 | } |
5953 | } | 5992 | } |
5954 | ], | 5993 | ], |
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json index 5c33daf86..8e4277fb8 100644 --- a/src/i18n/locales/en-US.json +++ b/src/i18n/locales/en-US.json | |||
@@ -1,9 +1,12 @@ | |||
1 | { | 1 | { |
2 | "app.errorHandler.action": "Reload", | 2 | "app.errorHandler.action": "Reload", |
3 | "app.errorHandler.headline": "Something went wrong", | 3 | "app.errorHandler.headline": "Something went wrong", |
4 | "changeserver.customServerLabel": "Custom server", | ||
4 | "changeserver.headline": "Change server", | 5 | "changeserver.headline": "Change server", |
5 | "changeserver.label": "Server", | 6 | "changeserver.label": "Server", |
6 | "changeserver.submit": "Submit", | 7 | "changeserver.submit": "Submit", |
8 | "changeserver.urlError": "Enter a valid URL", | ||
9 | "changeserver.warning": "Extra settings offered by Ferdi will not be saved", | ||
7 | "connectionLostBanner.cta": "Reload Service", | 10 | "connectionLostBanner.cta": "Reload Service", |
8 | "connectionLostBanner.informationLink": "What happened?", | 11 | "connectionLostBanner.informationLink": "What happened?", |
9 | "connectionLostBanner.message": "Oh no! Ferdi lost the connection to {name}.", | 12 | "connectionLostBanner.message": "Oh no! Ferdi lost the connection to {name}.", |
@@ -525,4 +528,4 @@ | |||
525 | "workspaceDrawer.workspaceFeatureInfo": "<p>Ferdi Workspaces let you focus on what’s important right now. Set up different sets of services and easily switch between them at any time.</p><p>You decide which services you need when and where, so we can help you stay on top of your game - or easily switch off from work whenever you want.</p>", | 528 | "workspaceDrawer.workspaceFeatureInfo": "<p>Ferdi Workspaces let you focus on what’s important right now. Set up different sets of services and easily switch between them at any time.</p><p>You decide which services you need when and where, so we can help you stay on top of your game - or easily switch off from work whenever you want.</p>", |
526 | "workspaceDrawer.workspacesSettingsTooltip": "Edit workspaces settings", | 529 | "workspaceDrawer.workspacesSettingsTooltip": "Edit workspaces settings", |
527 | "workspaces.switchingIndicator.switchingTo": "Switching to" | 530 | "workspaces.switchingIndicator.switchingTo": "Switching to" |
528 | } | 531 | } \ No newline at end of file |
diff --git a/src/i18n/messages/src/components/auth/ChangeServer.json b/src/i18n/messages/src/components/auth/ChangeServer.json index 3a122d50c..8cdfc6623 100644 --- a/src/i18n/messages/src/components/auth/ChangeServer.json +++ b/src/i18n/messages/src/components/auth/ChangeServer.json | |||
@@ -4,11 +4,11 @@ | |||
4 | "defaultMessage": "!!!Change server", | 4 | "defaultMessage": "!!!Change server", |
5 | "file": "src/components/auth/ChangeServer.js", | 5 | "file": "src/components/auth/ChangeServer.js", |
6 | "start": { | 6 | "start": { |
7 | "line": 11, | 7 | "line": 13, |
8 | "column": 12 | 8 | "column": 12 |
9 | }, | 9 | }, |
10 | "end": { | 10 | "end": { |
11 | "line": 14, | 11 | "line": 16, |
12 | "column": 3 | 12 | "column": 3 |
13 | } | 13 | } |
14 | }, | 14 | }, |
@@ -17,11 +17,50 @@ | |||
17 | "defaultMessage": "!!!Server", | 17 | "defaultMessage": "!!!Server", |
18 | "file": "src/components/auth/ChangeServer.js", | 18 | "file": "src/components/auth/ChangeServer.js", |
19 | "start": { | 19 | "start": { |
20 | "line": 15, | 20 | "line": 17, |
21 | "column": 9 | 21 | "column": 9 |
22 | }, | 22 | }, |
23 | "end": { | 23 | "end": { |
24 | "line": 18, | 24 | "line": 20, |
25 | "column": 3 | ||
26 | } | ||
27 | }, | ||
28 | { | ||
29 | "id": "changeserver.warning", | ||
30 | "defaultMessage": "!!!Extra settings offered by Ferdi will not be saved", | ||
31 | "file": "src/components/auth/ChangeServer.js", | ||
32 | "start": { | ||
33 | "line": 21, | ||
34 | "column": 11 | ||
35 | }, | ||
36 | "end": { | ||
37 | "line": 24, | ||
38 | "column": 3 | ||
39 | } | ||
40 | }, | ||
41 | { | ||
42 | "id": "changeserver.customServerLabel", | ||
43 | "defaultMessage": "!!!Custom server", | ||
44 | "file": "src/components/auth/ChangeServer.js", | ||
45 | "start": { | ||
46 | "line": 25, | ||
47 | "column": 21 | ||
48 | }, | ||
49 | "end": { | ||
50 | "line": 28, | ||
51 | "column": 3 | ||
52 | } | ||
53 | }, | ||
54 | { | ||
55 | "id": "changeserver.urlError", | ||
56 | "defaultMessage": "!!!Enter a valid URL", | ||
57 | "file": "src/components/auth/ChangeServer.js", | ||
58 | "start": { | ||
59 | "line": 29, | ||
60 | "column": 12 | ||
61 | }, | ||
62 | "end": { | ||
63 | "line": 32, | ||
25 | "column": 3 | 64 | "column": 3 |
26 | } | 65 | } |
27 | }, | 66 | }, |
@@ -30,11 +69,11 @@ | |||
30 | "defaultMessage": "!!!Submit", | 69 | "defaultMessage": "!!!Submit", |
31 | "file": "src/components/auth/ChangeServer.js", | 70 | "file": "src/components/auth/ChangeServer.js", |
32 | "start": { | 71 | "start": { |
33 | "line": 19, | 72 | "line": 33, |
34 | "column": 10 | 73 | "column": 10 |
35 | }, | 74 | }, |
36 | "end": { | 75 | "end": { |
37 | "line": 22, | 76 | "line": 36, |
38 | "column": 3 | 77 | "column": 3 |
39 | } | 78 | } |
40 | } | 79 | } |