summaryrefslogtreecommitdiffstats
path: root/webapp/components/admin_console/compliance_settings.jsx
blob: eac9bf097eb37e30195e6359e9d8c0ac4f8b756c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright (c) 2015 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 {FormattedHTMLMessage, FormattedMessage} from 'react-intl';
import SettingsGroup from './settings_group.jsx';
import TextSetting from './text_setting.jsx';

export default class ComplianceSettings extends AdminSettings {
    constructor(props) {
        super(props);

        this.getConfigFromState = this.getConfigFromState.bind(this);

        this.renderSettings = this.renderSettings.bind(this);
    }

    getConfigFromState(config) {
        config.ComplianceSettings.Enable = this.state.enable;
        config.ComplianceSettings.Directory = this.state.directory;
        config.ComplianceSettings.EnableDaily = this.state.enableDaily;

        return config;
    }

    getStateFromConfig(config) {
        return {
            enable: config.ComplianceSettings.Enable,
            directory: config.ComplianceSettings.Directory,
            enableDaily: config.ComplianceSettings.EnableDaily
        };
    }

    renderTitle() {
        return (
            <h3>
                <FormattedMessage
                    id='admin.compliance.title'
                    defaultMessage='Compliance Settings'
                />
            </h3>
        );
    }

    renderSettings() {
        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 (
            <SettingsGroup>
                {bannerContent}
                <BooleanSetting
                    id='enable'
                    label={
                        <FormattedMessage
                            id='admin.compliance.enableTitle'
                            defaultMessage='Enable Compliance Reporting:'
                        />
                    }
                    helpText={
                        <FormattedMessage
                            id='admin.compliance.enableDesc'
                            defaultMessage='When true, Mattermost allows compliance reporting'
                        />
                    }
                    value={this.state.enable}
                    onChange={this.handleChange}
                    disabled={!licenseEnabled}
                />
                <TextSetting
                    id='directory'
                    label={
                        <FormattedMessage
                            id='admin.compliance.directoryTitle'
                            defaultMessage='Compliance Report Directory:'
                        />
                    }
                    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>
        );
    }
}