summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-08-09 09:53:22 -0400
committerenahum <nahumhbl@gmail.com>2016-08-09 08:53:22 -0500
commit0afa28de0953ed528486a7d7ad6000f344624710 (patch)
treea31d1668aab355784547d1bc93ab3d8801ed2dd7 /webapp
parent09d98b486e8245ae84a452331e36e2978a6d01ab (diff)
downloadchat-0afa28de0953ed528486a7d7ad6000f344624710.tar.gz
chat-0afa28de0953ed528486a7d7ad6000f344624710.tar.bz2
chat-0afa28de0953ed528486a7d7ad6000f344624710.zip
Changed autodetection of SiteURL (#3764)
* Changed autoconfiguration of SiteURL to be done on every request * Added SiteURL to system console
Diffstat (limited to 'webapp')
-rw-r--r--webapp/actions/websocket_actions.jsx2
-rw-r--r--webapp/components/admin_console/configuration_settings.jsx20
-rw-r--r--webapp/components/create_team/components/team_url.jsx2
-rw-r--r--webapp/components/integrations/components/installed_incoming_webhook.jsx2
-rw-r--r--webapp/i18n/en.json3
-rw-r--r--webapp/stores/team_store.jsx28
-rw-r--r--webapp/utils/utils.jsx4
7 files changed, 43 insertions, 18 deletions
diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx
index e93b2d25b..9150e4111 100644
--- a/webapp/actions/websocket_actions.jsx
+++ b/webapp/actions/websocket_actions.jsx
@@ -32,7 +32,7 @@ const MAX_WEBSOCKET_FAILS = 7;
export function initialize() {
if (window.WebSocket) {
- let connUrl = window.mm_config.SiteURL;
+ let connUrl = Utils.getSiteURL();
// replace the protocol with a websocket one
if (connUrl.startsWith('https:')) {
diff --git a/webapp/components/admin_console/configuration_settings.jsx b/webapp/components/admin_console/configuration_settings.jsx
index e34167a30..6a07e31cd 100644
--- a/webapp/components/admin_console/configuration_settings.jsx
+++ b/webapp/components/admin_console/configuration_settings.jsx
@@ -28,6 +28,7 @@ export default class ConfigurationSettings extends AdminSettings {
}
getConfigFromState(config) {
+ config.ServiceSettings.SiteURL = this.state.siteURL;
config.ServiceSettings.ListenAddress = this.state.listenAddress;
config.ServiceSettings.WebserverMode = this.state.webserverMode;
@@ -36,6 +37,7 @@ export default class ConfigurationSettings extends AdminSettings {
getStateFromConfig(config) {
return {
+ siteURL: config.ServiceSettings.SiteURL,
listenAddress: config.ServiceSettings.ListenAddress,
webserverMode: config.ServiceSettings.WebserverMode
};
@@ -56,6 +58,24 @@ export default class ConfigurationSettings extends AdminSettings {
return (
<SettingsGroup>
<TextSetting
+ id='siteURL'
+ label={
+ <FormattedMessage
+ id='admin.service.siteURL'
+ defaultMessage='Site URL:'
+ />
+ }
+ placeholder={Utils.localizeMessage('admin.service.siteURLExample', 'Ex "https://mattermost.example.com:1234"')}
+ helpText={
+ <FormattedMessage
+ id='admin.service.siteURLDescription'
+ defaultMessage='The URL, including port number and protocol, from which users will access Mattermost. Leave blank to automatically configure based on incoming traffic.'
+ />
+ }
+ value={this.state.siteURL}
+ onChange={this.handleChange}
+ />
+ <TextSetting
id='listenAddress'
label={
<FormattedMessage
diff --git a/webapp/components/create_team/components/team_url.jsx b/webapp/components/create_team/components/team_url.jsx
index bcbe0a1a1..b6c7d38f3 100644
--- a/webapp/components/create_team/components/team_url.jsx
+++ b/webapp/components/create_team/components/team_url.jsx
@@ -105,7 +105,7 @@ export default class TeamUrl extends React.Component {
nameDivClass += ' has-error';
}
- const title = `${window.mm_config.SiteURL}/`;
+ const title = `${Utils.getSiteURL()}/`;
const urlTooltip = (
<Tooltip id='urlTooltip'>{title}</Tooltip>
);
diff --git a/webapp/components/integrations/components/installed_incoming_webhook.jsx b/webapp/components/integrations/components/installed_incoming_webhook.jsx
index 008000012..965ed2bc9 100644
--- a/webapp/components/integrations/components/installed_incoming_webhook.jsx
+++ b/webapp/components/integrations/components/installed_incoming_webhook.jsx
@@ -97,7 +97,7 @@ export default class InstalledIncomingWebhook extends React.Component {
id='installed_integrations.url'
defaultMessage='URL: {url}'
values={{
- url: window.mm_config.SiteURL + '/hooks/' + incomingWebhook.id
+ url: Utils.getSiteURL() + '/hooks/' + incomingWebhook.id
}}
/>
</span>
diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json
index 1dc2f49d1..478fbf362 100644
--- a/webapp/i18n/en.json
+++ b/webapp/i18n/en.json
@@ -640,6 +640,9 @@
"admin.service.sessionCache": "Session Cache (minutes):",
"admin.service.sessionCacheDesc": "The number of minutes to cache a session in memory.",
"admin.service.sessionDaysEx": "Ex \"30\"",
+ "admin.service.siteURL": "Site URL:",
+ "admin.service.siteURLDescription": "The URL, including port number and protocol, from which users will access Mattermost. Leave blank to automatically configure based on incoming traffic.",
+ "admin.service.siteURLExample": "Ex \"https://mattermost.example.com:1234\"",
"admin.service.ssoSessionDays": "Session length SSO (days):",
"admin.service.ssoSessionDaysDesc": "The number of days from the last time a user entered their credentials to the expiry of the user's session. If the authentication method is SAML or GitLab, the user may automatically be logged back in to Mattermost if they are already logged in to SAML or GitLab. After changing this setting, the setting will take effect after the next time the user enters their credentials.",
"admin.service.testingDescription": "When true, /loadtest slash command is enabled to load test accounts, data and text formatting. Changing this requires a server restart before taking effect.",
diff --git a/webapp/stores/team_store.jsx b/webapp/stores/team_store.jsx
index a482fa3a1..90cb66bb2 100644
--- a/webapp/stores/team_store.jsx
+++ b/webapp/stores/team_store.jsx
@@ -60,13 +60,7 @@ class TeamStoreClass extends EventEmitter {
}
getCurrentId() {
- var team = this.get(this.currentTeamId);
-
- if (team) {
- return team.id;
- }
-
- return null;
+ return this.currentTeamId;
}
getCurrent() {
@@ -80,10 +74,7 @@ class TeamStoreClass extends EventEmitter {
}
getCurrentTeamUrl() {
- if (this.getCurrent()) {
- return window.mm_config.SiteURL + '/' + this.getCurrent().name;
- }
- return '';
+ return this.getTeamUrl(this.currentTeamId);
}
getCurrentTeamRelativeUrl() {
@@ -97,7 +88,10 @@ class TeamStoreClass extends EventEmitter {
const current = this.getCurrent();
if (current) {
- return window.mm_config.SiteURL + '/signup_user_complete/?id=' + current.invite_id;
+ // can't call Utils.getSiteURL here because that introduces a circular dependency
+ const origin = window.mm_config.SiteURL || window.location.origin;
+
+ return origin + '/signup_user_complete/?id=' + current.invite_id;
}
return '';
@@ -105,11 +99,15 @@ class TeamStoreClass extends EventEmitter {
getTeamUrl(id) {
const team = this.get(id);
- if (team) {
- return window.mm_config.SiteURL + '/' + team.name;
+
+ if (!team) {
+ return '';
}
- return '';
+ // can't call Utils.getSiteURL here because that introduces a circular dependency
+ const origin = window.mm_config.SiteURL || window.location.origin;
+
+ return origin + '/' + team.name;
}
saveTeam(team) {
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index e3db6d827..9731d3ce2 100644
--- a/webapp/utils/utils.jsx
+++ b/webapp/utils/utils.jsx
@@ -1338,3 +1338,7 @@ export function isValidPassword(password) {
return errorMsg;
}
+
+export function getSiteURL() {
+ return global.mm_config.SiteURL || window.location.origin;
+} \ No newline at end of file