From 0afa28de0953ed528486a7d7ad6000f344624710 Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Tue, 9 Aug 2016 09:53:22 -0400
Subject: Changed autodetection of SiteURL (#3764)

* Changed autoconfiguration of SiteURL to be done on every request

* Added SiteURL to system console
---
 .../admin_console/configuration_settings.jsx         | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

(limited to 'webapp/components/admin_console/configuration_settings.jsx')

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
         };
@@ -55,6 +57,24 @@ export default class ConfigurationSettings extends AdminSettings {
     renderSettings() {
         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={
-- 
cgit v1.2.3-1-g7c22

