// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import AdminSettings from './admin_settings.jsx';
import SettingsGroup from './settings_group.jsx';
import DropdownSetting from './dropdown_setting.jsx';
import RadioSetting from './radio_setting.jsx';
import PostEditSetting from './post_edit_setting.jsx';
import BooleanSetting from './boolean_setting.jsx';
import TextSetting from './text_setting.jsx';
import ColorSetting from './color_setting.jsx';
import Constants from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
export default class PolicySettings extends AdminSettings {
constructor(props) {
super(props);
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
}
getConfigFromState(config) {
config.ServiceSettings.RestrictPostDelete = this.state.restrictPostDelete;
config.ServiceSettings.AllowEditPost = this.state.allowEditPost;
config.ServiceSettings.PostEditTimeLimit = this.parseIntNonZero(this.state.postEditTimeLimit, Constants.DEFAULT_POST_EDIT_TIME_LIMIT);
config.TeamSettings.RestrictTeamInvite = this.state.restrictTeamInvite;
config.TeamSettings.RestrictPublicChannelCreation = this.state.restrictPublicChannelCreation;
config.TeamSettings.RestrictPrivateChannelCreation = this.state.restrictPrivateChannelCreation;
config.TeamSettings.RestrictPublicChannelManagement = this.state.restrictPublicChannelManagement;
config.TeamSettings.RestrictPrivateChannelManagement = this.state.restrictPrivateChannelManagement;
config.TeamSettings.RestrictPublicChannelDeletion = this.state.restrictPublicChannelDeletion;
config.TeamSettings.RestrictPrivateChannelDeletion = this.state.restrictPrivateChannelDeletion;
config.TeamSettings.RestrictPrivateChannelManageMembers = this.state.restrictPrivateChannelManageMembers;
config.AnnouncementSettings.EnableBanner = this.state.enableBanner;
config.AnnouncementSettings.BannerText = this.state.bannerText;
config.AnnouncementSettings.BannerColor = this.state.bannerColor;
config.AnnouncementSettings.BannerTextColor = this.state.bannerTextColor;
config.AnnouncementSettings.AllowBannerDismissal = this.state.allowBannerDismissal;
return config;
}
getStateFromConfig(config) {
return {
restrictPostDelete: config.ServiceSettings.RestrictPostDelete,
allowEditPost: config.ServiceSettings.AllowEditPost,
postEditTimeLimit: config.ServiceSettings.PostEditTimeLimit,
restrictTeamInvite: config.TeamSettings.RestrictTeamInvite,
restrictPublicChannelCreation: config.TeamSettings.RestrictPublicChannelCreation,
restrictPrivateChannelCreation: config.TeamSettings.RestrictPrivateChannelCreation,
restrictPublicChannelManagement: config.TeamSettings.RestrictPublicChannelManagement,
restrictPrivateChannelManagement: config.TeamSettings.RestrictPrivateChannelManagement,
restrictPublicChannelDeletion: config.TeamSettings.RestrictPublicChannelDeletion,
restrictPrivateChannelDeletion: config.TeamSettings.RestrictPrivateChannelDeletion,
restrictPrivateChannelManageMembers: config.TeamSettings.RestrictPrivateChannelManageMembers,
enableBanner: config.AnnouncementSettings.EnableBanner,
bannerText: config.AnnouncementSettings.BannerText,
bannerColor: config.AnnouncementSettings.BannerColor,
bannerTextColor: config.AnnouncementSettings.BannerTextColor,
allowBannerDismissal: config.AnnouncementSettings.AllowBannerDismissal
};
}
renderTitle() {
return (
);
}
renderSettings() {
return (
}
value={this.state.restrictTeamInvite}
onChange={this.handleChange}
helpText={
}
/>
}
value={this.state.restrictPublicChannelCreation}
onChange={this.handleChange}
helpText={
}
/>
}
value={this.state.restrictPublicChannelManagement}
onChange={this.handleChange}
helpText={
}
/>
}
value={this.state.restrictPublicChannelDeletion}
onChange={this.handleChange}
helpText={
)
}}
/>
}
/>
}
value={this.state.restrictPrivateChannelCreation}
onChange={this.handleChange}
helpText={
}
/>
}
value={this.state.restrictPrivateChannelManagement}
onChange={this.handleChange}
helpText={
}
/>
}
value={this.state.restrictPrivateChannelManageMembers}
onChange={this.handleChange}
helpText={
}
/>
}
value={this.state.restrictPrivateChannelDeletion}
onChange={this.handleChange}
helpText={
)
}}
/>
}
/>
}
value={this.state.restrictPostDelete}
onChange={this.handleChange}
helpText={
}
/>
}
value={this.state.allowEditPost}
timeLimitValue={this.state.postEditTimeLimit}
onChange={this.handleChange}
helpText={
}
/>
}
helpText={
}
value={this.state.enableBanner}
onChange={this.handleChange}
/>
}
helpText={
}
value={this.state.bannerText}
onChange={this.handleChange}
disabled={!this.state.enableBanner}
/>
}
value={this.state.bannerColor}
onChange={this.handleChange}
disabled={!this.state.enableBanner}
/>
}
value={this.state.bannerTextColor}
onChange={this.handleChange}
disabled={!this.state.enableBanner}
/>
}
helpText={
}
value={this.state.allowBannerDismissal}
onChange={this.handleChange}
disabled={!this.state.enableBanner}
/>
);
}
}