// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import * as Utils from 'utils/utils.jsx'; import AdminSettings from './admin_settings.jsx'; import BooleanSetting from './boolean_setting.jsx'; import {ConnectionSecurityDropdownSettingEmail} from './connection_security_dropdown_setting.jsx'; import EmailConnectionTest from './email_connection_test.jsx'; import {FormattedHTMLMessage, FormattedMessage} from 'react-intl'; import SettingsGroup from './settings_group.jsx'; import TextSetting from './text_setting.jsx'; export default class EmailSettings extends AdminSettings { constructor(props) { super(props); this.getConfigFromState = this.getConfigFromState.bind(this); this.renderSettings = this.renderSettings.bind(this); } getConfigFromState(config) { config.EmailSettings.SendEmailNotifications = this.state.sendEmailNotifications; config.EmailSettings.FeedbackName = this.state.feedbackName; config.EmailSettings.FeedbackEmail = this.state.feedbackEmail; config.EmailSettings.FeedbackOrganization = this.state.feedbackOrganization; config.EmailSettings.SMTPUsername = this.state.smtpUsername; config.EmailSettings.SMTPPassword = this.state.smtpPassword; config.EmailSettings.SMTPServer = this.state.smtpServer; config.EmailSettings.SMTPPort = this.state.smtpPort; config.EmailSettings.ConnectionSecurity = this.state.connectionSecurity; config.EmailSettings.EnableEmailBatching = this.state.enableEmailBatching; config.ServiceSettings.EnableSecurityFixAlert = this.state.enableSecurityFixAlert; config.EmailSettings.SkipServerCertificateVerification = this.state.skipServerCertificateVerification; 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, enableEmailBatching: config.EmailSettings.EnableEmailBatching, skipServerCertificateVerification: config.EmailSettings.SkipServerCertificateVerification, enableSecurityFixAlert: config.ServiceSettings.EnableSecurityFixAlert }; } renderTitle() { return ( ); } renderSettings() { let enableEmailBatchingDisabledText = null; if (this.props.config.ClusterSettings.Enable) { enableEmailBatchingDisabledText = ( ); } else if (!this.props.config.ServiceSettings.SiteURL) { enableEmailBatchingDisabledText = ( ); } return ( } helpText={ } value={this.state.sendEmailNotifications} onChange={this.handleChange} /> } helpText={[ , enableEmailBatchingDisabledText ]} value={this.state.enableEmailBatching && !this.props.config.ClusterSettings.Enable && this.props.config.ServiceSettings.SiteURL} onChange={this.handleChange} disabled={!this.state.sendEmailNotifications || this.props.config.ClusterSettings.Enable || !this.props.config.ServiceSettings.SiteURL} /> } placeholder={Utils.localizeMessage('admin.email.notificationDisplayExample', 'Ex: "Mattermost Notification", "System", "No-Reply"')} helpText={ } value={this.state.feedbackName} onChange={this.handleChange} disabled={!this.state.sendEmailNotifications} /> } placeholder={Utils.localizeMessage('admin.email.notificationEmailExample', 'Ex: "mattermost@yourcompany.com", "admin@yourcompany.com"')} helpText={ } value={this.state.feedbackEmail} onChange={this.handleChange} disabled={!this.state.sendEmailNotifications} /> } placeholder={Utils.localizeMessage('admin.email.notificationOrganizationExample', 'Ex: "© ABC Corporation, 565 Knight Way, Palo Alto, California, 94305, USA"')} helpText={ } value={this.state.feedbackOrganization} onChange={this.handleChange} disabled={!this.state.sendEmailNotifications} /> } placeholder={Utils.localizeMessage('admin.email.smtpUsernameExample', 'Ex: "admin@yourcompany.com", "AKIADTOVBGERKLCBV"')} helpText={ } value={this.state.smtpUsername} onChange={this.handleChange} disabled={!this.state.sendEmailNotifications} /> } placeholder={Utils.localizeMessage('admin.email.smtpPasswordExample', 'Ex: "yourpassword", "jcuS8PuvcpGhpgHhlcpT1Mx42pnqMxQY"')} helpText={ } value={this.state.smtpPassword} onChange={this.handleChange} disabled={!this.state.sendEmailNotifications} /> } placeholder={Utils.localizeMessage('admin.email.smtpServerExample', 'Ex: "smtp.yourcompany.com", "email-smtp.us-east-1.amazonaws.com"')} helpText={ } value={this.state.smtpServer} onChange={this.handleChange} disabled={!this.state.sendEmailNotifications} /> } placeholder={Utils.localizeMessage('admin.email.smtpPortExample', 'Ex: "25", "465", "587"')} helpText={ } value={this.state.smtpPort} onChange={this.handleChange} disabled={!this.state.sendEmailNotifications} /> } helpText={ } value={this.state.skipServerCertificateVerification} onChange={this.handleChange} /> } helpText={ } value={this.state.enableSecurityFixAlert} onChange={this.handleChange} /> ); } }