// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import * as Client from '../../utils/client.jsx'; import * as AsyncClient from '../../utils/async_client.jsx'; import {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'react-intl'; import React from 'react'; import ReactDOM from 'react-dom'; var holders = defineMessages({ saving: { id: 'admin.compliance.saving', defaultMessage: 'Saving Config...' }, directoryExample: { id: 'admin.compliance.directoryExample', defaultMessage: 'Ex "./data/"' } }); class ComplianceSettings extends React.Component { constructor(props) { super(props); this.handleSubmit = this.handleSubmit.bind(this); this.handleChange = this.handleChange.bind(this); this.handleEnable = this.handleEnable.bind(this); this.handleDisable = this.handleDisable.bind(this); this.state = { saveNeeded: false, serverError: null, enable: this.props.config.ComplianceSettings.Enable }; } handleChange() { this.setState({saveNeeded: true}); } handleEnable() { this.setState({saveNeeded: true, enable: true}); } handleDisable() { this.setState({saveNeeded: true, enable: false}); } handleSubmit(e) { e.preventDefault(); $('#save-button').button('loading'); const config = this.props.config; config.ComplianceSettings.Enable = this.refs.Enable.checked; config.ComplianceSettings.Directory = ReactDOM.findDOMNode(this.refs.Directory).value; config.ComplianceSettings.EnableDaily = this.refs.EnableDaily.checked; Client.saveConfig( config, () => { AsyncClient.getConfig(); this.setState({ serverError: null, saveNeeded: false }); $('#save-button').button('reset'); }, (err) => { this.setState({ serverError: err.message, saveNeeded: true }); $('#save-button').button('reset'); } ); } render() { const {formatMessage} = this.props.intl; let serverError = ''; if (this.state.serverError) { serverError =
; } let saveClass = 'btn'; if (this.state.saveNeeded) { saveClass = 'btn btn-primary'; } const licenseEnabled = global.window.mm_license.IsLicensed === 'true' && global.window.mm_license.Compliance === 'true'; let bannerContent; if (!licenseEnabled) { bannerContent = (