// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import {recycleDatabaseConnection} from 'actions/admin_actions.jsx'; import * as Utils from 'utils/utils.jsx'; import AdminSettings from './admin_settings.jsx'; import BooleanSetting from './boolean_setting.jsx'; import {FormattedMessage} from 'react-intl'; import GeneratedSetting from './generated_setting.jsx'; import SettingsGroup from './settings_group.jsx'; import TextSetting from './text_setting.jsx'; import RequestButton from './request_button/request_button.jsx'; export default class DatabaseSettings extends AdminSettings { constructor(props) { super(props); this.getConfigFromState = this.getConfigFromState.bind(this); this.renderSettings = this.renderSettings.bind(this); } getConfigFromState(config) { // driverName and dataSource are read-only from the UI config.SqlSettings.MaxIdleConns = this.parseIntNonZero(this.state.maxIdleConns); config.SqlSettings.MaxOpenConns = this.parseIntNonZero(this.state.maxOpenConns); config.SqlSettings.AtRestEncryptKey = this.state.atRestEncryptKey; config.SqlSettings.Trace = this.state.trace; config.SqlSettings.QueryTimeout = this.parseIntNonZero(this.state.queryTimeout); return config; } getStateFromConfig(config) { return { driverName: config.SqlSettings.DriverName, dataSource: config.SqlSettings.DataSource, maxIdleConns: config.SqlSettings.MaxIdleConns, maxOpenConns: config.SqlSettings.MaxOpenConns, atRestEncryptKey: config.SqlSettings.AtRestEncryptKey, trace: config.SqlSettings.Trace, queryTimeout: config.SqlSettings.QueryTimeout }; } renderTitle() { return ( ); } renderSettings() { const dataSource = '**********' + this.state.dataSource.substring(this.state.dataSource.indexOf('@')); let recycleDbButton =
; if (global.window.mm_license.IsLicensed === 'true') { recycleDbButton = ( ), reloadConfiguration: ( ) }} /> } buttonText={ } showSuccessMessage={false} errorMessage={{ id: 'admin.recycle.reloadFail', defaultMessage: 'Recycling unsuccessful: {error}' }} includeDetailedError={true} /> ); } return (

{this.state.driverName}

{dataSource}

} placeholder={Utils.localizeMessage('admin.sql.maxConnectionsExample', 'Ex "10"')} helpText={ } value={this.state.maxIdleConns} onChange={this.handleChange} /> } placeholder={Utils.localizeMessage('admin.sql.maxOpenExample', 'Ex "10"')} helpText={ } value={this.state.maxOpenConns} onChange={this.handleChange} /> } placeholder={Utils.localizeMessage('admin.sql.queryTimeoutExample', 'Ex "30"')} helpText={ } value={this.state.queryTimeout} onChange={this.handleChange} /> } placeholder={Utils.localizeMessage('admin.sql.keyExample', 'Ex "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6"')} helpText={ } value={this.state.atRestEncryptKey} onChange={this.handleChange} /> } helpText={ } value={this.state.trace} onChange={this.handleChange} /> {recycleDbButton}
); } }