diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-06-14 09:38:19 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-06-14 07:38:19 -0600 |
commit | a0cc913b85dea5023b705697afa5cd8749a6e5de (patch) | |
tree | debe3365ea1e66e94bd0a4738bf4faa0f10eac05 /webapp/components/admin_console/custom_emoji_settings.jsx | |
parent | 661f221727109f2298812fea89347bfeaf984109 (diff) | |
download | chat-a0cc913b85dea5023b705697afa5cd8749a6e5de.tar.gz chat-a0cc913b85dea5023b705697afa5cd8749a6e5de.tar.bz2 chat-a0cc913b85dea5023b705697afa5cd8749a6e5de.zip |
PLT-3143 Added serverside code for custom Emoji (#3311)
* Added model objects for emoji
* Added database tables for emoji
* Added settings for custom emoji
* Added serverside APIs and unit tests for custom emoji
* Added additional validation to catch duplicate emoji names earlier on
* Added additional validation to prevent users from adding emoji as another user
Diffstat (limited to 'webapp/components/admin_console/custom_emoji_settings.jsx')
-rw-r--r-- | webapp/components/admin_console/custom_emoji_settings.jsx | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/webapp/components/admin_console/custom_emoji_settings.jsx b/webapp/components/admin_console/custom_emoji_settings.jsx new file mode 100644 index 000000000..332c7b216 --- /dev/null +++ b/webapp/components/admin_console/custom_emoji_settings.jsx @@ -0,0 +1,91 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import * as Utils from 'utils/utils.jsx'; + +import AdminSettings from './admin_settings.jsx'; +import BooleanSetting from './boolean_setting.jsx'; +import DropdownSetting from './dropdown_setting.jsx'; +import {FormattedMessage} from 'react-intl'; +import SettingsGroup from './settings_group.jsx'; + +export default class CustomEmojiSettings extends AdminSettings { + constructor(props) { + super(props); + + this.getConfigFromState = this.getConfigFromState.bind(this); + + this.renderSettings = this.renderSettings.bind(this); + + this.state = Object.assign(this.state, { + enableCustomEmoji: props.config.ServiceSettings.EnableCustomEmoji, + restrictCustomEmojiCreation: props.config.ServiceSettings.RestrictCustomEmojiCreation + }); + } + + getConfigFromState(config) { + config.ServiceSettings.EnableCustomEmoji = this.state.enableCustomEmoji; + config.ServiceSettings.RestrictCustomEmojiCreation = this.state.restrictCustomEmojiCreation; + + return config; + } + + renderTitle() { + return ( + <h3> + <FormattedMessage + id='admin.customization.customEmoji' + defaultMessage='Custom Emoji' + /> + </h3> + ); + } + + renderSettings() { + return ( + <SettingsGroup> + <BooleanSetting + id='enableCustomEmoji' + label={ + <FormattedMessage + id='admin.customization.enableCustomEmojiTitle' + defaultMessage='Enable Custom Emoji:' + /> + } + helpText={ + <FormattedMessage + id='admin.customization.enableCustomEmojiDesc' + defaultMessage='Enable users to create custom emoji for use in chat messages.' + /> + } + value={this.state.enableCustomEmoji} + onChange={this.handleChange} + /> + <DropdownSetting + id='restrictCustomEmojiCreation' + values={[ + {value: 'all', text: Utils.localizeMessage('admin.customization.restrictCustomEmojiCreationAll', 'Allow everyone to create custom emoji')}, + {value: 'system_admin', text: Utils.localizeMessage('admin.customization.restrictCustomEmojiCreationSystemAdmin', 'Only allow system admins to create custom emoji')} + ]} + label={ + <FormattedMessage + id='admin.customization.restrictCustomEmojiCreationTitle' + defaultMessage='Restrict Custom Emoji Creation:' + /> + } + helpText={ + <FormattedMessage + id='admin.customization.restrictCustomEmojiCreationDesc' + defaultMessage='Restrict the creation of custom emoji to certain users.' + /> + } + value={this.state.restrictCustomEmojiCreation} + onChange={this.handleChange} + disabled={!this.state.enableCustomEmoji} + /> + </SettingsGroup> + ); + } +}
\ No newline at end of file |