// Copyright (c) 2015-present 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, FormattedHTMLMessage} 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, order: locales[l].order};
}).sort((a, b) => a.order - b.order)
});
}
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 (
);
}
renderSettings() {
return (
}
value={this.state.defaultServerLocale}
onChange={this.handleChange}
helpText={
}
/>
}
value={this.state.defaultClientLocale}
onChange={this.handleChange}
helpText={
}
/>
}
selected={this.state.availableLocales}
onChange={this.handleChange}
helpText={
}
noResultText={
}
notPresent={
}
/>
);
}
}