// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import AdminSettings from './admin_settings.jsx'; import BooleanSetting from './boolean_setting.jsx'; import TextSetting from './text_setting.jsx'; import {FormattedMessage, FormattedHTMLMessage} from 'react-intl'; import SettingsGroup from './settings_group.jsx'; import ClusterTableContainer from './cluster_table_container.jsx'; import AdminStore from 'stores/admin_store.jsx'; import * as Utils from 'utils/utils.jsx'; export default class ClusterSettings extends AdminSettings { constructor(props) { super(props); this.getConfigFromState = this.getConfigFromState.bind(this); this.renderSettings = this.renderSettings.bind(this); } getConfigFromState(config) { config.ClusterSettings.Enable = this.state.enable; config.ClusterSettings.InterNodeListenAddress = this.state.interNodeListenAddress; config.ClusterSettings.InterNodeUrls = this.state.interNodeUrls.split(','); config.ClusterSettings.InterNodeUrls = config.ClusterSettings.InterNodeUrls.map((url) => { return url.trim(); }); if (config.ClusterSettings.InterNodeUrls.length === 1 && config.ClusterSettings.InterNodeUrls[0] === '') { config.ClusterSettings.InterNodeUrls = []; } return config; } getStateFromConfig(config) { const settings = config.ClusterSettings; return { enable: settings.Enable, interNodeUrls: settings.InterNodeUrls.join(', '), interNodeListenAddress: settings.InterNodeListenAddress, showWarning: false }; } renderTitle() { return (

); } overrideHandleChange(id, value) { this.setState({ showWarning: true }); this.handleChange(id, value); } renderSettings() { const licenseEnabled = global.window.mm_license.IsLicensed === 'true' && global.window.mm_license.Cluster === 'true'; if (!licenseEnabled) { return null; } var configLoadedFromCluster = null; if (AdminStore.getClusterId()) { configLoadedFromCluster = (
); } var warning = null; if (this.state.showWarning) { warning = (
); } var clusterTableContainer = null; if (this.state.enable) { clusterTableContainer = (); } return ( {configLoadedFromCluster} {clusterTableContainer}

{warning} } helpText={ } value={this.state.enable} onChange={this.overrideHandleChange} disabled={true} /> } placeholder={Utils.localizeMessage('admin.cluster.interNodeListenAddressEx', 'Ex ":8075"')} helpText={ } value={this.state.interNodeListenAddress} onChange={this.overrideHandleChange} disabled={true} /> } placeholder={Utils.localizeMessage('admin.cluster.interNodeUrlsEx', 'Ex "http://10.10.10.30, http://10.10.10.31"')} helpText={ } value={this.state.interNodeUrls} onChange={this.overrideHandleChange} disabled={true} />
); } }