diff options
author | 2017-12-24 22:11:36 +0100 | |
---|---|---|
committer | 2017-12-24 22:11:36 +0100 | |
commit | df44b69c4655415fe1e44689ece443ec06ef0f52 (patch) | |
tree | e677ed5f5328bb3b14bc976c7392d8e259f89034 /src/components/settings/services | |
parent | [wip] add icon upload (diff) | |
parent | Merge pull request #494 from heavypackets/websecurity-enable-patch (diff) | |
download | ferdium-app-df44b69c4655415fe1e44689ece443ec06ef0f52.tar.gz ferdium-app-df44b69c4655415fe1e44689ece443ec06ef0f52.tar.zst ferdium-app-df44b69c4655415fe1e44689ece443ec06ef0f52.zip |
Merge branch 'develop' into feature/icon-upload
Diffstat (limited to 'src/components/settings/services')
-rw-r--r-- | src/components/settings/services/EditServiceForm.js | 79 |
1 files changed, 61 insertions, 18 deletions
diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js index bcbda7773..ee69d53aa 100644 --- a/src/components/settings/services/EditServiceForm.js +++ b/src/components/settings/services/EditServiceForm.js | |||
@@ -48,6 +48,10 @@ const messages = defineMessages({ | |||
48 | id: 'settings.service.form.tabOnPremise', | 48 | id: 'settings.service.form.tabOnPremise', |
49 | defaultMessage: '!!!Self hosted ⭐️', | 49 | defaultMessage: '!!!Self hosted ⭐️', |
50 | }, | 50 | }, |
51 | useHostedService: { | ||
52 | id: 'settings.service.form.useHostedService', | ||
53 | defaultMessage: '!!!Use the hosted {name} service.', | ||
54 | }, | ||
51 | customUrlValidationError: { | 55 | customUrlValidationError: { |
52 | id: 'settings.service.form.customUrlValidationError', | 56 | id: 'settings.service.form.customUrlValidationError', |
53 | defaultMessage: '!!!Could not validate custom {name} server.', | 57 | defaultMessage: '!!!Could not validate custom {name} server.', |
@@ -68,6 +72,18 @@ const messages = defineMessages({ | |||
68 | id: 'settings.service.form.isMutedInfo', | 72 | id: 'settings.service.form.isMutedInfo', |
69 | defaultMessage: '!!!When disabled, all notification sounds and audio playback are muted', | 73 | defaultMessage: '!!!When disabled, all notification sounds and audio playback are muted', |
70 | }, | 74 | }, |
75 | headlineNotifications: { | ||
76 | id: 'settings.service.form.headlineNotifications', | ||
77 | defaultMessage: '!!!Notifications', | ||
78 | }, | ||
79 | headlineBadges: { | ||
80 | id: 'settings.service.form.headlineBadges', | ||
81 | defaultMessage: '!!!Unread message dadges', | ||
82 | }, | ||
83 | headlineGeneral: { | ||
84 | id: 'settings.service.form.headlineGeneral', | ||
85 | defaultMessage: '!!!General', | ||
86 | }, | ||
71 | }); | 87 | }); |
72 | 88 | ||
73 | @observer | 89 | @observer |
@@ -109,13 +125,12 @@ export default class EditServiceForm extends Component { | |||
109 | this.props.form.submit({ | 125 | this.props.form.submit({ |
110 | onSuccess: async (form) => { | 126 | onSuccess: async (form) => { |
111 | const values = form.values(); | 127 | const values = form.values(); |
112 | |||
113 | let isValid = true; | 128 | let isValid = true; |
114 | 129 | ||
115 | if (recipe.validateUrl && values.customUrl) { | 130 | if (recipe.validateUrl && values.customUrl) { |
116 | this.setState({ isValidatingCustomUrl: true }); | 131 | this.setState({ isValidatingCustomUrl: true }); |
117 | try { | 132 | try { |
118 | values.customUrl = normalizeUrl(values.customUrl); | 133 | values.customUrl = normalizeUrl(values.customUrl, { stripWWW: false }); |
119 | isValid = await recipe.validateUrl(values.customUrl); | 134 | isValid = await recipe.validateUrl(values.customUrl); |
120 | } catch (err) { | 135 | } catch (err) { |
121 | console.warn('ValidateURL', err); | 136 | console.warn('ValidateURL', err); |
@@ -167,6 +182,13 @@ export default class EditServiceForm extends Component { | |||
167 | /> | 182 | /> |
168 | ); | 183 | ); |
169 | 184 | ||
185 | let activeTabIndex = 0; | ||
186 | if (recipe.hasHostedOption && service.team) { | ||
187 | activeTabIndex = 1; | ||
188 | } else if (recipe.hasHostedOption && service.customUrl) { | ||
189 | activeTabIndex = 2; | ||
190 | } | ||
191 | |||
170 | return ( | 192 | return ( |
171 | <div className="settings__main"> | 193 | <div className="settings__main"> |
172 | <div className="settings__header"> | 194 | <div className="settings__header"> |
@@ -207,11 +229,20 @@ export default class EditServiceForm extends Component { | |||
207 | </div> | 229 | </div> |
208 | {(recipe.hasTeamId || recipe.hasCustomUrl) && ( | 230 | {(recipe.hasTeamId || recipe.hasCustomUrl) && ( |
209 | <Tabs | 231 | <Tabs |
210 | active={service.customUrl ? 1 : 0} | 232 | active={activeTabIndex} |
211 | > | 233 | > |
234 | {recipe.hasHostedOption && ( | ||
235 | <TabItem title={recipe.name}> | ||
236 | {intl.formatMessage(messages.useHostedService, { name: recipe.name })} | ||
237 | </TabItem> | ||
238 | )} | ||
212 | {recipe.hasTeamId && ( | 239 | {recipe.hasTeamId && ( |
213 | <TabItem title={intl.formatMessage(messages.tabHosted)}> | 240 | <TabItem title={intl.formatMessage(messages.tabHosted)}> |
214 | <Input field={form.$('team')} suffix={recipe.urlInputSuffix} /> | 241 | <Input |
242 | field={form.$('team')} | ||
243 | prefix={recipe.urlInputPrefix} | ||
244 | suffix={recipe.urlInputSuffix} | ||
245 | /> | ||
215 | </TabItem> | 246 | </TabItem> |
216 | )} | 247 | )} |
217 | {recipe.hasCustomUrl && ( | 248 | {recipe.hasCustomUrl && ( |
@@ -240,20 +271,32 @@ export default class EditServiceForm extends Component { | |||
240 | </Tabs> | 271 | </Tabs> |
241 | )} | 272 | )} |
242 | <div className="settings__options"> | 273 | <div className="settings__options"> |
243 | <Toggle field={form.$('isNotificationEnabled')} /> | 274 | <div className="settings__settings-group"> |
244 | {recipe.hasIndirectMessages && ( | 275 | <h3>{intl.formatMessage(messages.headlineNotifications)}</h3> |
245 | <div> | 276 | <Toggle field={form.$('isNotificationEnabled')} /> |
246 | <Toggle field={form.$('isIndirectMessageBadgeEnabled')} /> | 277 | <Toggle field={form.$('isMuted')} /> |
247 | <p className="settings__help"> | 278 | <p className="settings__help"> |
248 | {intl.formatMessage(messages.indirectMessageInfo)} | 279 | {intl.formatMessage(messages.isMutedInfo)} |
249 | </p> | 280 | </p> |
250 | </div> | 281 | </div> |
251 | )} | 282 | |
252 | <Toggle field={form.$('isMuted')} /> | 283 | <div className="settings__settings-group"> |
253 | <p className="settings__help"> | 284 | <h3>{intl.formatMessage(messages.headlineBadges)}</h3> |
254 | {intl.formatMessage(messages.isMutedInfo)} | 285 | <Toggle field={form.$('isBadgeEnabled')} /> |
255 | </p> | 286 | {recipe.hasIndirectMessages && form.$('isBadgeEnabled').value && ( |
256 | <Toggle field={form.$('isEnabled')} /> | 287 | <div> |
288 | <Toggle field={form.$('isIndirectMessageBadgeEnabled')} /> | ||
289 | <p className="settings__help"> | ||
290 | {intl.formatMessage(messages.indirectMessageInfo)} | ||
291 | </p> | ||
292 | </div> | ||
293 | )} | ||
294 | </div> | ||
295 | |||
296 | <div className="settings__settings-group"> | ||
297 | <h3>{intl.formatMessage(messages.headlineGeneral)}</h3> | ||
298 | <Toggle field={form.$('isEnabled')} /> | ||
299 | </div> | ||
257 | </div> | 300 | </div> |
258 | {recipe.message && ( | 301 | {recipe.message && ( |
259 | <p className="settings__message"> | 302 | <p className="settings__message"> |