Commit ba9a0751 authored by Jonathan's avatar Jonathan Committed by George Goldberg
Browse files

MM-8840: Add GlobalRelay Configuration Settings (#817)

* Added system console integration for new GlobalRelay config values

* Merge error fix.

* Restablishing global relay export in the settings and fixing tests

* MM-8840: Removes newlines from translaiton file.

* Update en.json

* MM-8840: Update to make export format description static.

* MM-8840: Global Relay settings translations changes.

* MM-8840: Updates snapshot.

* Removing Global Relay unnecesary header text

* Remove settings title from en.json

* Fixing tests snapshots

* Leave unmodified other translation files
parent fd9e6d03
......@@ -10,6 +10,12 @@ import DropdownSetting from './dropdown_setting.jsx';
import JobsTable from './jobs';
import SettingsGroup from './settings_group.jsx';
import TextSetting from './text_setting.jsx';
import RadioSetting from './radio_setting';
const exportFormats = {
EXPORT_FORMAT_ACTIANCE: 'actiance',
EXPORT_FORMAT_GLOBALRELAY: 'globalrelay',
};
export default class MessageExportSettings extends AdminSettings {
constructor(props) {
......@@ -23,17 +29,32 @@ export default class MessageExportSettings extends AdminSettings {
config.MessageExportSettings.EnableExport = this.state.enableComplianceExport;
config.MessageExportSettings.ExportFormat = this.state.exportFormat;
config.MessageExportSettings.DailyRunTime = this.state.exportJobStartTime;
config.MessageExportSettings.GlobalRelayEmailAddress = this.state.globalRelayEmailAddress;
if (this.state.exportFormat === exportFormats.EXPORT_FORMAT_GLOBALRELAY) {
config.MessageExportSettings.GlobalRelaySettings = {
CustomerType: this.state.globalRelayCustomerType,
SmtpUsername: this.state.globalRelaySmtpUsername,
SmtpPassword: this.state.globalRelaySmtpPassword,
EmailAddress: this.state.globalRelayEmailAddress,
};
}
return config;
}
getStateFromConfig(config) {
return {
const state = {
enableComplianceExport: config.MessageExportSettings.EnableExport,
exportFormat: config.MessageExportSettings.ExportFormat,
exportJobStartTime: config.MessageExportSettings.DailyRunTime,
globalRelayEmailAddress: config.MessageExportSettings.GlobalRelayEmailAddress,
};
if (config.MessageExportSettings.GlobalRelaySettings) {
state.globalRelayCustomerType = config.MessageExportSettings.GlobalRelaySettings.CustomerType;
state.globalRelaySmtpUsername = config.MessageExportSettings.GlobalRelaySettings.SmtpUsername;
state.globalRelaySmtpPassword = config.MessageExportSettings.GlobalRelaySettings.SmtpPassword;
state.globalRelayEmailAddress = config.MessageExportSettings.GlobalRelaySettings.EmailAddress;
}
return state;
}
renderTitle() {
......@@ -47,21 +68,89 @@ export default class MessageExportSettings extends AdminSettings {
renderSettings() {
const exportFormatOptions = [
{value: 'actiance', text: Utils.localizeMessage('admin.complianceExport.exportFormat.actiance', 'Actiance XML')},
// {value: 'globalrelay', text: Utils.localizeMessage('admin.complianceExport.exportFormat.globalrelay', 'GlobalRelay EML')},
{value: exportFormats.EXPORT_FORMAT_ACTIANCE, text: Utils.localizeMessage('admin.complianceExport.exportFormat.actiance', 'Actiance XML')},
{value: exportFormats.EXPORT_FORMAT_GLOBALRELAY, text: Utils.localizeMessage('admin.complianceExport.exportFormat.globalrelay', 'GlobalRelay EML')},
];
// if export format is globalrelay, user must set email address
var dropdownHelpText;
var globalRelayEmail;
if (this.state.exportFormat === 'globalrelay') {
globalRelayEmail = (
// if the export format is globalrelay, the user needs to set some additional parameters
let globalRelaySettings;
if (this.state.exportFormat === exportFormats.EXPORT_FORMAT_GLOBALRELAY) {
const globalRelayCustomerType = (
<RadioSetting
id='globalRelayCustomerType'
values={[
{value: 'A9', text: Utils.localizeMessage('admin.complianceExport.globalRelayCustomerType.a9.description', 'A9/Type 9')},
{value: 'A10', text: Utils.localizeMessage('admin.complianceExport.globalRelayCustomerType.a10.description', 'A10/Type 10')},
]}
label={
<FormattedMessage
id='admin.complianceExport.globalRelayCustomerType.title'
defaultMessage='Customer Type:'
/>
}
helpText={
<FormattedMessage
id='admin.complianceExport.globalRelayCustomerType.description'
defaultMessage='The type of GlobalRelay customer account that your organization has.'
/>
}
value={this.state.globalRelayCustomerType ? this.state.globalRelayCustomerType : ''}
disabled={!this.state.enableComplianceExport}
onChange={this.handleChange}
/>
);
const globalRelaySmtpUsername = (
<TextSetting
id='globalRelaySmtpUsername'
label={
<FormattedMessage
id='admin.complianceExport.globalRelaySmtpUsername.title'
defaultMessage='SMTP Username:'
/>
}
placeholder={Utils.localizeMessage('admin.complianceExport.globalRelaySmtpUsername.example', 'E.g.: "globalRelayUser"')}
helpText={
<FormattedMessage
id='admin.complianceExport.globalRelaySmtpUsername.description'
defaultMessage='The username that is used to authenticate against the GlobalRelay SMTP server.'
/>
}
value={this.state.globalRelaySmtpUsername ? this.state.globalRelaySmtpUsername : ''}
disabled={!this.state.enableComplianceExport}
onChange={this.handleChange}
/>
);
const globalRelaySmtpPassword = (
<TextSetting
id='globalRelaySmtpPassword'
label={
<FormattedMessage
id='admin.complianceExport.globalRelaySmtpPassword.title'
defaultMessage='SMTP Password:'
/>
}
placeholder={Utils.localizeMessage('admin.complianceExport.globalRelaySmtpPassword.example', 'E.g.: "globalRelayPassword"')}
helpText={
<FormattedMessage
id='admin.complianceExport.globalRelaySmtpPassword.description'
defaultMessage='The password that is used to authenticate against the GlobalRelay SMTP server.'
/>
}
value={this.state.globalRelaySmtpPassword ? this.state.globalRelaySmtpPassword : ''}
disabled={!this.state.enableComplianceExport}
onChange={this.handleChange}
/>
);
const globalRelayEmail = (
<TextSetting
id='globalRelayEmailAddress'
label={
<FormattedMessage
id='admin.complianceExport.globalRelayEmailAddress.title'
defaultMessage='GlobalRelay Email Address:'
defaultMessage='Email Address:'
/>
}
placeholder={Utils.localizeMessage('admin.complianceExport.globalRelayEmailAddress.example', 'E.g.: "globalrelay@mattermost.com"')}
......@@ -71,30 +160,31 @@ export default class MessageExportSettings extends AdminSettings {
defaultMessage='The email address that your GlobalRelay server monitors for incoming Compliance Exports.'
/>
}
value={this.state.globalRelayEmailAddress === null ? '' : this.state.globalRelayEmailAddress}
value={this.state.globalRelayEmailAddress ? this.state.globalRelayEmailAddress : ''}
disabled={!this.state.enableComplianceExport}
onChange={this.handleChange}
/>
);
dropdownHelpText = (
<FormattedMessage
id='admin.complianceExport.exportFormat.globalrelay.description'
defaultMessage='Format of the compliance export. Corresponds to the system that you want to import the data into. Compliance Exports will be emailed to the configured email address.'
/>
);
} else {
dropdownHelpText = (
<FormattedHTMLMessage
id='admin.complianceExport.exportFormat.actiance.description'
defaultMessage='Format of the compliance export. Corresponds to the system that you want to import the data into. Compliance Export files will be written to the "exports" subdirectory of the configured <a href="/admin_console/files/storage">Local Storage Directory</a>.'
/>
globalRelaySettings = (
<SettingsGroup id={'globalRelaySettings'} >
{globalRelayCustomerType}
{globalRelaySmtpUsername}
{globalRelaySmtpPassword}
{globalRelayEmail}
</SettingsGroup>
);
}
const dropdownHelpText = (
<FormattedHTMLMessage
id='admin.complianceExport.exportFormat.description'
defaultMessage='Format of the compliance export. Corresponds to the system that you want to import the data into.<br><br>For Actiance XML, compliance export files are written to the "exports" subdirectory of the configured <a href="/admin_console/files/storage">Local Storage Directory</a>. For Global Relay EML, they are emailed to the configured email address.'
/>
);
return (
<SettingsGroup>
{/*
<div className='banner'>
<div className='banner__content'>
<FormattedHTMLMessage
......@@ -103,16 +193,6 @@ export default class MessageExportSettings extends AdminSettings {
/>
</div>
</div>
*/}
<div className='banner'>
<div className='banner__content'>
<FormattedHTMLMessage
id='admin.complianceExport.description_without_globalrelay'
defaultMessage='This feature supports compliance exports to the Actiance XML format, and is currently in beta. Support for GlobalRelay EML and the Mattermost CSV format is scheduled for a future release, and will replace the existing <a href=\"/admin_console/general/compliance\">Compliance</a> feature.'
/>
</div>
</div>
<BooleanSetting
id='enableComplianceExport'
......@@ -167,7 +247,7 @@ export default class MessageExportSettings extends AdminSettings {
onChange={this.handleChange}
/>
{globalRelayEmail}
{globalRelaySettings}
<JobsTable
jobType={JobTypes.MESSAGE_EXPORT}
......
......@@ -223,19 +223,27 @@
"admin.compliance.true": "true",
"admin.complianceExport.createJob.help": "Initiates a Compliance Export job immediately.",
"admin.complianceExport.createJob.title": "Run Compliance Export Job Now",
"admin.complianceExport.description": "This feature supports compliance exports to the Actiance XML and GlobalRelay EML formats, and is currently in beta. Support for the Mattermost CSV format is scheduled for a future release, and will replace the existing <a href=\"/admin_console/general/compliance\">Compliance</a> feature.",
"admin.complianceExport.description_without_globalrelay": "This feature supports compliance exports to the Actiance XML format, and is currently in beta. Support for GlobalRelay EML and the Mattermost CSV formats is scheduled for a future release, and will replace the existing <a href=\"/admin_console/general/compliance\">Compliance</a> feature.",
"admin.complianceExport.description": "This feature supports compliance exports to the Actiance XML and Global Relay EML formats, and is currently in beta. Support for the Mattermost CSV format is scheduled for a future release, and will replace the existing <a href=\"/admin_console/general/compliance\">Compliance</a> feature.",
"admin.complianceExport.exportFormat.actiance": "Actiance XML",
"admin.complianceExport.exportFormat.actiance.description": "Format of the compliance export. Corresponds to the system that you want to import the data into. Compliance Export files will be written to the \"exports\" subdirectory of the configured <a href=\"/admin_console/files/storage\">Local Storage Directory</a>.",
"admin.complianceExport.exportFormat.globalrelay": "GlobalRelay EML",
"admin.complianceExport.exportFormat.globalrelay.description": "Format of the compliance export. Corresponds to the system that you want to import the data into. Compliance Exports will be emailed to the configured email address.",
"admin.complianceExport.exportFormat.description": "Format of the compliance export. Corresponds to the system that you want to import the data into.<br><br>For Actiance XML, compliance export files are written to the \"exports\" subdirectory of the configured <a href=\"/admin_console/files/storage\">Local Storage Directory</a>. For Global Relay EML, they are emailed to the configured email address.",
"admin.complianceExport.exportFormat.globalrelay": "Global Relay EML",
"admin.complianceExport.exportFormat.title": "Export Format:",
"admin.complianceExport.exportJobStartTime.description": "Set the start time of the daily scheduled compliance export job. Choose a time when fewer people are using your system. Must be a 24-hour time stamp in the form HH:MM.",
"admin.complianceExport.exportJobStartTime.example": "E.g.: \"02:00\"",
"admin.complianceExport.exportJobStartTime.title": "Compliance Export time:",
"admin.complianceExport.globalRelayEmailAddress.description": "The email address that your GlobalRelay server monitors for incoming Compliance Exports.",
"admin.complianceExport.globalRelayCustomerType.title": "Global Relay Customer Account:",
"admin.complianceExport.globalRelayCustomerType.description": "Type of Global Relay customer account your organization has.",
"admin.complianceExport.globalRelayCustomerType.a9.description": "A9/Type 9",
"admin.complianceExport.globalRelayCustomerType.a10.description": "A10/Type 10",
"admin.complianceExport.globalRelayEmailAddress.title": "Global Relay Email Address:",
"admin.complianceExport.globalRelayEmailAddress.description": "The email address your Global Relay server monitors for incoming compliance exports.",
"admin.complianceExport.globalRelayEmailAddress.example": "E.g.: \"globalrelay@mattermost.com\"",
"admin.complianceExport.globalRelayEmailAddress.title": "GlobalRelay Email Address:",
"admin.complianceExport.globalRelaySmtpUsername.title": "Global Relay SMTP Username:",
"admin.complianceExport.globalRelaySmtpUsername.description": "The username for authenticating to the Global Relay SMTP server.",
"admin.complianceExport.globalRelaySmtpUsername.example": "E.g.: \"globalRelayUser\"",
"admin.complianceExport.globalRelaySmtpPassword.title": "Global Relay SMTP Password:",
"admin.complianceExport.globalRelaySmtpPassword.description": "The password associated with the SMTP username.",
"admin.complianceExport.globalRelaySmtpPassword.example": "E.g.: \"globalRelayPassword\"",
"admin.complianceExport.title": "Compliance Export (Beta)",
"admin.compliance_reports.desc": "Job Name:",
"admin.compliance_reports.desc_placeholder": "E.g. \"Audit 445 for HR\"",
......
......@@ -7,7 +7,7 @@ import {shallow} from 'enzyme';
import MessageExportSettings from 'components/admin_console/message_export_settings.jsx';
describe('components/MessageExportSettings', () => {
test('should match snapshot, disabled', () => {
test('should match snapshot, disabled, actiance', () => {
const config = {
MessageExportSettings: {
EnableExport: false,
......@@ -24,6 +24,18 @@ describe('components/MessageExportSettings', () => {
/>
);
expect(wrapper).toMatchSnapshot();
// actiance config fields are disabled
expect(wrapper.find('#exportJobStartTime').prop('disabled')).toBe(true);
expect(wrapper.find('#exportFormat').prop('disabled')).toBe(true);
// globalrelay config fiels are not rendered
expect(wrapper.find('#globalRelaySettings').exists()).toBe(false);
// controls should reflect config
expect(wrapper.find('#enableComplianceExport').prop('value')).toBe(false);
expect(wrapper.find('#exportJobStartTime').prop('value')).toBe('01:00');
expect(wrapper.find('#exportFormat').prop('value')).toBe('actiance');
});
test('should match snapshot, enabled, actiance', () => {
......@@ -43,6 +55,62 @@ describe('components/MessageExportSettings', () => {
/>
);
expect(wrapper).toMatchSnapshot();
// actiance config fields are enabled
expect(wrapper.find('#exportJobStartTime').prop('disabled')).toBe(false);
expect(wrapper.find('#exportFormat').prop('disabled')).toBe(false);
// globalrelay config fiels are not rendered
expect(wrapper.find('#globalRelaySettings').exists()).toBe(false);
// controls should reflect config
expect(wrapper.find('#enableComplianceExport').prop('value')).toBe(true);
expect(wrapper.find('#exportJobStartTime').prop('value')).toBe('01:00');
expect(wrapper.find('#exportFormat').prop('value')).toBe('actiance');
});
test('should match snapshot, disabled, globalrelay', () => {
const config = {
MessageExportSettings: {
EnableExport: false,
ExportFormat: 'globalrelay',
DailyRunTime: '01:00',
ExportFromTimestamp: 12345678,
BatchSize: 10000,
GlobalRelaySettings: {
CustomerType: 'A10',
SmtpUsername: 'globalRelayUser',
SmtpPassword: 'globalRelayPassword',
EmailAddress: 'globalRelay@mattermost.com',
},
},
};
const wrapper = shallow(
<MessageExportSettings
config={config}
/>
);
expect(wrapper).toMatchSnapshot();
// actiance config fields are disabled
expect(wrapper.find('#exportJobStartTime').prop('disabled')).toBe(true);
expect(wrapper.find('#exportFormat').prop('disabled')).toBe(true);
// globalrelay config fiels are disabled
expect(wrapper.find('#globalRelayCustomerType').prop('disabled')).toBe(true);
expect(wrapper.find('#globalRelaySmtpUsername').prop('disabled')).toBe(true);
expect(wrapper.find('#globalRelaySmtpPassword').prop('disabled')).toBe(true);
expect(wrapper.find('#globalRelayEmailAddress').prop('disabled')).toBe(true);
// controls should reflect config
expect(wrapper.find('#enableComplianceExport').prop('value')).toBe(false);
expect(wrapper.find('#exportJobStartTime').prop('value')).toBe('01:00');
expect(wrapper.find('#exportFormat').prop('value')).toBe('globalrelay');
expect(wrapper.find('#globalRelayCustomerType').prop('value')).toBe('A10');
expect(wrapper.find('#globalRelaySmtpUsername').prop('value')).toBe('globalRelayUser');
expect(wrapper.find('#globalRelaySmtpPassword').prop('value')).toBe('globalRelayPassword');
expect(wrapper.find('#globalRelayEmailAddress').prop('value')).toBe('globalRelay@mattermost.com');
});
test('should match snapshot, enabled, globalrelay', () => {
......@@ -53,7 +121,12 @@ describe('components/MessageExportSettings', () => {
DailyRunTime: '01:00',
ExportFromTimestamp: 12345678,
BatchSize: 10000,
GlobalRelayEmailAddress: 'test@mattermost.com',
GlobalRelaySettings: {
CustomerType: 'A10',
SmtpUsername: 'globalRelayUser',
SmtpPassword: 'globalRelayPassword',
EmailAddress: 'globalRelay@mattermost.com',
},
},
};
......@@ -63,5 +136,24 @@ describe('components/MessageExportSettings', () => {
/>
);
expect(wrapper).toMatchSnapshot();
// actiance config fields are enabled
expect(wrapper.find('#exportJobStartTime').prop('disabled')).toBe(false);
expect(wrapper.find('#exportFormat').prop('disabled')).toBe(false);
// globalrelay config fiels are enabled
expect(wrapper.find('#globalRelayCustomerType').prop('disabled')).toBe(false);
expect(wrapper.find('#globalRelaySmtpUsername').prop('disabled')).toBe(false);
expect(wrapper.find('#globalRelaySmtpPassword').prop('disabled')).toBe(false);
expect(wrapper.find('#globalRelayEmailAddress').prop('disabled')).toBe(false);
// controls should reflect config
expect(wrapper.find('#enableComplianceExport').prop('value')).toBe(true);
expect(wrapper.find('#exportJobStartTime').prop('value')).toBe('01:00');
expect(wrapper.find('#exportFormat').prop('value')).toBe('globalrelay');
expect(wrapper.find('#globalRelayCustomerType').prop('value')).toBe('A10');
expect(wrapper.find('#globalRelaySmtpUsername').prop('value')).toBe('globalRelayUser');
expect(wrapper.find('#globalRelaySmtpPassword').prop('value')).toBe('globalRelayPassword');
expect(wrapper.find('#globalRelayEmailAddress').prop('value')).toBe('globalRelay@mattermost.com');
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment