PLT-3237 Update displayed config values in admin console after saving (#3506)

* Reloaded admin console data when settings are saved

* Fixed attempting to save an invalid config setting overwriting the stored config
Этот коммит содержится в:
Harrison Healey
2016-07-06 16:07:56 -04:00
коммит произвёл GitHub
родитель b1520d0b94
Коммит b114062c1b
30 изменённых файлов: 327 добавлений и 256 удалений

Просмотреть файл

@@ -24,11 +24,11 @@ export default class AdminSettings extends React.Component {
this.handleSubmit = this.handleSubmit.bind(this);
this.onKeyDown = this.onKeyDown.bind(this);
this.state = {
this.state = Object.assign(this.getStateFromConfig(props.config), {
saveNeeded: false,
saving: false,
serverError: null
};
});
}
handleChange(id, value) {
@@ -60,12 +60,17 @@ export default class AdminSettings extends React.Component {
serverError: null
});
const config = this.getConfigFromState(this.props.config);
// clone config so that we aren't modifying data in the stores
let config = JSON.parse(JSON.stringify(this.props.config));
config = this.getConfigFromState(config);
Client.saveConfig(
config,
() => {
AsyncClient.getConfig();
AsyncClient.getConfig((savedConfig) => {
this.setState(this.getStateFromConfig(savedConfig));
});
this.setState({
saveNeeded: false,
saving: false

Просмотреть файл

@@ -18,12 +18,6 @@ export default class ComplianceSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enable: props.config.ComplianceSettings.Enable,
directory: props.config.ComplianceSettings.Directory,
enableDaily: props.config.ComplianceSettings.EnableDaily
});
}
getConfigFromState(config) {
@@ -34,6 +28,14 @@ export default class ComplianceSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enable: config.ComplianceSettings.Enable,
directory: config.ComplianceSettings.Directory,
enableDaily: config.ComplianceSettings.EnableDaily
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -19,17 +19,12 @@ export default class ConfigurationSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
listenAddress: props.config.ServiceSettings.ListenAddress,
webserverMode: props.config.ServiceSettings.WebserverMode
});
}
componentWillReceiveProps(nextProps) {
if (nextProps.config.ServiceSettings.ListenAddress !== this.props.config.ServiceSettings.ListenAddress) {
this.setState({listenAddress: nextProps.config.ServiceSettings.ListenAddress});
}
// special case for this page since we don't update AdminSettings components when the
// stored config changes, but we want this page to update when you reload the config
this.setState(this.getStateFromConfig(nextProps.config));
}
getConfigFromState(config) {
@@ -39,6 +34,13 @@ export default class ConfigurationSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
listenAddress: config.ServiceSettings.ListenAddress,
webserverMode: config.ServiceSettings.WebserverMode
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -18,11 +18,6 @@ export default class ConnectionSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
allowCorsFrom: props.config.ServiceSettings.AllowCorsFrom,
enableInsecureOutgoingConnections: props.config.ServiceSettings.EnableInsecureOutgoingConnections
});
}
getConfigFromState(config) {
@@ -32,6 +27,13 @@ export default class ConnectionSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
allowCorsFrom: config.ServiceSettings.AllowCorsFrom,
enableInsecureOutgoingConnections: config.ServiceSettings.EnableInsecureOutgoingConnections
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -19,12 +19,6 @@ export default class CustomBrandSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
siteName: props.config.TeamSettings.SiteName,
enableCustomBrand: props.config.TeamSettings.EnableCustomBrand,
customBrandText: props.config.TeamSettings.CustomBrandText
});
}
getConfigFromState(config) {
@@ -37,6 +31,14 @@ export default class CustomBrandSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
siteName: config.TeamSettings.SiteName,
enableCustomBrand: config.TeamSettings.EnableCustomBrand,
customBrandText: config.TeamSettings.CustomBrandText
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -18,11 +18,6 @@ export default class CustomEmojiSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enableCustomEmoji: props.config.ServiceSettings.EnableCustomEmoji,
restrictCustomEmojiCreation: props.config.ServiceSettings.RestrictCustomEmojiCreation
});
}
getConfigFromState(config) {
@@ -35,6 +30,13 @@ export default class CustomEmojiSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enableCustomEmoji: config.ServiceSettings.EnableCustomEmoji,
restrictCustomEmojiCreation: config.ServiceSettings.RestrictCustomEmojiCreation
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -20,15 +20,6 @@ export default class DatabaseSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
driverName: this.props.config.SqlSettings.DriverName,
dataSource: this.props.config.SqlSettings.DataSource,
maxIdleConns: props.config.SqlSettings.MaxIdleConns,
maxOpenConns: props.config.SqlSettings.MaxOpenConns,
atRestEncryptKey: props.config.SqlSettings.AtRestEncryptKey,
trace: props.config.SqlSettings.Trace
});
}
getConfigFromState(config) {
@@ -42,6 +33,17 @@ export default class DatabaseSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
driverName: config.SqlSettings.DriverName,
dataSource: config.SqlSettings.DataSource,
maxIdleConns: config.SqlSettings.MaxIdleConns,
maxOpenConns: config.SqlSettings.MaxOpenConns,
atRestEncryptKey: config.SqlSettings.AtRestEncryptKey,
trace: config.SqlSettings.Trace
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -15,11 +15,6 @@ export default class DeveloperSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enableTesting: props.config.ServiceSettings.EnableTesting,
enableDeveloper: props.config.ServiceSettings.EnableDeveloper
});
}
getConfigFromState(config) {
@@ -29,6 +24,13 @@ export default class DeveloperSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enableTesting: config.ServiceSettings.EnableTesting,
enableDeveloper: config.ServiceSettings.EnableDeveloper
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -15,12 +15,6 @@ export default class EmailAuthenticationSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enableSignUpWithEmail: props.config.EmailSettings.EnableSignUpWithEmail,
enableSignInWithEmail: props.config.EmailSettings.EnableSignInWithEmail,
enableSignInWithUsername: props.config.EmailSettings.EnableSignInWithUsername
});
}
getConfigFromState(config) {
@@ -31,6 +25,14 @@ export default class EmailAuthenticationSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enableSignUpWithEmail: config.EmailSettings.EnableSignUpWithEmail,
enableSignInWithEmail: config.EmailSettings.EnableSignInWithEmail,
enableSignInWithUsername: config.EmailSettings.EnableSignInWithUsername
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -20,19 +20,6 @@ export default class EmailSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
sendEmailNotifications: props.config.EmailSettings.SendEmailNotifications,
feedbackName: props.config.EmailSettings.FeedbackName,
feedbackEmail: props.config.EmailSettings.FeedbackEmail,
feedbackOrganization: props.config.EmailSettings.FeedbackOrganization,
smtpUsername: props.config.EmailSettings.SMTPUsername,
smtpPassword: props.config.EmailSettings.SMTPPassword,
smtpServer: props.config.EmailSettings.SMTPServer,
smtpPort: props.config.EmailSettings.SMTPPort,
connectionSecurity: props.config.EmailSettings.ConnectionSecurity,
enableSecurityFixAlert: props.config.ServiceSettings.EnableSecurityFixAlert
});
}
getConfigFromState(config) {
@@ -50,6 +37,21 @@ export default class EmailSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
sendEmailNotifications: config.EmailSettings.SendEmailNotifications,
feedbackName: config.EmailSettings.FeedbackName,
feedbackEmail: config.EmailSettings.FeedbackEmail,
feedbackOrganization: config.EmailSettings.FeedbackOrganization,
smtpUsername: config.EmailSettings.SMTPUsername,
smtpPassword: config.EmailSettings.SMTPPassword,
smtpServer: config.EmailSettings.SMTPServer,
smtpPort: config.EmailSettings.SMTPPort,
connectionSecurity: config.EmailSettings.ConnectionSecurity,
enableSecurityFixAlert: config.ServiceSettings.EnableSecurityFixAlert
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -17,11 +17,6 @@ export default class ExternalServiceSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
segmentDeveloperKey: props.config.ServiceSettings.SegmentDeveloperKey,
googleDeveloperKey: props.config.ServiceSettings.GoogleDeveloperKey
});
}
getConfigFromState(config) {
@@ -31,6 +26,13 @@ export default class ExternalServiceSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
segmentDeveloperKey: config.ServiceSettings.SegmentDeveloperKey,
googleDeveloperKey: config.ServiceSettings.GoogleDeveloperKey
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -18,15 +18,6 @@ export default class GitLabSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enable: props.config.GitLabSettings.Enable,
id: props.config.GitLabSettings.Id,
secret: props.config.GitLabSettings.Secret,
userApiEndpoint: props.config.GitLabSettings.UserApiEndpoint,
authEndpoint: props.config.GitLabSettings.AuthEndpoint,
tokenEndpoint: props.config.GitLabSettings.TokenEndpoint
});
}
getConfigFromState(config) {
@@ -40,6 +31,17 @@ export default class GitLabSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enable: config.GitLabSettings.Enable,
id: config.GitLabSettings.Id,
secret: config.GitLabSettings.Secret,
userApiEndpoint: config.GitLabSettings.UserApiEndpoint,
authEndpoint: config.GitLabSettings.AuthEndpoint,
tokenEndpoint: config.GitLabSettings.TokenEndpoint
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -17,15 +17,6 @@ export default class ImageSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
thumbnailWidth: props.config.FileSettings.ThumbnailWidth,
thumbnailHeight: props.config.FileSettings.ThumbnailHeight,
profileWidth: props.config.FileSettings.ProfileWidth,
profileHeight: props.config.FileSettings.ProfileHeight,
previewWidth: props.config.FileSettings.PreviewWidth,
previewHeight: props.config.FileSettings.PreviewHeight
});
}
getConfigFromState(config) {
@@ -39,6 +30,17 @@ export default class ImageSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
thumbnailWidth: config.FileSettings.ThumbnailWidth,
thumbnailHeight: config.FileSettings.ThumbnailHeight,
profileWidth: config.FileSettings.ProfileWidth,
profileHeight: config.FileSettings.ProfileHeight,
previewWidth: config.FileSettings.PreviewWidth,
previewHeight: config.FileSettings.PreviewHeight
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -19,28 +19,6 @@ export default class LdapSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enable: props.config.LdapSettings.Enable,
ldapServer: props.config.LdapSettings.LdapServer,
ldapPort: props.config.LdapSettings.LdapPort,
connectionSecurity: props.config.LdapSettings.ConnectionSecurity,
baseDN: props.config.LdapSettings.BaseDN,
bindUsername: props.config.LdapSettings.BindUsername,
bindPassword: props.config.LdapSettings.BindPassword,
userFilter: props.config.LdapSettings.UserFilter,
firstNameAttribute: props.config.LdapSettings.FirstNameAttribute,
lastNameAttribute: props.config.LdapSettings.LastNameAttribute,
nicknameAttribute: props.config.LdapSettings.NicknameAttribute,
emailAttribute: props.config.LdapSettings.EmailAttribute,
usernameAttribute: props.config.LdapSettings.UsernameAttribute,
idAttribute: props.config.LdapSettings.IdAttribute,
syncIntervalMinutes: props.config.LdapSettings.SyncIntervalMinutes,
skipCertificateVerification: props.config.LdapSettings.SkipCertificateVerification,
queryTimeout: props.config.LdapSettings.QueryTimeout,
maxPageSize: props.config.LdapSettings.MaxPageSize,
loginFieldName: props.config.LdapSettings.LoginFieldName
});
}
getConfigFromState(config) {
@@ -67,6 +45,30 @@ export default class LdapSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enable: config.LdapSettings.Enable,
ldapServer: config.LdapSettings.LdapServer,
ldapPort: config.LdapSettings.LdapPort,
connectionSecurity: config.LdapSettings.ConnectionSecurity,
baseDN: config.LdapSettings.BaseDN,
bindUsername: config.LdapSettings.BindUsername,
bindPassword: config.LdapSettings.BindPassword,
userFilter: config.LdapSettings.UserFilter,
firstNameAttribute: config.LdapSettings.FirstNameAttribute,
lastNameAttribute: config.LdapSettings.LastNameAttribute,
nicknameAttribute: config.LdapSettings.NicknameAttribute,
emailAttribute: config.LdapSettings.EmailAttribute,
usernameAttribute: config.LdapSettings.UsernameAttribute,
idAttribute: config.LdapSettings.IdAttribute,
syncIntervalMinutes: config.LdapSettings.SyncIntervalMinutes,
skipCertificateVerification: config.LdapSettings.SkipCertificateVerification,
queryTimeout: config.LdapSettings.QueryTimeout,
maxPageSize: config.LdapSettings.MaxPageSize,
loginFieldName: config.LdapSettings.LoginFieldName
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -15,15 +15,6 @@ export default class LegalAndSupportSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
termsOfServiceLink: props.config.SupportSettings.TermsOfServiceLink,
privacyPolicyLink: props.config.SupportSettings.PrivacyPolicyLink,
aboutLink: props.config.SupportSettings.AboutLink,
helpLink: props.config.SupportSettings.HelpLink,
reportAProblemLink: props.config.SupportSettings.ReportAProblemLink,
supportEmail: props.config.SupportSettings.SupportEmail
});
}
getConfigFromState(config) {
@@ -37,6 +28,17 @@ export default class LegalAndSupportSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
termsOfServiceLink: config.SupportSettings.TermsOfServiceLink,
privacyPolicyLink: config.SupportSettings.PrivacyPolicyLink,
aboutLink: config.SupportSettings.AboutLink,
helpLink: config.SupportSettings.HelpLink,
reportAProblemLink: config.SupportSettings.ReportAProblemLink,
supportEmail: config.SupportSettings.SupportEmail
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -24,9 +24,6 @@ export default class LocalizationSettings extends AdminSettings {
this.state = Object.assign(this.state, {
hasErrors: false,
defaultServerLocale: props.config.LocalizationSettings.DefaultServerLocale,
defaultClientLocale: props.config.LocalizationSettings.DefaultClientLocale,
availableLocales: props.config.LocalizationSettings.AvailableLocales ? props.config.LocalizationSettings.AvailableLocales.split(',') : [],
languages: Object.keys(locales).map((l) => {
return {value: locales[l].value, text: locales[l].name};
})
@@ -45,6 +42,14 @@ export default class LocalizationSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
defaultServerLocale: config.LocalizationSettings.DefaultServerLocale,
defaultClientLocale: config.LocalizationSettings.DefaultClientLocale,
availableLocales: config.LocalizationSettings.AvailableLocales ? config.LocalizationSettings.AvailableLocales.split(',') : []
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -19,16 +19,6 @@ export default class LogSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enableConsole: props.config.LogSettings.EnableConsole,
consoleLevel: props.config.LogSettings.ConsoleLevel,
enableFile: props.config.LogSettings.EnableFile,
fileLevel: props.config.LogSettings.FileLevel,
fileLocation: props.config.LogSettings.FileLocation,
fileFormat: props.config.LogSettings.FileFormat,
enableWebhookDebugging: props.config.LogSettings.EnableWebhookDebugging
});
}
getConfigFromState(config) {
@@ -43,6 +33,18 @@ export default class LogSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enableConsole: config.LogSettings.EnableConsole,
consoleLevel: config.LogSettings.ConsoleLevel,
enableFile: config.LogSettings.EnableFile,
fileLevel: config.LogSettings.FileLevel,
fileLocation: config.LogSettings.FileLocation,
fileFormat: config.LogSettings.FileFormat,
enableWebhookDebugging: config.LogSettings.EnableWebhookDebugging
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -19,12 +19,6 @@ export default class LoginSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
passwordResetSalt: props.config.EmailSettings.PasswordResetSalt,
maximumLoginAttempts: props.config.ServiceSettings.MaximumLoginAttempts,
enableMultifactorAuthentication: props.config.ServiceSettings.EnableMultifactorAuthentication
});
}
getConfigFromState(config) {
@@ -37,6 +31,14 @@ export default class LoginSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
passwordResetSalt: config.EmailSettings.PasswordResetSalt,
maximumLoginAttempts: config.ServiceSettings.MaximumLoginAttempts,
enableMultifactorAuthentication: config.ServiceSettings.EnableMultifactorAuthentication
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -19,12 +19,6 @@ export default class PolicySettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
restrictTeamInvite: props.config.TeamSettings.RestrictTeamInvite,
restrictPublicChannelManagement: props.config.TeamSettings.RestrictPublicChannelManagement,
restrictPrivateChannelManagement: props.config.TeamSettings.RestrictPrivateChannelManagement
});
}
getConfigFromState(config) {
@@ -35,6 +29,14 @@ export default class PolicySettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
restrictTeamInvite: config.TeamSettings.RestrictTeamInvite,
restrictPublicChannelManagement: config.TeamSettings.RestrictPublicChannelManagement,
restrictPrivateChannelManagement: config.TeamSettings.RestrictPrivateChannelManagement
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -15,11 +15,6 @@ export default class PrivacySettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
showEmailAddress: props.config.PrivacySettings.ShowEmailAddress,
showFullName: props.config.PrivacySettings.ShowFullName
});
}
getConfigFromState(config) {
@@ -29,6 +24,13 @@ export default class PrivacySettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
showEmailAddress: config.PrivacySettings.ShowEmailAddress,
showFullName: config.PrivacySettings.ShowFullName
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -16,11 +16,6 @@ export default class PublicLinkSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enablePublicLink: props.config.FileSettings.EnablePublicLink,
publicLinkSalt: props.config.FileSettings.PublicLinkSalt
});
}
getConfigFromState(config) {
@@ -30,6 +25,13 @@ export default class PublicLinkSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enablePublicLink: config.FileSettings.EnablePublicLink,
publicLinkSalt: config.FileSettings.PublicLinkSalt
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -28,34 +28,6 @@ export default class PushSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
let pushNotificationServerType = PUSH_NOTIFICATIONS_CUSTOM;
let agree = false;
if (!props.config.EmailSettings.SendPushNotifications) {
pushNotificationServerType = PUSH_NOTIFICATIONS_OFF;
} else if (props.config.EmailSettings.PushNotificationServer === Constants.MHPNS &&
global.window.mm_license.IsLicensed === 'true' && global.window.mm_license.MHPNS === 'true') {
pushNotificationServerType = PUSH_NOTIFICATIONS_MHPNS;
agree = true;
} else if (props.config.EmailSettings.PushNotificationServer === Constants.MTPNS) {
pushNotificationServerType = PUSH_NOTIFICATIONS_MTPNS;
} else {
pushNotificationServerType = PUSH_NOTIFICATIONS_CUSTOM;
}
let pushNotificationServer = this.props.config.EmailSettings.PushNotificationServer;
if (pushNotificationServerType === PUSH_NOTIFICATIONS_MTPNS) {
pushNotificationServer = Constants.MTPNS;
} else if (pushNotificationServerType === PUSH_NOTIFICATIONS_MHPNS) {
pushNotificationServer = Constants.MHPNS;
}
this.state = Object.assign(this.state, {
pushNotificationServerType,
pushNotificationServer,
pushNotificationContents: props.config.EmailSettings.PushNotificationContents,
agree
});
}
canSave() {
@@ -96,6 +68,36 @@ export default class PushSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
let pushNotificationServerType = PUSH_NOTIFICATIONS_CUSTOM;
let agree = false;
if (!config.EmailSettings.SendPushNotifications) {
pushNotificationServerType = PUSH_NOTIFICATIONS_OFF;
} else if (config.EmailSettings.PushNotificationServer === Constants.MHPNS &&
global.window.mm_license.IsLicensed === 'true' && global.window.mm_license.MHPNS === 'true') {
pushNotificationServerType = PUSH_NOTIFICATIONS_MHPNS;
agree = true;
} else if (config.EmailSettings.PushNotificationServer === Constants.MTPNS) {
pushNotificationServerType = PUSH_NOTIFICATIONS_MTPNS;
} else {
pushNotificationServerType = PUSH_NOTIFICATIONS_CUSTOM;
}
let pushNotificationServer = config.EmailSettings.PushNotificationServer;
if (pushNotificationServerType === PUSH_NOTIFICATIONS_MTPNS) {
pushNotificationServer = Constants.MTPNS;
} else if (pushNotificationServerType === PUSH_NOTIFICATIONS_MHPNS) {
pushNotificationServer = Constants.MHPNS;
}
return {
pushNotificationServerType,
pushNotificationServer,
pushNotificationContents: config.EmailSettings.PushNotificationContents,
agree
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -18,14 +18,6 @@ export default class RateSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enableRateLimiter: props.config.RateLimitSettings.EnableRateLimiter,
perSec: props.config.RateLimitSettings.PerSec,
memoryStoreSize: props.config.RateLimitSettings.MemoryStoreSize,
varyByRemoteAddr: props.config.RateLimitSettings.VaryByRemoteAddr,
varyByHeader: props.config.RateLimitSettings.VaryByHeader
});
}
getConfigFromState(config) {
@@ -38,6 +30,16 @@ export default class RateSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enableRateLimiter: config.RateLimitSettings.EnableRateLimiter,
perSec: config.RateLimitSettings.PerSec,
memoryStoreSize: config.RateLimitSettings.MemoryStoreSize,
varyByRemoteAddr: config.RateLimitSettings.VaryByRemoteAddr,
varyByHeader: config.RateLimitSettings.VaryByHeader
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -24,27 +24,6 @@ export default class SamlSettings extends AdminSettings {
this.renderSettings = this.renderSettings.bind(this);
this.uploadCertificate = this.uploadCertificate.bind(this);
this.removeCertificate = this.removeCertificate.bind(this);
const settings = props.config.SamlSettings;
this.state = Object.assign(this.state, {
enable: settings.Enable,
verify: settings.Verify,
encrypt: settings.Encrypt,
idpUrl: settings.IdpUrl,
idpDescriptorUrl: settings.IdpDescriptorUrl,
assertionConsumerServiceURL: settings.AssertionConsumerServiceURL,
idpCertificateFile: settings.IdpCertificateFile,
publicCertificateFile: settings.PublicCertificateFile,
privateKeyFile: settings.PrivateKeyFile,
firstNameAttribute: settings.FirstNameAttribute,
lastNameAttribute: settings.LastNameAttribute,
emailAttribute: settings.EmailAttribute,
usernameAttribute: settings.UsernameAttribute,
nicknameAttribute: settings.NicknameAttribute,
localeAttribute: settings.LocaleAttribute,
loginButtonText: settings.LoginButtonText
});
}
getConfigFromState(config) {
@@ -68,6 +47,29 @@ export default class SamlSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
const settings = config.SamlSettings;
return {
enable: settings.Enable,
verify: settings.Verify,
encrypt: settings.Encrypt,
idpUrl: settings.IdpUrl,
idpDescriptorUrl: settings.IdpDescriptorUrl,
assertionConsumerServiceURL: settings.AssertionConsumerServiceURL,
idpCertificateFile: settings.IdpCertificateFile,
publicCertificateFile: settings.PublicCertificateFile,
privateKeyFile: settings.PrivateKeyFile,
firstNameAttribute: settings.FirstNameAttribute,
lastNameAttribute: settings.LastNameAttribute,
emailAttribute: settings.EmailAttribute,
usernameAttribute: settings.UsernameAttribute,
nicknameAttribute: settings.NicknameAttribute,
localeAttribute: settings.LocaleAttribute,
loginButtonText: settings.LoginButtonText
};
}
uploadCertificate(id, file, callback) {
Client.uploadCertificateFile(
file,

Просмотреть файл

@@ -17,13 +17,6 @@ export default class SessionSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
sessionLengthWebInDays: props.config.ServiceSettings.SessionLengthWebInDays,
sessionLengthMobileInDays: props.config.ServiceSettings.SessionLengthMobileInDays,
sessionLengthSSOInDays: props.config.ServiceSettings.SessionLengthSSOInDays,
sessionCacheInMinutes: props.config.ServiceSettings.SessionCacheInMinutes
});
}
getConfigFromState(config) {
@@ -35,6 +28,15 @@ export default class SessionSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
sessionLengthWebInDays: config.ServiceSettings.SessionLengthWebInDays,
sessionLengthMobileInDays: config.ServiceSettings.SessionLengthMobileInDays,
sessionLengthSSOInDays: config.ServiceSettings.SessionLengthSSOInDays,
sessionCacheInMinutes: config.ServiceSettings.SessionCacheInMinutes
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -16,12 +16,6 @@ export default class SignupSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
requireEmailVerification: props.config.EmailSettings.RequireEmailVerification,
inviteSalt: props.config.EmailSettings.InviteSalt,
enableOpenServer: props.config.TeamSettings.EnableOpenServer
});
}
getConfigFromState(config) {
@@ -32,6 +26,14 @@ export default class SignupSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
requireEmailVerification: config.EmailSettings.RequireEmailVerification,
inviteSalt: config.EmailSettings.InviteSalt,
enableOpenServer: config.TeamSettings.EnableOpenServer
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -21,16 +21,6 @@ export default class StorageSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
maxFileSize: props.config.FileSettings.MaxFileSize / 1024 / 1024,
driverName: props.config.FileSettings.DriverName,
directory: props.config.FileSettings.Directory,
amazonS3AccessKeyId: props.config.FileSettings.AmazonS3AccessKeyId,
amazonS3SecretAccessKey: props.config.FileSettings.AmazonS3SecretAccessKey,
amazonS3Bucket: props.config.FileSettings.AmazonS3Bucket,
amazonS3Region: props.config.FileSettings.AmazonS3Region
});
}
getConfigFromState(config) {
@@ -45,6 +35,18 @@ export default class StorageSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
maxFileSize: config.FileSettings.MaxFileSize / 1024 / 1024,
driverName: config.FileSettings.DriverName,
directory: config.FileSettings.Directory,
amazonS3AccessKeyId: config.FileSettings.AmazonS3AccessKeyId,
amazonS3SecretAccessKey: config.FileSettings.AmazonS3SecretAccessKey,
amazonS3Bucket: config.FileSettings.AmazonS3Bucket,
amazonS3Region: config.FileSettings.AmazonS3Region
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -22,15 +22,6 @@ export default class UsersAndTeamsSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enableUserCreation: props.config.TeamSettings.EnableUserCreation,
enableTeamCreation: props.config.TeamSettings.EnableTeamCreation,
maxUsersPerTeam: props.config.TeamSettings.MaxUsersPerTeam,
restrictCreationToDomains: props.config.TeamSettings.RestrictCreationToDomains,
restrictTeamNames: props.config.TeamSettings.RestrictTeamNames,
restrictDirectMessage: props.config.TeamSettings.RestrictDirectMessage
});
}
getConfigFromState(config) {
@@ -44,6 +35,17 @@ export default class UsersAndTeamsSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enableUserCreation: config.TeamSettings.EnableUserCreation,
enableTeamCreation: config.TeamSettings.EnableTeamCreation,
maxUsersPerTeam: config.TeamSettings.MaxUsersPerTeam,
restrictCreationToDomains: config.TeamSettings.RestrictCreationToDomains,
restrictTeamNames: config.TeamSettings.RestrictTeamNames,
restrictDirectMessage: config.TeamSettings.RestrictDirectMessage
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -15,15 +15,6 @@ export default class WebhookSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.state = Object.assign(this.state, {
enableIncomingWebhooks: props.config.ServiceSettings.EnableIncomingWebhooks,
enableOutgoingWebhooks: props.config.ServiceSettings.EnableOutgoingWebhooks,
enableCommands: props.config.ServiceSettings.EnableCommands,
enableOnlyAdminIntegrations: props.config.ServiceSettings.EnableOnlyAdminIntegrations,
enablePostUsernameOverride: props.config.ServiceSettings.EnablePostUsernameOverride,
enablePostIconOverride: props.config.ServiceSettings.EnablePostIconOverride
});
}
getConfigFromState(config) {
@@ -37,6 +28,17 @@ export default class WebhookSettings extends AdminSettings {
return config;
}
getStateFromConfig(config) {
return {
enableIncomingWebhooks: config.ServiceSettings.EnableIncomingWebhooks,
enableOutgoingWebhooks: config.ServiceSettings.EnableOutgoingWebhooks,
enableCommands: config.ServiceSettings.EnableCommands,
enableOnlyAdminIntegrations: config.ServiceSettings.EnableOnlyAdminIntegrations,
enablePostUsernameOverride: config.ServiceSettings.EnablePostUsernameOverride,
enablePostIconOverride: config.ServiceSettings.EnablePostIconOverride
};
}
renderTitle() {
return (
<h3>

Просмотреть файл

@@ -405,7 +405,7 @@ export function getComplianceReports() {
);
}
export function getConfig() {
export function getConfig(success, error) {
if (isCallInProgress('getConfig')) {
return;
}
@@ -419,10 +419,17 @@ export function getConfig() {
type: ActionTypes.RECEIVED_CONFIG,
config: data
});
if (success) {
success(data);
}
},
(err) => {
callTracker.getConfig = 0;
dispatchError(err, 'getConfig');
if (!error) {
dispatchError(err, 'getConfig');
}
}
);
}