2017-04-12 08:27:57 -04:00
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
2016-03-14 16:07:58 -07:00
// See License.txt for license information.
2016-05-17 07:21:39 -04:00
import React from 'react' ;
2016-03-14 16:07:58 -07:00
2016-05-17 07:21:39 -04:00
import * as Utils from 'utils/utils.jsx' ;
2016-03-16 18:35:53 -07:00
2016-05-17 07:21:39 -04:00
import AdminSettings from './admin_settings.jsx' ;
import BooleanSetting from './boolean_setting.jsx' ;
import { FormattedHTMLMessage , FormattedMessage } from 'react-intl' ;
import SettingsGroup from './settings_group.jsx' ;
import TextSetting from './text_setting.jsx' ;
2016-03-14 16:07:58 -07:00
2016-05-17 07:21:39 -04:00
export default class ComplianceSettings extends AdminSettings {
2016-03-14 16:07:58 -07:00
constructor ( props ) {
super ( props ) ;
2016-05-17 07:21:39 -04:00
this . getConfigFromState = this . getConfigFromState . bind ( this ) ;
2016-03-14 16:07:58 -07:00
2016-05-17 07:21:39 -04:00
this . renderSettings = this . renderSettings . bind ( this ) ;
2016-03-14 16:07:58 -07:00
}
2016-05-17 07:21:39 -04:00
getConfigFromState ( config ) {
config . ComplianceSettings . Enable = this . state . enable ;
config . ComplianceSettings . Directory = this . state . directory ;
config . ComplianceSettings . EnableDaily = this . state . enableDaily ;
2016-03-14 16:07:58 -07:00
2016-05-17 07:21:39 -04:00
return config ;
2016-03-14 16:07:58 -07:00
}
2016-07-06 16:07:56 -04:00
getStateFromConfig ( config ) {
return {
enable : config . ComplianceSettings . Enable ,
directory : config . ComplianceSettings . Directory ,
enableDaily : config . ComplianceSettings . EnableDaily
} ;
}
2016-05-17 07:21:39 -04:00
renderTitle ( ) {
return (
2017-03-30 12:46:47 -04:00
< FormattedMessage
id = 'admin.compliance.title'
defaultMessage = 'Compliance Settings'
/ >
2016-05-17 07:21:39 -04:00
) ;
}
2016-03-14 16:07:58 -07:00
2016-05-17 07:21:39 -04:00
renderSettings ( ) {
2016-03-14 16:07:58 -07:00
const licenseEnabled = global . window . mm _license . IsLicensed === 'true' && global . window . mm _license . Compliance === 'true' ;
let bannerContent ;
if ( ! licenseEnabled ) {
bannerContent = (
< div className = 'banner warning' >
< div className = 'banner__content' >
< FormattedHTMLMessage
id = 'admin.compliance.noLicense'
defaultMessage = '<h4 class="banner__heading">Note:</h4><p>Compliance is an enterprise feature. Your current license does not support Compliance. Click <a href="http://mattermost.com"target="_blank">here</a> for information and pricing on enterprise licenses.</p>'
/ >
< / div >
< / div >
) ;
}
return (
2016-05-17 07:21:39 -04:00
< SettingsGroup >
2016-03-14 16:07:58 -07:00
{ bannerContent }
2016-05-17 07:21:39 -04:00
< BooleanSetting
id = 'enable'
label = {
< FormattedMessage
id = 'admin.compliance.enableTitle'
2016-07-05 07:26:22 -04:00
defaultMessage = 'Enable Compliance Reporting:'
2016-05-17 07:21:39 -04:00
/ >
}
helpText = {
2016-08-01 11:21:50 -04:00
< FormattedHTMLMessage
2016-05-17 07:21:39 -04:00
id = 'admin.compliance.enableDesc'
2016-08-01 11:21:50 -04:00
defaultMessage = 'When true, Mattermost allows compliance reporting from the <strong>Compliance and Auditing</strong> tab. See <a href="https://docs.mattermost.com/administration/compliance.html" target="_blank">documentation</a> to learn more.'
2016-05-17 07:21:39 -04:00
/ >
}
value = { this . state . enable }
onChange = { this . handleChange }
disabled = { ! licenseEnabled }
/ >
< TextSetting
id = 'directory'
label = {
< FormattedMessage
id = 'admin.compliance.directoryTitle'
2016-07-05 07:26:22 -04:00
defaultMessage = 'Compliance Report Directory:'
2016-05-17 07:21:39 -04:00
/ >
}
placeholder = { Utils . localizeMessage ( 'admin.sql.maxOpenExample' , 'Ex "10"' ) }
helpText = {
< FormattedMessage
id = 'admin.compliance.directoryDescription'
defaultMessage = 'Directory to which compliance reports are written. If blank, will be set to ./data/.'
/ >
}
value = { this . state . directory }
onChange = { this . handleChange }
disabled = { ! licenseEnabled || ! this . state . enable }
/ >
< BooleanSetting
id = 'enableDaily'
label = {
< FormattedMessage
id = 'admin.compliance.enableDailyTitle'
defaultMessage = 'Enable Daily Report:'
/ >
}
helpText = {
< FormattedMessage
id = 'admin.compliance.enableDailyDesc'
defaultMessage = 'When true, Mattermost will generate a daily compliance report.'
/ >
}
value = { this . state . enableDaily }
onChange = { this . handleChange }
disabled = { ! licenseEnabled || ! this . state . enable }
/ >
< / SettingsGroup >
2016-03-14 16:07:58 -07:00
) ;
}
2016-07-05 07:26:22 -04:00
}