// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import * as I18n from 'i18n/i18n.jsx'; import AdminSettings from './admin_settings.jsx'; import {FormattedMessage} from 'react-intl'; import SettingsGroup from './settings_group.jsx'; import DropdownSetting from './dropdown_setting.jsx'; import MultiSelectSetting from './multiselect_settings.jsx'; export default class LocalizationSettings extends AdminSettings { constructor(props) { super(props); this.getConfigFromState = this.getConfigFromState.bind(this); this.renderSettings = this.renderSettings.bind(this); this.canSave = this.canSave.bind(this); const locales = I18n.getAllLanguages(); this.state = Object.assign(this.state, { hasErrors: false, languages: Object.keys(locales).map((l) => { return {value: locales[l].value, text: locales[l].name}; }) }); } canSave() { return this.state.availableLocales.join(',').indexOf(this.state.defaultClientLocale) !== -1 || this.state.availableLocales.length === 0; } getConfigFromState(config) { config.LocalizationSettings.DefaultServerLocale = this.state.defaultServerLocale; config.LocalizationSettings.DefaultClientLocale = this.state.defaultClientLocale; config.LocalizationSettings.AvailableLocales = this.state.availableLocales.join(','); return config; } getStateFromConfig(config) { return { defaultServerLocale: config.LocalizationSettings.DefaultServerLocale, defaultClientLocale: config.LocalizationSettings.DefaultClientLocale, availableLocales: config.LocalizationSettings.AvailableLocales ? config.LocalizationSettings.AvailableLocales.split(',') : [] }; } renderTitle() { return (