PLT-5900 Removed automatic configuration of Site URL (#6135)

This commit is contained in:
Harrison Healey
2017-04-20 16:25:45 +01:00
committed by George Goldberg
parent 3179d3f66e
commit fb325cc339
8 changed files with 76 additions and 11 deletions
+1
View File
@@ -323,6 +323,7 @@ package: build build-client
@# Disable developer settings
sed -i'' -e 's|"ConsoleLevel": "DEBUG"|"ConsoleLevel": "INFO"|g' $(DIST_PATH)/config/config.json
sed -i'' -e 's|"SiteURL": "http://localhost:8065"|"SiteURL": ""|g' $(DIST_PATH)/config/config.json
@# Reset email sending to original configuration
sed -i'' -e 's|"SendEmailNotifications": true,|"SendEmailNotifications": false,|g' $(DIST_PATH)/config/config.json
+1 -6
View File
@@ -142,12 +142,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
isTokenFromQueryString = true
}
if utils.GetSiteURL() == "" {
protocol := app.GetProtocol(r)
c.SetSiteURL(protocol + "://" + r.Host)
} else {
c.SetSiteURL(utils.GetSiteURL())
}
c.SetSiteURL(utils.GetSiteURL())
w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId)
w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.CfgHash, utils.IsLicensed))
+1 -1
View File
@@ -1,6 +1,6 @@
{
"ServiceSettings": {
"SiteURL": "",
"SiteURL": "http://localhost:8065",
"ListenAddress": ":8065",
"ConnectionSecurity": "",
"TLSCertFile": "",
@@ -69,6 +69,10 @@ export default class AdminSettings extends React.Component {
if (callback) {
callback();
}
if (this.handleSaved) {
this.handleSaved(config);
}
},
(err) => {
this.setState({
@@ -79,6 +83,10 @@ export default class AdminSettings extends React.Component {
if (callback) {
callback();
}
if (this.handleSaved) {
this.handleSaved(config);
}
}
);
}
@@ -3,6 +3,8 @@
import React from 'react';
import ErrorStore from 'stores/error_store.jsx';
import * as Utils from 'utils/utils.jsx';
import AdminSettings from './admin_settings.jsx';
@@ -21,6 +23,8 @@ export default class ConfigurationSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.handleSaved = this.handleSaved.bind(this);
this.renderSettings = this.renderSettings.bind(this);
}
@@ -62,6 +66,14 @@ export default class ConfigurationSettings extends AdminSettings {
};
}
handleSaved(newConfig) {
const lastError = ErrorStore.getLastError();
if (lastError && lastError.message === 'error_bar.site_url' && newConfig.ServiceSettings.SiteURL) {
ErrorStore.clearLastError(true);
}
}
renderTitle() {
return (
<h3>
@@ -96,7 +108,7 @@ export default class ConfigurationSettings extends AdminSettings {
helpText={
<FormattedHTMLMessage
id='admin.service.siteURLDescription'
defaultMessage='The URL, including port number and protocol, that users will use to access Mattermost. This field can be left blank unless you are configuring email batching in <b>Notifications > Email</b>. When blank, the URL is automatically configured based on incoming traffic.'
defaultMessage='The URL, including port number and protocol, that users will use to access Mattermost. This setting is required.'
/>
}
value={this.state.siteURL}
+46 -1
View File
@@ -13,11 +13,13 @@ const StatTypes = Constants.StatTypes;
import React from 'react';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import {Link} from 'react-router';
const EXPIRING_ERROR = 'error_bar.expiring';
const EXPIRED_ERROR = 'error_bar.expired';
const PAST_GRACE_ERROR = 'error_bar.past_grace';
const RENEWAL_LINK = 'https://licensing.mattermost.com/renew';
const SITE_URL_ERROR = 'error_bar.site_url';
const BAR_DEVELOPER_TYPE = 'developer';
const BAR_CRITICAL_TYPE = 'critical';
@@ -38,7 +40,11 @@ export default class ErrorBar extends React.Component {
isSystemAdmin = Utils.isSystemAdmin(user.roles);
}
if (!ErrorStore.getIgnoreNotification() && global.window.mm_config.SendEmailNotifications === 'false') {
const errorIgnored = ErrorStore.getIgnoreNotification();
if (!errorIgnored && isSystemAdmin && global.mm_config.SiteURL === '') {
ErrorStore.storeLastError({notification: true, message: SITE_URL_ERROR});
} else if (!errorIgnored && global.window.mm_config.SendEmailNotifications === 'false') {
ErrorStore.storeLastError({notification: true, message: Utils.localizeMessage('error_bar.preview_mode', 'Preview Mode: Email notifications have not been configured')});
} else if (isLicensePastGracePeriod()) {
if (isSystemAdmin) {
@@ -157,6 +163,45 @@ export default class ErrorBar extends React.Component {
defaultMessage='Enterprise license is expired and some features may be disabled. Please contact your System Administrator for details.'
/>
);
} else if (message === SITE_URL_ERROR) {
let id;
let defaultMessage;
if (global.mm_config.EnableSignUpWithGitLab === 'true') {
id = 'error_bar.site_url_gitlab';
defaultMessage = '{docsLink} is now a required setting. Please configure it in the System Console or in gitlab.rb if you\'re using GitLab Mattermost.';
} else {
id = 'error_bar.site_url';
defaultMessage = '{docsLink} is now a required setting. Please configure it in {link}.';
}
message = (
<FormattedMessage
id={id}
defaultMessage={defaultMessage}
values={{
docsLink: (
<a
href='https://docs.mattermost.com/administration/config-settings.html#site-url'
rel='noopener noreferrer'
target='_blank'
>
<FormattedMessage
id='error_bar.site_url.docsLink'
defaultMessage='Site URL'
/>
</a>
),
link: (
<Link to='/admin_console/general/configuration'>
<FormattedMessage
id='error_bar.site_url.link'
defaultMessage='the System Console'
/>
</Link>
)
}}
/>
);
}
return (
+4
View File
@@ -1291,6 +1291,10 @@
"error_bar.expiring": "Enterprise license expires on {date}. <a href='{link}' target='_blank'>Please renew.</a>",
"error_bar.past_grace": "Enterprise license is expired and some features may be disabled. Please contact your System Administrator for details.",
"error_bar.preview_mode": "Preview Mode: Email notifications have not been configured",
"error_bar.site_url": "{docsLink} is now a required setting. Please configure it in {link}.",
"error_bar.site_url.docsLink": "Site URL",
"error_bar.site_url.link": "the System Console",
"error_bar.site_url_gitlab": "{docsLink} is now a required setting. Please configure it in the System Console or in gitlab.rb if you're using GitLab Mattermost.",
"file_attachment.download": "Download",
"file_info_preview.size": "Size ",
"file_info_preview.type": "File type ",
+2 -2
View File
@@ -62,11 +62,11 @@ class ErrorStoreClass extends EventEmitter {
BrowserStore.setGlobalItem('last_error_conn', count);
}
clearLastError() {
clearLastError(force) {
var lastError = this.getLastError();
// preview message can only be cleared by clearNotificationError
if (lastError && lastError.notification) {
if (!force && lastError && lastError.notification) {
return;
}