diff --git a/webapp/channels/src/components/admin_console/push_settings.jsx b/webapp/channels/src/components/admin_console/push_settings.jsx index bbce3d8a0a..e8d44c0b34 100644 --- a/webapp/channels/src/components/admin_console/push_settings.jsx +++ b/webapp/channels/src/components/admin_console/push_settings.jsx @@ -19,6 +19,17 @@ const PUSH_NOTIFICATIONS_MHPNS = 'mhpns'; const PUSH_NOTIFICATIONS_MTPNS = 'mtpns'; const PUSH_NOTIFICATIONS_CUSTOM = 'custom'; +const PUSH_NOTIFICATIONS_LOCATION_US = 'us'; +const PUSH_NOTIFICATIONS_LOCATION_DE = 'de'; + +const PUSH_NOTIFICATIONS_SERVER_DIC = { + [PUSH_NOTIFICATIONS_LOCATION_US]: Constants.MHPNS_US, + [PUSH_NOTIFICATIONS_LOCATION_DE]: Constants.MHPNS_DE, +}; + +const DROPDOWN_ID_SERVER_TYPE = 'pushNotificationServerType'; +const DROPDOWN_ID_SERVER_LOCATION = 'pushNotificationServerLocation'; + export default class PushSettings extends AdminSettings { canSave = () => { return this.state.pushNotificationServerType !== PUSH_NOTIFICATIONS_MHPNS || this.state.agree; @@ -31,14 +42,14 @@ export default class PushSettings extends AdminSettings { }; handleDropdownChange = (id, value) => { - if (id === 'pushNotificationServerType') { + if (id === DROPDOWN_ID_SERVER_TYPE) { this.setState({ agree: false, }); if (value === PUSH_NOTIFICATIONS_MHPNS) { this.setState({ - pushNotificationServer: Constants.MHPNS, + pushNotificationServer: PUSH_NOTIFICATIONS_SERVER_DIC[this.state.pushNotificationServerLocation], }); } else if (value === PUSH_NOTIFICATIONS_MTPNS) { this.setState({ @@ -53,6 +64,13 @@ export default class PushSettings extends AdminSettings { } } + if (id === DROPDOWN_ID_SERVER_LOCATION) { + this.setState({ + pushNotificationServer: PUSH_NOTIFICATIONS_SERVER_DIC[value], + pushNotificationServerLocation: value, + }); + } + this.handleChange(id, value); }; @@ -67,11 +85,18 @@ export default class PushSettings extends AdminSettings { getStateFromConfig(config) { let pushNotificationServerType = PUSH_NOTIFICATIONS_CUSTOM; let agree = false; + let pushNotificationServerLocation = PUSH_NOTIFICATIONS_LOCATION_US; if (!config.EmailSettings.SendPushNotifications) { pushNotificationServerType = PUSH_NOTIFICATIONS_OFF; - } else if (config.EmailSettings.PushNotificationServer === Constants.MHPNS && + } else if (config.EmailSettings.PushNotificationServer === Constants.MHPNS_US && this.props.license.IsLicensed === 'true' && this.props.license.MHPNS === 'true') { pushNotificationServerType = PUSH_NOTIFICATIONS_MHPNS; + pushNotificationServerLocation = PUSH_NOTIFICATIONS_LOCATION_US; + agree = true; + } else if (config.EmailSettings.PushNotificationServer === Constants.MHPNS_DE && + this.props.license.IsLicensed === 'true' && this.props.license.MHPNS === 'true') { + pushNotificationServerType = PUSH_NOTIFICATIONS_MHPNS; + pushNotificationServerLocation = PUSH_NOTIFICATIONS_LOCATION_DE; agree = true; } else if (config.EmailSettings.PushNotificationServer === Constants.MTPNS) { pushNotificationServerType = PUSH_NOTIFICATIONS_MTPNS; @@ -81,13 +106,14 @@ export default class PushSettings extends AdminSettings { if (pushNotificationServerType === PUSH_NOTIFICATIONS_MTPNS) { pushNotificationServer = Constants.MTPNS; } else if (pushNotificationServerType === PUSH_NOTIFICATIONS_MHPNS) { - pushNotificationServer = Constants.MHPNS; + pushNotificationServer = PUSH_NOTIFICATIONS_SERVER_DIC[pushNotificationServerLocation]; } const maxNotificationsPerChannel = config.TeamSettings.MaxNotificationsPerChannel; return { pushNotificationServerType, + pushNotificationServerLocation, pushNotificationServer, maxNotificationsPerChannel, agree, @@ -247,7 +273,7 @@ export default class PushSettings extends AdminSettings { {msg} ), - linkPricacy: (msg) => ( + linkPrivacy: (msg) => ( + } + value={this.state.pushNotificationServerLocation} + onChange={this.handleDropdownChange} + setByEnv={this.isPushNotificationServerSetByEnv()} + disabled={this.props.isDisabled} + /> + ); + } + return ( + {locationDropdown} {tosCheckbox} documentation on push notifications to learn more about setup options.", "admin.email.pushServerEx": "E.g.: \"https://push-test.mattermost.com\"", + "admin.email.pushServerLocationDE": "Germany", + "admin.email.pushServerLocationTitle": "Push Notification Server location:", + "admin.email.pushServerLocationUS": "US", "admin.email.pushServerTitle": "Push Notification Server:", "admin.email.pushTitle": "Enable Push Notifications: ", "admin.email.requireVerificationDescription": "Typically set to true in production. When true, Mattermost requires email verification after account creation prior to allowing login. Developers may set this field to false to skip sending verification emails for faster development.", diff --git a/webapp/channels/src/utils/constants.tsx b/webapp/channels/src/utils/constants.tsx index 469f9b7634..45a98bc49b 100644 --- a/webapp/channels/src/utils/constants.tsx +++ b/webapp/channels/src/utils/constants.tsx @@ -1936,7 +1936,8 @@ export const Constants = { EMOJI_PATH: '/static/emoji', RECENT_EMOJI_KEY: 'recentEmojis', DEFAULT_WEBHOOK_LOGO: logoWebhook, - MHPNS: 'https://push.mattermost.com', + MHPNS_US: 'https://push.mattermost.com', + MHPNS_DE: 'https://hpns-de.mattermost.com', MTPNS: 'https://push-test.mattermost.com', MAX_PREV_MSGS: 100, POST_COLLAPSE_TIMEOUT: 1000 * 60 * 5, // five minutes