// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import * as Utils from 'utils/utils.jsx';
import Constants from 'utils/constants.jsx';
import AdminSettings from './admin_settings.jsx';
import BooleanSetting from './boolean_setting.jsx';
import DropdownSetting from './dropdown_setting.jsx';
import {FormattedHTMLMessage, FormattedMessage} from 'react-intl';
import SettingsGroup from './settings_group.jsx';
import TextSetting from './text_setting.jsx';
const RESTRICT_DIRECT_MESSAGE_ANY = 'any';
const RESTRICT_DIRECT_MESSAGE_TEAM = 'team';
export default class UsersAndTeamsSettings extends AdminSettings {
constructor(props) {
super(props);
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
}
getConfigFromState(config) {
config.TeamSettings.EnableUserCreation = this.state.enableUserCreation;
config.TeamSettings.EnableTeamCreation = this.state.enableTeamCreation;
config.TeamSettings.MaxUsersPerTeam = this.parseIntNonZero(this.state.maxUsersPerTeam, Constants.DEFAULT_MAX_USERS_PER_TEAM);
config.TeamSettings.RestrictCreationToDomains = this.state.restrictCreationToDomains;
config.TeamSettings.RestrictDirectMessage = this.state.restrictDirectMessage;
config.TeamSettings.TeammateNameDisplay = this.state.teammateNameDisplay;
config.TeamSettings.MaxChannelsPerTeam = this.parseIntNonZero(this.state.maxChannelsPerTeam, Constants.DEFAULT_MAX_CHANNELS_PER_TEAM);
config.TeamSettings.MaxNotificationsPerChannel = this.parseIntNonZero(this.state.maxNotificationsPerChannel, Constants.DEFAULT_MAX_NOTIFICATIONS_PER_CHANNEL);
return config;
}
getStateFromConfig(config) {
return {
enableUserCreation: config.TeamSettings.EnableUserCreation,
enableTeamCreation: config.TeamSettings.EnableTeamCreation,
maxUsersPerTeam: config.TeamSettings.MaxUsersPerTeam,
restrictCreationToDomains: config.TeamSettings.RestrictCreationToDomains,
restrictDirectMessage: config.TeamSettings.RestrictDirectMessage,
teammateNameDisplay: config.TeamSettings.TeammateNameDisplay,
maxChannelsPerTeam: config.TeamSettings.MaxChannelsPerTeam,
maxNotificationsPerChannel: config.TeamSettings.MaxNotificationsPerChannel
};
}
renderTitle() {
return (
);
}
renderSettings() {
return (
}
helpText={
}
value={this.state.enableUserCreation}
onChange={this.handleChange}
/>
}
helpText={
}
value={this.state.enableTeamCreation}
onChange={this.handleChange}
/>
}
placeholder={Utils.localizeMessage('admin.team.maxUsersExample', 'Ex "25"')}
helpText={
}
value={this.state.maxUsersPerTeam}
onChange={this.handleChange}
/>
}
placeholder={Utils.localizeMessage('admin.team.maxChannelsExample', 'Ex "100"')}
helpText={
}
value={this.state.maxChannelsPerTeam}
onChange={this.handleChange}
/>
}
placeholder={Utils.localizeMessage('admin.team.maxNotificationsPerChannelExample', 'Ex "1000"')}
helpText={
}
value={this.state.maxNotificationsPerChannel}
onChange={this.handleChange}
/>
}
placeholder={Utils.localizeMessage('admin.team.restrictExample', 'Ex "corp.mattermost.com, mattermost.org"')}
helpText={
}
value={this.state.restrictCreationToDomains}
onChange={this.handleChange}
/>
}
helpText={
}
value={this.state.restrictDirectMessage}
onChange={this.handleChange}
/>
}
helpText={
}
value={this.state.teammateNameDisplay}
onChange={this.handleChange}
/>
);
}
}